xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kpu <olivier.capuo...@gmail.com>
Subject Re: SVGGraphics2D how to group elements
Date Mon, 05 Apr 2010 12:44:12 GMT

Hi Thomas,


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

svgGenerator.getRoot(elt1_g);
m1.draw(svgGenerator);

svgGenerator.getRoot(elt2_g);      
m2.draw(svgGenerator);

Result is : 
<svg><defs id="genericDefs"/><g> svg instructions of m2  </g></svg>

Normal, because the svg root change after m1 drawing, so svg instructions m1
are lost.


Helder Magalhães wrote:
> 
> I'm not sure what you mean with "by component"... I didn't found a
> relevant enough difference in the code snippets which would help
> understanding the difference. Please clear it up a bit in order to get
> interesting feedback, [...]
> 

I want to get the following general schema :
 
<svg>
<g>
  <g> svg instructions of m1  </g>
  <g> svg instructions of m2    </g>
   ...
  <g> svg instructions of m n    </g>
<g>
</svg>


And NOT as the default ouput :

<svg>
<g>
 svg instructions of m1 
 svg instructions of m2 
   ...
 svg instructions of m n 
<g>
</svg>



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

After treatment ?
But, how to distinguish the blocks of instructions between them (m1 and m2 )
?

Thanks for your help




-- 
View this message in context: http://old.nabble.com/SVGGraphics2D-how-to-group-elements-tp28129357p28139659.html
Sent from the Batik - Users mailing list archive at Nabble.com.


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