Examples of SVGGraphics2D


Examples of org.apache.batik.svggen.SVGGraphics2D

     */
    public TestReport runImpl() throws Exception {
        DefaultTestReport report
            = new DefaultTestReport(this);

        SVGGraphics2D g2d = buildSVGGraphics2D();
        g2d.setSVGCanvasSize(CANVAS_SIZE);

        //
        // Generate SVG content
        //
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        OutputStreamWriter osw = new OutputStreamWriter(bos, "UTF-8");
        try{
            painter.paint(g2d);
            configureSVGGraphics2D(g2d);
            g2d.stream(osw);
            osw.flush();
            bos.flush();
            bos.close();
        }catch(Exception e){
            StringWriter trace = new StringWriter();
View Full Code Here

Examples of org.apache.batik.svggen.SVGGraphics2D

        GraphicContextDefaults defaults
            = new GraphicContextDefaults();
        defaults.font = new Font("Arial", Font.PLAIN, 12);
        ctx.setGraphicContextDefaults(defaults);
        ctx.setPrecision(12);
        return new SVGGraphics2D(ctx, false);
    }
View Full Code Here

Examples of org.apache.batik.svggen.SVGGraphics2D

            = SVGDOMImplementation.getDOMImplementation();

        Document doc = domImpl.createDocument(SVG_NAMESPACE_URI,
                                              SVG_SVG_TAG, null);

        SVGGraphics2D svgGenerator = new SVGGraphics2D(doc);

        painter.paint(svgGenerator);

        //
        // Set the size and viewBox on the output document
        //
        int vpX = currentStore.getVpX();
        int vpY = currentStore.getVpY();
        int vpW = currentStore.getVpW();
        int vpH = currentStore.getVpH();
        svgGenerator.setSVGCanvasSize(new Dimension(vpW, vpH));

        Element svgRoot = svgGenerator.getRoot();
        svgRoot.setAttributeNS(null, SVG_VIEW_BOX_ATTRIBUTE,
                               "" + vpX + " " + vpY + " " +
                               vpW + " " + vpH );

        //
View Full Code Here

Examples of org.apache.batik.svggen.SVGGraphics2D

    //---Create an instance of org.w3c.dom.Document
    Document document = domImpl.createDocument( null, "svg", null );

    //---Create an instance of the SVG Generator
    SVGGraphics2D svgGenerator = new SVGGraphics2D( document );

    chart.setGraphics2D( svgGenerator );
    chart.render();

    Writer writer = new OutputStreamWriter( outputStream, "UTF-8" );
    svgGenerator.stream( writer, false );

    writer.flush();
    writer.close();
  }
View Full Code Here

Examples of org.apache.batik.svggen.SVGGraphics2D

      DOMImplementation domImpl
      = GenericDOMImplementation.getDOMImplementation();
      // Create an instance of org.w3c.dom.Document
      Document document = domImpl.createDocument(null, "svg", null);
      // Create an instance of the SVG Generator
      SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
      // set the precision to avoid a null pointer exception in Batik 1.5
      svgGenerator.getGeneratorContext().setPrecision(6);
      // Ask the chart to render into the SVG Graphics2D implementation
      chart.draw(svgGenerator, new Rectangle2D.Double(0, 0, width, height), null);
      // Finally, stream out SVG to a file using UTF-8 character to
      // byte encoding
      boolean useCSS = true;
      Writer out = new OutputStreamWriter(new FileOutputStream(filename), "UTF-8");
      svgGenerator.stream(out, useCSS);
      } catch(IOException ex) {
        throw new WorkBenchError(ex);
      }
    }
View Full Code Here

Examples of org.apache.batik.svggen.SVGGraphics2D

        // Create an instance of org.w3c.dom.Document.
        String svgNS = "http://www.w3.org/2000/svg";
        Document document = domImpl.createDocument(svgNS, "svg", null);

        // Create an instance of the SVG Generator.
        SVGGraphics2D svgGenerator = new SVGGraphics2D(document);

        // Ask the test to render into the SVG Graphics2D implementation.
        //TestSVGGen test = new TestSVGGen();
        switchDesigner.paint(svgGenerator);

        // Finally, stream out SVG to the standard output using
        // UTF-8 encoding.
        boolean useCSS = true; // we want to use CSS style attributes
        Writer out = new OutputStreamWriter(new FileOutputStream("c:\\uengine\\test.svg"), "UTF-8");
        svgGenerator.stream(out, useCSS);
       
        System.exit(0);
    }
