Hi Thomas,
thomas.deweese wrote:
>
> Hi Olivier,
>
>>
>> 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.
>
>
I understand better, so I try :
m1.draw(svgGenerator);
svgGenerator.getRoot(elt1_g);
m2.draw(svgGenerator);
svgGenerator.getRoot(elt2_g);
Node node = documentGrouped.importNode(elt1_g, true);
documentGrouped.getDocumentElement().appendChild(node);
node = documentGrouped.importNode(elt2_g, true);
documentGrouped.getDocumentElement().appendChild(node);
Element svgRoot = documentGrouped.getDocumentElement();
svgRoot.setAttributeNS(SVGSyntax.XMLNS_NAMESPACE_URI,
SVGSyntax.XMLNS_PREFIX,
SVGSyntax.SVG_NAMESPACE_URI);
svgRoot.setAttributeNS(SVGSyntax.XMLNS_NAMESPACE_URI,
SVGSyntax.XMLNS_PREFIX + ":" + SVGSyntax.XLINK_PREFIX,
SVGSyntax.SVG_NAMESPACE_URI);
System.out.println(DOMUtilities.getXML(documentGrouped.getFirstChild()));
output :
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/2000/svg">
<g fill-opacity="1" color-rendering="auto" color-interpolation="auto"
text-rendering="auto" stroke="black" stroke-linecap="square"
stroke-miterlimit="10" shape-rendering="auto" stroke-opacity="1"
fill="black" stroke-dasharray="none" font-weight="normal" stroke-width="1"
font-family="'Dialog'" font-style="normal" stroke-linejoin="miter"
font-size="12" image-rendering="auto" stroke-dashoffset="0">
<!--Generated by the Batik Graphics2D SVG Generator-->
<defs id="genericDefs"/>
<g>
<g fill="blue" stroke="blue">
<circle r="25" cx="25" cy="25" stroke="none"/>
</g>
</g>
</g>
<g fill-opacity="1" color-rendering="auto" color-interpolation="auto"
text-rendering="auto" stroke="black" stroke-linecap="square"
stroke-miterlimit="10" shape-rendering="auto" stroke-opacity="1"
fill="black" stroke-dasharray="none" font-weight="normal" stroke-width="1"
font-family="'Dialog'" font-style="normal" stroke-linejoin="miter"
font-size="12" image-rendering="auto" stroke-dashoffset="0">
<!--Generated by the Batik Graphics2D SVG Generator-->
<defs id="genericDefs"/>
<g>
<g fill="lime" stroke="lime">
<rect x="0" width="50" y="50" height="50" stroke="none"/>
</g>
</g>
</g>
</svg>
Aside from the multiple statements (same id values, comments...) it's Ok !
Thanks !
--
View this message in context:
http://old.nabble.com/SVGGraphics2D-how-to-group-elements-tp28129357p28144661.html
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]