SVGTranscoder transcoder = new SVGTranscoder();
// transcoder.addTranscodingHint(SVGTranscoder.KEY_NEWLINE,SVGTranscoder.VALUE_NEWLINE_LF);
transcoder.addTranscodingHint(SVGTranscoder.KEY_DOCTYPE, SVGTranscoder.VALUE_DOCTYPE_CHANGE);
//transcoder.addTranscodingHint(SVGTranscoder.KEY_FORMAT, SVGTranscoder.VALUE_FORMAT_OFF);
OutputStream outputStream = null;
TranscoderInput input = new TranscoderInput(getSVGDocument());
try {
outputStream = new FileOutputStream(filename);
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
}
if (outputStream != null) {
TranscoderOutput output = new TranscoderOutput(new OutputStreamWriter(outputStream));
try {
transcoder.transcode(input, output);
} catch (TranscoderException e) {
e.printStackTrace();
}
try {
outputStream.flush();
outputStream.close();
isDocumentChanged = false;
} catch (IOException e) {
e.printStackTrace();
}
}
Jan
-----Ursprüngliche Nachricht-----
Von: Marcelo Gilman [mailto:[EMAIL PROTECTED]
Gesendet: Dienstag, 29. Juli 2003 22:56
An: [EMAIL PROTECTED]
Betreff: Problems saving and showing a SVGDocumentI 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í.