View Full Code Here

Examples of org.apache.batik.svggen.SVGGraphics2D

        DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
        String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
        SVGDocument document = (SVGDocument) impl.createDocument(svgNS, "svg", null);

        // Create an instance of the SVG Generator.
        SVGGraphics2D svgGenerator = new SVGGraphics2D(document);

        try{
         
          disableDoubleBuffering(componentToExport);

          componentToExport.paint(svgGenerator);
         
          enableDoubleBuffering(componentToExport);
//          SwingSVGPrettyPrint.print(componentToExport, svgGenerator);
 
          // Populate the document root with the generated SVG content.
//          Element root = document.getDocumentElement();
//          svgGenerator.getRoot(root);

         
//      JSVGCanvas canvas = new JSVGCanvas();
//      canvas.setPreferredSize(new Dimension(800,600));
//          JFrame f = new JFrame();
//          f.getContentPane().setLayout(new BorderLayout());
//          f.getContentPane().add("Center", canvas);
//          canvas.setSVGDocument(document);
//          f.pack();
//          f.setVisible(true);

          // Finally, stream out SVG to the standard output using
          // UTF-8 encoding.
          boolean useCSS = false; // we want to use CSS style attributes
          Writer out = new OutputStreamWriter(fao, "UTF-8");
          svgGenerator.stream(out, useCSS);
          out.flush();
          out.close();

      }catch(Exception e){
        throw e;
      }finally{
        svgGenerator.dispose();
        svgGenerator = null;
      }
       
    }
View Full Code Here

Examples of org.apache.batik.svggen.SVGGraphics2D

      Document doc =
        domImpl.createDocument("http://www.w3.org/2000/svg", "svg", null);
      SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(doc);
      ctx.setComment("Generated by TinyUML with Batik SVG Generator");
      ctx.setEmbeddedFontsOn(true);
      SVGGraphics2D g2d = new SVGGraphics2D(ctx, true);
      g2d.setSVGCanvasSize(editor.getTotalCanvasSize());
      editor.paintComponentNonScreen(g2d);

      // write the file
      File theFile = getFileWithExtension(file);
      if (canWrite(editor, theFile)) {
        out = new FileOutputStream(theFile);
        writer = new OutputStreamWriter(out, "UTF-8");
        g2d.stream(writer);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    } finally  {
      if (writer != null) { writer.close(); }
View Full Code Here

Examples of org.apache.batik.svggen.SVGGraphics2D

      Document doc =
        domImpl.createDocument("http://www.w3.org/2000/svg", "svg", null);
      SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(doc);
      ctx.setComment("Generated by TinyUML with Batik SVG Generator");
      ctx.setEmbeddedFontsOn(true);
      SVGGraphics2D g2d = new SVGGraphics2D(ctx, true);
      g2d.setSVGCanvasSize(editor.getTotalCanvasSize());
      editor.paintComponentNonScreen(g2d);

      // write the file
      File theFile = getFileWithExtension(file);
      if (canWrite(editor, theFile)) {
        out = new FileOutputStream(theFile);
        writer = new OutputStreamWriter(out, "UTF-8");
        g2d.stream(writer);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    } finally  {
      if (writer != null) { writer.close(); }
View Full Code Here

Examples of org.apache.batik.svggen.SVGGraphics2D

                SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(document);

                //ctx.setEmbeddedFontsOn(true);
                // Create an instance of the SVG Generator
                g2d = new SVGGraphics2D(ctx, false);

                Rectangle rect = GlobalFunction.checkMinimumViewport(view);
                Dimension size = new Dimension(rect.width + 10, rect.height + 10);

                g2d.translate(-rect.x + 5, -rect.y + 5);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.