xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bishop, Michael W. CONTR J9C880" <Michael.Bis...@je.jfcom.mil>
Subject RE: Resizing graphics automatically when Jframe resizes
Date Wed, 08 Feb 2006 05:31:54 GMT
I think you have to run all changes to the document through the UpdateManager:
 
JSVGCanvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(Runnable runnable);
 
Michael Bishop

________________________________

From: Eastman, David [mailto:david.eastman@lmco.com]
Sent: Tue 2/7/2006 4:29 PM
To: batik-users@xmlgraphics.apache.org
Subject: RE: Resizing graphics automatically when Jframe resizes



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