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 20:02:28 GMT
I'm sorry, I wrote that kind of quick.  You'd make a class that
implements Runnable and make the changes in the run method.

 

public class ResizeCanvas implements Runnable {

   public void run() {

      // Changes to svgDocument go in here.

   }

}

 

________________________________

From: Eastman, David [mailto:david.eastman@lmco.com] 
Sent: Wednesday, February 08, 2006 1:13 PM
To: batik-users@xmlgraphics.apache.org
Subject: RE: Resizing graphics automatically when Jframe resizes

 

Michael,

 

I'm a bit confused.  What is the runnable object I am adding to the
queue?  The svgCanvas?  svgCanvas.getSVGDocument?  Or something else?

 

Thanks,

David

 

	-----Original Message-----
	From: Bishop, Michael W. CONTR J9C880
[mailto:Michael.Bishop@je.jfcom.mil] 
	Sent: Tuesday, February 07, 2006 9:32 PM
	To: batik-users@xmlgraphics.apache.org
	Subject: RE: Resizing graphics automatically when Jframe resizes

	I think you have to run all changes to the document through the
UpdateManager:

	 

	
JSVGCanvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(Runna
ble 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


Mime
View raw message