Hello,
I am trying to use the DOM output generated by the SVGGraphics2D for
processing thru a pipeline. The problem that I am facing is that the
document which was used to create the svggenerator is not getting updated. I
have attached the code for your reference, can you please give me
suggestions as to a better method of doing what I need.
Thanks,
Dinkar
Output of the program:
<?xml version="1.0" encoding="UTF-8"?>
<svg />
The code:
import java.awt.Rectangle;
import java.awt.Graphics2D;
import java.awt.Color;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.IOException;
import org.apache.batik.svggen.SVGGraphics2D;
import org.apache.batik.dom.GenericDOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.DOMImplementation;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.Namespace;
import org.jdom.input.DOMBuilder;
import org.jdom.output.XMLOutputter;
import org.jdom.output.SAXOutputter;
import org.xml.sax.ContentHandler;
public class SVGTest {
public void paint(Graphics2D g2d) {
g2d.setPaint(Color.red);
g2d.fill(new Rectangle(10, 10, 100, 100));
}
public static void main(String [] args) throws IOException {
// Get a DOMImplementation
DOMImplementation domImpl =
GenericDOMImplementation.getDOMImplementation();
// Create an instance of org.w3c.dom.Document
org.w3c.dom.Document document = domImpl.createDocument(null, "svg",
null);
// Create an instance of the SVG Generator
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
// Ask the test to render into the SVG Graphics2D implementation
SVGTest test = new SVGTest();
test.paint(svgGenerator);
// Finally, stream out SVG to the standard output using UTF-8
// character to byte encoding
// boolean useCSS = true; // we want to use CSS style attribute
//Writer out = new OutputStreamWriter(System.out, "UTF-8");
//svgGenerator.stream(out, useCSS);
DOMBuilder builder = new DOMBuilder();
XMLOutputter outputter = new XMLOutputter();
org.jdom.Document jdomDocument = builder.build(document);
outputter.output(jdomDocument, System.out);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]