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: Affine Transforms in gvtBuildCompleted callback
Date Thu, 03 Feb 2005 02:19:58 GMT
Caron, Michael R wrote:

> Thanks for all the help so far in using Batik.

   No problem,

> I have a question regarding the use of Affine Transforms in the
> gvtBuildCompleted callback. I defined the method to be as follows:
> 
>     GraphicsNode g = e.getGVTRoot();
>     AffineTransform tx = g.getTransform();

    The root node doesn't have the viewing transform the
the root node is a special 'RootGraphicsNode' which there
can be only one of in a GVT tree.  The actual CanvasGraphicsNode
(which is the peer of an SVG element with a viewing transform)
is the first child of the root graphics node.  Here is sample
code from the JSVGComponent that get's the CanvasGraphicsNode:

     protected CanvasGraphicsNode getCanvasGraphicsNode(GraphicsNode gn) {
         if (!(gn instanceof CompositeGraphicsNode))
             return null;
         CompositeGraphicsNode cgn = (CompositeGraphicsNode)gn;
         List children = cgn.getChildren();
         if (children.size() == 0)
             return null;
         gn = (GraphicsNode)children.get(0);
         if (!(gn instanceof CanvasGraphicsNode))
             return null;
         return (CanvasGraphicsNode)gn;
     }

> I would assume that since the JSVGCanvas onto which I am loading the
> document is constrained by the Jpanel it is contained by, neither of
> which have PreferredWidth and Height as large as the SVG document
> itself, that there would be an implicit transform. But it turns out that
> tx is null. 

    Be a little careful when the Canvas parses a SVG document the
it calls 'setMySize' which set's the preferred size of the component.


> Why would the tx be null? And how would I get the translated heights and
> widths of the SVG rendered onto the JSVGComponent (not the height and
> width of the canvas itself, but the actual image as translated onto the
> canvas)?

	Rectangle2D bounds = canvas.getGraphicsNode().getBounds();

    Because the viewing transform is applied to the child of the
root graphics node it's bounds should be the translated size of
the content.


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


Mime
View raw message