xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vincent Hardy <vincent.ha...@sun.com>
Subject Re: How to produce SAX events from SVGGraphics2D
Date Mon, 01 Oct 2001 13:17:47 GMT
Stephan,

In your code, are you actually doing both the System.out and 
the DOMStreamer? If so, try to do the DOMStreamer only.

The stream method resets the content of the of the SVGGraphics2D
which is 'empty' (i.e., clean canvas), after the call...

See:

public void stream(Writer writer, boolean useCss) 

in SVGGraphics2D.

Vincent.

Stephan Michels wrote:
> 
> hi,
> I want to write a Transformer for cocoon, and use the batik
> SVGGraphics2D class. To produce the SAX events I use
> the DOMStreamer from cocoon. But the xml file which the
> DOMStreamer produce is not complete. Has anyone
> a working example, or can help me?
> 
> <snippet>
> DOMImplementation domImpl =
>   GenericDOMImplementation.getDOMImplementation();
> Document document = domImpl.createDocument(null, "svg", null);
> SVGGraphics2D g = new SVGGraphics2D(document);
> g.setSVGCanvasSize(new
>   Dimension(rootElement.getWidth(),rootElement.getHeight()));
> rootElement.toSVG(g, 0, rootElement.getHeight()/2);
> 
> try
> {
>   boolean useCSS = true;
>   Writer out = new OutputStreamWriter(System.out, "UTF-8");
>   g.stream(out, useCSS);
> } catch (Exception e)
> {
>   e.printStackTrace();
> }
> 
> DOMStreamer streamer = new DOMStreamer(contentHandler,
>   lexicalHandler);
> streamer.stream(g.getDOMTreeManager().getRoot());
> </snippet>
> 
> <System.out>
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 20001102//EN'
> 'http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-2000110<svg
> style="fill-opacity:1; color-interpolation:auto; color-rendering:auto;
> text-rendering:auto; stroke:black;  <!--Generated by the Batik Graphics2D
> SVG Generator-->
>   <defs id="genericDefs" />
>   <g>
>     <g>
>       <text x="0" y="20" style="stroke:none;">x
>       </text>
>       <text x="12" y="20" style="stroke:none;">+
>       </text>
>       <text x="27" y="11" style="stroke:none;">y
>       </text>
>       <text x="27" y="10" style="stroke:none;">2
>       </text>
>       <line x1="0" x2="38" y1="20" style="fill:none;" y2="20" />
>       <text x="0" y="38" style="stroke:none;">k
>       </text>
>       <text x="11" y="38" style="stroke:none;">+
>       </text>
>       <text x="26" y="38" style="stroke:none;">1
>       </text>
>     </g>
>   </g>
> </svg>
> </System.out>
> 
> <xml-output>
> <?xml version="1.0" encoding="UTF-8"?>
> <svg fill-opacity="1"
>       color-interpolation="auto"
>       color-rendering="auto"
>       text-rendering="auto"
>       stroke="black"
>       stroke-linecap="square"
>       stroke-miterlimit="10"
>       stroke-opacity="1"
>       shape-rendering="auto"
>       fill="black"
>       stroke-dasharray="none"
>       font-weight="normal"
>       stroke-width="1"
>       font-family="'Lucida Sans'"
>       font-style="normal"
>       stroke-linejoin="miter"
>       font-size="12"
>       image-rendering="auto"
>       stroke-dashoffset="0">
>     <defs id="genericDefs"/>
>       <g/>
> </svg>
> </xml-output>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org

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


Mime
View raw message