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

Reply via email to