xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Javid Alimohideen" <javid...@gmail.com>
Subject Batik offscreen rendering howto?
Date Sat, 04 Mar 2006 01:28:03 GMT
H
I have a dynamic renderer in my application to render the svg content
(offscreen). The rendering works fine but if I make some changes to the
document the renderer.repaint method doesn't reflect the changes made to the
dom. I am pasting the source code of my render method:
The root variable was built using the GVT builder.
Thanks for your help,

Javid

public synchronized BufferedImage getRenderedImage(GraphicsNode root,
AffineTransform transform, int width, int height) {


		BufferedImage dest = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);

		renderer.updateOffScreen(width, height);
		renderer.setTree(root);
		renderer.setTransform(transform);


		java.awt.Rectangle r = new java.awt.Rectangle( 0, 0, width, height);
		try {
			renderer.repaint( transform.createInverse().createTransformedShape(r) );
		}
		catch (Exception e) { e.printStackTrace(); }

		BufferedImage rend = renderer.getOffScreen();
		//renderer = null;

		Graphics2D g2d = GraphicsUtil.createGraphics(dest);
		g2d.setComposite(AlphaComposite.SrcOver);
		g2d.setColor(java.awt.Color.black);
		g2d.fillRect(0, 0, width, height);
		if (rend != null) {
			g2d.drawRenderedImage(rend, new AffineTransform());
		}
		renderer = null;
		g2d.dispose();
		rend = null;
		return dest;
}


---------------------------------------------------------------------
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