xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eastman, David" <david.east...@lmco.com>
Subject RE: Resizing graphics automatically when Jframe resizes
Date Tue, 07 Feb 2006 21:29:41 GMT
I'm using a BorderLayout.CENTER for the JFrame and JPanel, and I'm
pretty sure the JSVGCanvas is resizing correctly.  For the document, I'm
doing the following:

svgCanvas.getSVGDocument().getRootElement().setAttributeNS("null","viewb
ox",svgCanvas.getX()+" "+svgCanvas.getY()+" "+svgCanvas.getWidth()+"
"+svgCanvas.getHeight());
svgCanvas.getSVGDocument().getRootElement().setAttributeNS("null","prese
rveAspectRatio","xMidYMid meet");

I tried putting this on a button ActionListener and forcing a repaint(),
but the graphic still refuses to change size...  I'm not sure where the
"correct" place for it would be (given the sample application).  Or is
there something else I'm missing?

Thanks,
David


-----Original Message-----
From: Urs Reupke [mailto:ursreupke@gmx.net] 
Sent: Tuesday, February 07, 2006 12:07 PM
To: batik-users@xmlgraphics.apache.org
Subject: Re: Resizing graphics automatically when Jframe resizes


Hi David

Eastman, David wrote:
> I want
> my SVG graphic to have the following behavior:
> 
> -Graphic fills the JPanel containing the JSVGCanvas
> -Graphic is centered in the JPanel
> -Graphic automatically resizes to fill the JPanel when the user 
> resizes
> the JFrame

The basics for the first and third of these properties are rooted in the

layout manager you use within the JPanel. Tell it to automatically 
resize the JSVGCanvas to the panel's size, and your halfway done.

Afterwards, you'll need to tell the document (not Batik) to fill the 
canvas. To do so, you have to add some attributes to the main "svg"
element. I believe the attributes you're looking for are "viewBox" and 
"preserveAspectRatio". You might want to consult the SVG 
Specification[1] and read through items 7.7 and 7.8.

I believe the second property can be handled by using the same 
attributes, but I have never attempted to do so.

Have fun
-Urs

[1]SVG Specification on coordinate systems
http://www.w3.org/TR/SVG11/coords.html#ViewportSpace

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message