Search in sources :

Example 1 with JSVGCanvas

use of org.apache.batik.swing.JSVGCanvas 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

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