Examples of SVGGraphics2D


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);
      editor.paintComponentNonScreen(g2d);
      FileOutputStream out = new FileOutputStream(file);
      OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
      g2d.stream(writer);
      writer.close();
      out.close();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
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

            = ExtensibleSVGDOMImplementation.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

        SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(domFactory);

        GenericImageHandler ihandler = new CachedImageHandlerBase64Encoder();
        ctx.setGenericImageHandler(ihandler);

        return new SVGGraphics2D(ctx, false);
    }
View Full Code Here

Examples of org.apache.batik.svggen.SVGGraphics2D

    public JPainterCompare(Painter painter){
        // First, create the AWT reference.
        JPainterComponent ref = new JPainterComponent(painter);

        // Now, generate the SVG from this Painter
        SVGGraphics2D g2d = buildSVGGraphics2D();

        g2d.setSVGCanvasSize(CANVAS_SIZE);

        //
        // Generate SVG content
        //
        File tmpFile = null;
        try{
            tmpFile = File.createTempFile(CONFIG_TMP_FILE_PREFIX,
                                          ".svg");
           
            OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(tmpFile), "UTF-8");

            painter.paint(g2d);
            g2d.stream(osw);
            osw.flush();
        }catch(Exception e){
            e.printStackTrace();
            throw new IllegalArgumentException
                (Messages.formatMessage(ERROR_COULD_NOT_TRANSCODE_TO_SVG,
View Full Code Here

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

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

Examples of org.apache.batik.svggen.SVGGraphics2D

        // Build a painter for the RecordStore
        WMFPainter painter = new WMFPainter(currentStore, xOffset, yOffset, conv);

        // Use SVGGraphics2D to generate SVG content
        Document doc = this.createDocument(output);
        svgGenerator = new SVGGraphics2D(doc);

        /** set precision
         ** otherwise Ellipses aren't working (for example) (because of Decimal format
         * modifications ins SVGGenerator Context
         */
 
View Full Code Here

Examples of org.apache.batik.svggen.SVGGraphics2D

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

        SVGGraphics2D g = new SVGGraphics2D(svgdocument);

        g.setSVGCanvasSize(
          new Dimension(base.getWidth(), base.getHeight()));

        //g.setColor(Color.white);
        //g.fillRect(0, 0, base.getWidth(), base.getHeight());
        g.setColor(Color.black);

        base.paint(g);

        //if (antialiasing)
        //element.setAttribute("text-rendering", "optimizeLegibility");
        //else
        //element.setAttribute("text-rendering", "geometricPrecision");

        // this should be done in a better way
        Element root = g.getRoot();
        svgdocument = impl.createDocument(svgNS, "svg", null);
        Node node = svgdocument.importNode(root, true);
        ((org.apache.batik.dom.svg.SVGOMDocument) svgdocument).
        getRootElement().appendChild(node);
View Full Code Here

Examples of org.apache.batik.svggen.SVGGraphics2D

        SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(this.document);
        ctx.setComment("Generated by " + userAgent.getProducer() + " with Batik SVG Generator");
        ctx.setEmbeddedFontsOn(true);
       
        // Create an instance of the SVG Generator
        this.svgGenerator = new SVGGraphics2D(ctx, true);
        Rectangle2D viewArea = pageViewport.getViewArea();
        Dimension dim = new Dimension();
        dim.setSize(viewArea.getWidth() / 1000, viewArea.getHeight() / 1000);
        this.svgGenerator.setSVGCanvasSize(dim);
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.