xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas DeWeese <Thomas.DeWe...@Kodak.com>
Subject Re: using JSVGCanvas to draw somewhere else
Date Fri, 23 Jul 2004 10:28:16 GMT
Tonny Kohar wrote:

>>2) Why does GraphicsNode.getBounds()sometimes return really tiny
>>rectangles? (Drawing many of the sample SVGs included with Batik
>>renders them in a 1 or 2 pixel box, and I have to zoom the hell out of
>>the transform in order to see anything. Still, other SVG samples
>>display at the proper size.)

    I suspect this is caused by loading the SVG before the JSVGCanvas
has a size.  If the canvas doesn't have a size (or size is zero) it
set's it's size to 1 for purposes of calculating the viewing

    This raises the other issue I was going to mention which is the
JSVGCanvas may not be what you want to be using here.  A better
match might be to use the batik.transcoder.SVGAbstractTranscoder.
This will build the GVT tree and set the viewing transform in a
bit lighter weight manner - and also probably easier to understand.

> It maybe because the viewbox or transform stuff. Try to calculate the
> bounds by applying the transform of graphicsNode.getGlobalTransform()
> eg: 
> Shape shape = (Shape)graphicsNode.getBounds();
> AffineTransform at = graphicsNode.getGlobalTransform()
> shape = at.createTransformedShape(shape);
> Rectangle bounds = shape.getBounds();
> Regards
> Tonny Kohar

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

View raw message