xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Evenblij, Paul" <Paul_Evenb...@nl.compuware.com>
Subject RE: SVGGraphics2D.getRoot() truncates SVG document?
Date Mon, 17 Sep 2001 16:13:05 GMT
From: George Armhold [mailto:armhold@cs.rutgers.edu]
> Vincent Hardy wrote:
> > You can also have a look at the DOMTreeManager and the 
> DOMGroupManager
> > for more explanations on how the DOM is managed in SVGGraphics2D.
> Actually I'm already trying to follow the model in SwingPrettyPrint
> but I'm still baffled (an annotated version of that code would be
> really helpful to us mere mortals.) I can't figure out how to get
> access to either the <svg> or <defs> tag in the document so I can
> append a <script> tag containing some javascript common to the entire
> document.  Following the example in SwingPrettyPrint I can get access
> to the <g> nodes, but I can't seem to get above that in the document
> structure without mangling it.  


What I did to solve this problem for my case:

  SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx, false);
  DOMTreeManager treeManager = svgGenerator.getDOMTreeManager();

  // create the <defs> element containing our scripts
  Element scriptDefs = createScriptDefs(document);
  // give it to the tree manager
  treeManager.appendGroup(scriptDefs, null);

As far as I can tell, the treeManager takes care of z-order administration
when more than one SVGGraphics2D instance are adding to the same tree. It
will append your group to the topLevelGroup and tell all domGroupManagers
(every SVGGraphics2D instance has one) that a new group will be started. I
don't know of any other way to add to the top level (short of hacking your
own way in the Batik code, that is;)

Hope this helps,

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

View raw message