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 Merging one document with another in a JSVGCanvas
Date Sat, 28 Mar 2009 00:35:15 GMT
A few weeks ago I was painting one or more JSVGCanvas objects on top of 
another to build a display with multiple document roots.  This works 
pretty well by using the JContainer.add() method, then you can use Swing 
methods to size and position the child JSVGCanvas.  However it has some 
drawbacks -- the deal breaker for me was reconciling the coordinate 
systems and CTMs of both the parent and child objects so that the child 
showed up where I wanted it to in the right scale.   Further, the 
kbd/mouse interactors for both objects remain completely separate.

So I learned how to do the following:

      SVGDocument ourDoc = getSVGDocument();
      SVGSVGElement root = ourDoc.getRootElement();

      // now get another document and import it

      SVGDocument doc = otherCanvas.getSVGDocument();
      SVGSVGElement panelRoot = doc.getRootElement();
      SVGOMSVGElement node = (SVGOMSVGElement)
                     ourDoc.importNode(panelRoot, true);

      // now add it to the display

      root.appendChild(node);
         
So far so good.  The next step is what I need help with, which is to 
scale, translate, and possibly rotate the sub-document in "node" to a 
fixed place in "root."   I have the target position as follows:

      SVGGraphicsElement position = (SVGGraphicsElement) 
ourDoc.getElementByID("xyzzy");
      SVGRect targetRect = position.getBBox();

So what is the most efficient way to get "node" to appear exactly on top 
of "targetRect?"   I have gotten hopelessly confused over the various 
viewports, viewboxes, and transforms involved. 

I may also need to rotate node by 90 degrees.  Since node is an SVG 
element, it won't take a transform, so do I need to encapsulate it 
inside a G element?

Much thanks for any help on this.

-- 
Alan Deikman
ZNYX Networks


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