Let's say I want to draw a blue rectangle with a red border.
Ideally the SVG element should look like this: <rect
style="fill:blue;stroke:red"/>

I would imagine using the following code with SVGGraphics2D.
 svgGraphics2D.setPaint(Color.RED);
 svgGraphics2D.draw(rect);
 svgGraphics2D.setPaint(Color.BLUE);
 svgGraphics2D.fill(rect);

Unfortunately this code resulted in two elements:
 <rect style="fill:none;stroke:red"/>
 <rect style="fill:blue;stroke:none"/>

The generated code makes sense from a Java2D perspective, but it is
not optimal for SVG since it effectively doubles the footprint of the
output.
Does anyone know if Batik provides a way to generate the optimal
single element syntax?

It sounds like I need to extend my own SVGGraphics2D to associate a
shape instance to a cached element instance and set the fill/stroke
manually based on the drawing commands.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org

Reply via email to