Search in sources :

Example 1 with SAXSVGDocumentFactory

use of org.apache.batik.dom.svg.SAXSVGDocumentFactory in project charts by vaadin.

the class PdfExportDemo method createSVGDocument.

private SVGDocument createSVGDocument(String svg, UserAgent agent) throws IOException {
    SVGDocumentFactory documentFactory = new SAXSVGDocumentFactory(agent.getXMLParserClassName(), true);
    SVGDocument svgdoc = documentFactory.createSVGDocument(null, new StringReader(svg));
    return svgdoc;
}
Also used : SAXSVGDocumentFactory(org.apache.batik.dom.svg.SAXSVGDocumentFactory) SVGDocumentFactory(org.apache.batik.dom.svg.SVGDocumentFactory) StringReader(java.io.StringReader) SAXSVGDocumentFactory(org.apache.batik.dom.svg.SAXSVGDocumentFactory) SVGDocument(org.w3c.dom.svg.SVGDocument)

Example 2 with SAXSVGDocumentFactory

use of org.apache.batik.dom.svg.SAXSVGDocumentFactory in project charts by vaadin.

the class SwingDemo method display.

public static void display(Configuration conf) {
    String svg = SVGGenerator.getInstance().generate(conf);
    String parser = XMLResourceDescriptor.getXMLParserClassName();
    SVGDocumentFactory documentFactory = new SAXSVGDocumentFactory(parser, true);
    SVGDocument svgdoc;
    try {
        svgdoc = documentFactory.createSVGDocument(null, new StringReader(svg));
        JSVGCanvas jsvgCanvas = new JSVGCanvas();
        jsvgCanvas.setSVGDocument(svgdoc);
        JFrame f = new JFrame();
        f.setSize(600, 400);
        f.getContentPane().add(jsvgCanvas);
        f.pack();
        f.setVisible(true);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : JFrame(javax.swing.JFrame) SAXSVGDocumentFactory(org.apache.batik.dom.svg.SAXSVGDocumentFactory) SVGDocumentFactory(org.apache.batik.dom.svg.SVGDocumentFactory) StringReader(java.io.StringReader) SAXSVGDocumentFactory(org.apache.batik.dom.svg.SAXSVGDocumentFactory) JSVGCanvas(org.apache.batik.swing.JSVGCanvas) IOException(java.io.IOException) SVGDocument(org.w3c.dom.svg.SVGDocument)

Aggregations

StringReader (java.io.StringReader)2 SAXSVGDocumentFactory (org.apache.batik.dom.svg.SAXSVGDocumentFactory)2 SVGDocumentFactory (org.apache.batik.dom.svg.SVGDocumentFactory)2 SVGDocument (org.w3c.dom.svg.SVGDocument)2 IOException (java.io.IOException)1 JFrame (javax.swing.JFrame)1 JSVGCanvas (org.apache.batik.swing.JSVGCanvas)1