Hi Olivier,
kpu <[email protected]> wrote on 04/05/2010 08:44:12 AM:
> thomas.deweese wrote:
> >
> > You need to call 'getRoot(element_g)' this will append everything
> > drawn since the graphics was constructed, or the last time getRoot was
> > called as children of 'element_g'.
> >> m1.draw(svgGenerator);
> > svgGenerator.getRoot(g1);
> >> m2.draw(svgGenerator);
> > svgGenerator.getRoot(g2);
> >
>
> I try :
>
> Element elt1_g =
>
svgGenerator.getDOMFactory().createElementNS(SVGGraphics2D.SVG_NAMESPACE_URI,
> SVGGraphics2D.SVG_G_TAG);
> Element elt2_g =
>
>
svgGenerator.getDOMFactory().createElementNS(SVGGraphics2D.SVG_NAMESPACE_URI,
> SVGGraphics2D.SVG_G_TAG);
>
> m1.draw(svgGenerator);
> svgGenerator.getRoot(elt1_g);
>
> m2.draw(svgGenerator);
> svgGenerator.getRoot(elt2_g);
>
>
> Result is :
> <svg><defs id="genericDefs"/><g/></svg>
I assume that is from calling 'svgGenerator.stream'?
That is why I said:
> thomas.deweese wrote:
> >
> >
> >> // Finally, stream out SVG to the standard output using
> >> // UTF-8 encoding.
> >
> > You will need to manage the streaming of the SVG yourself.
> > There are many options for this but two from Batik are
> > batik.svggen.XmlWriter or I think a little better is
> > bati.dom.DOMUtilities.
When you call 'getRoot' the content is removed from the
SVGGraphics2D and put in the g element you give it. It is
then your responsibility to append that group to a document
however you want and stream it out. This gives you complete
control over the structure of your document.
Good luck.