xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Deikman <Alan.Deik...@znyx.com>
Subject Re: Merging one document with another in a JSVGCanvas
Date Tue, 31 Mar 2009 18:21:34 GMT
thomas.deweese@kodak.com wrote:
>    Right.  The easiest way to map things is to get the bbox of
> 'node' (same as position above). 

I was trying to avoid this, because at the time that 'node' is imported, 
the GVT tree isn't computed so node.getBBox() returns null.  I did 
figure out how to get it computed as follows:

           UserAgentAdapter agent = new UserAgentAdapter();
           BridgeContext ctx = new BridgeContext(agent);
           GVTBuilder builder = new GVTBuilder();
           GraphicsNode rootGN = builder.build(ctx, ourDoc);

And then all the bboxes are available.  Question: does invoking a 
GVTBuilder() at this point have any bad side effects or is there another 
way of doing this?  Remember I am doing this inside the UpdateManager's 

So far I have discovered that I can get the translation done by just 
setting the viewport on the SVG element as follows:

           node.setAttribute("x", Double.toString(position.getX()));
           node.setAttribute("y", Double.toString(position.getY()));
           node.setAttribute("width", Double.toString(position.getWidth()));

This way I don't need the bbox of 'node'.   However, once I need 
rotation it all gets screwed up both in terms of position and scale.   
I'm still working on that but I wanted to follow up on your helpful post 
with what I had so far.

Alan Deikman

View raw message