You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Marcelo Gilman <ma...@yahoo.com.ar> on 2003/07/29 22:55:52 UTC

Problems saving and showing a SVGDocument

I am experimenting problems when trying to save and then show an SVGDocument. The code I am using is included below. If I do not save it, then the graphic is shown and if I save it (as in the included code) the graphic is not shown (a white frame appears). 

Any suggestions?

Thanks, Marcelo.

// Create SVG doc
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
SVGDocument doc = (SVGDocument) impl.createDocument(svgNS, "svg", null);
SVGGraphics2D g = new SVGGraphics2D(doc);
 
// draw something
g.setPaint(Color.YELLOW);
g.fill(new Ellipse2D.Double(10, 10, 100, 20));
 
// Save
OutputStream file = new FileOutputStream(afileName);
Writer out = new OutputStreamWriter(file, "UTF-8");
svgGenerator.stream(out, false);
file.close();
 
// show
g.getRoot(doc.getDocumentElement());
JSVGCanvas canvas = new JSVGCanvas();
JFrame f = new JFrame();
f.getContentPane().add(canvas);
canvas.setDocument(doc);
f.pack();
f.setVisible(true);




---------------------------------
Internet GRATIS es Yahoo! Conexión.
Usuario: yahoo; contraseña: yahoo
Desde Buenos Aires: 4004-1010
Más ciudades: clic aquí.

Re: Problems saving and showing a SVGDocument

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Marcelo,

Marcelo Gilman wrote:
> 
> 
> I am experimenting problems when trying to save and then show an 
> SVGDocument. The code I am using is included below. If I do not save it, 
> then the graphic is shown and if I save it (as in the included code) the 
> graphic is not shown (a white frame appears).

    I think that the stream is changing what getRoot is returning.
I would suggest calling getRoot() and calling XmlWriter
yourself directly with the returned element (you might
take a look at what stream is doing as it does do some
nice stuff for you but most of it's functionality is in
XmlWriter).




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