Package org.apache.batik.svggen

Examples of org.apache.batik.svggen.SVGGraphics2D


              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);
   
              paint(svgGenerator, bds, circuit, width, height);
   
              // 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(stream,
                  "UTF-8");
              svgGenerator.stream(out, useCSS);
            } else if (filter.type == FORMAT_PDF) {
              com.itextpdf.text.Document document = new com.itextpdf.text.Document(new Rectangle(width, height));
              PdfWriter writer = PdfWriter.getInstance(document, stream);
              document.open();
              PdfContentByte cb = writer.getDirectContent();
View Full Code Here


        log.debug("pBean.getWidth(),pBean.getHeight()"
            + pBean.getWidth() + "," + pBean.getHeight());

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

        svgGenerator = WhiteboardMapToSVG.getInstance()
            .convertMapToSVG(svgGenerator, whiteBoardMap);

        // Finally, stream out SVG to the standard output using
        // UTF-8 encoding.
        boolean useCSS = true; // we want to use CSS style attributes

        File uploadTempDir = OmFileHelper.getUploadTempDir();
        log.debug("working_dir: " + uploadTempDir);
        String reqFilePrefix = fileName + "_" + CalendarPatterns.getTimeForStreamId(new Date());
        File svgFile = new File(uploadTempDir, reqFilePrefix + ".svg");
        log.debug("exported svg file: " + svgFile.getCanonicalPath());
        FileWriter out = new FileWriter(svgFile);
        svgGenerator.stream(out, useCSS);
        out.flush();
        out.close();
        File expFile = new File(uploadTempDir, reqFilePrefix + "." + exportType);
        log.debug("exported file: " + expFile.getCanonicalPath());
        if ("svg".equals(exportType)) {
View Full Code Here

             String svgNS = "http://www.w3.org/2000/svg";
             Document document = domImpl.createDocument(svgNS, "svg", null);


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

             draw(svgGenerator);

             Writer out = new BufferedWriter(new FileWriter(selecteddFile));
             //logger.info("Writing output");
             svgGenerator.stream(out, false);
             //logger.info("Done");
         } catch (Exception e) {
             MessageUtils.showMessage("Error encountered creating SVG file: " + e.toString());
         }
     }
View Full Code Here

        DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
        String svgNS = "http://www.w3.org/2000/svg";
        Document document = domImpl.createDocument(svgNS, format, null);

        // Write image data into document
        SVGGraphics2D svgGenerator = new SVGGraphics2D(document);

        choosePaint(target, svgGenerator, paintOffscreen);

        Writer out = null;
        try {
            // Finally, stream out SVG to the standard output using
            // UTF-8 encoding.
            boolean useCSS = true; // we want to use CSS style attributes
            out = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(selectedFile), "UTF-8"));
            svgGenerator.stream(out, useCSS);
        } finally {
            if (out != null) try {
                out.close();
            } catch (IOException e) {
                log.error("Error closing svg file", e);
View Full Code Here

            boolean isFirstLayer = i == 0;

            File path = null;
            if (renderAsSvg(layer)) {
                // render layer as SVG
                final SVGGraphics2D graphics2D = getSvgGraphics(transformer.getMapSize());

                try {
                    Graphics2D clippedGraphics2D = createClippedGraphics(transformer, areaOfInterest, graphics2D);
                    layer.render(clippedGraphics2D, clientHttpRequestFactory, transformer, isFirstLayer);

                    path = new File(printDirectory, mapKey + "_layer_" + i + ".svg");
                    saveSvgFile(graphics2D, path);
                } finally {
                    graphics2D.dispose();
                }
            } else {
                // render layer as raster graphic
                final BufferedImage bufferedImage = new BufferedImage(transformer.getMapSize().width,
                        transformer.getMapSize().height, this.imageType.value);
                Graphics2D graphics2D = createClippedGraphics(transformer, areaOfInterest, bufferedImage.createGraphics());
                try {
                    layer.render(graphics2D, clientHttpRequestFactory, transformer, isFirstLayer);

                    path = new File(printDirectory, mapKey + "_layer_" + i + ".png");
                    ImageIO.write(bufferedImage, "png", path);
                } finally {
                    graphics2D.dispose();
                }
            }
            graphics.add(path.toURI());
            i++;
        }
View Full Code Here

        SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(document);
        ctx.setStyleHandler(new OpacityAdjustingStyleHandler());
        ctx.setComment("Generated by GeoTools2 with Batik SVG Generator");

        SVGGraphics2D g2d = new SVGGraphics2D(ctx, true);
        g2d.setSVGCanvasSize(size);

        return g2d;
    }
View Full Code Here

        // start the rendering
        File path = null;
        if (template.getConfiguration().renderAsSvg(scalebarParams.renderAsSvg)) {
            // render scalebar as SVG
            final SVGGraphics2D graphics2D = CreateMapProcessor.getSvgGraphics(
                    new Dimension(maxWidthInPixelAdjusted, maxHeightInPixelAdjusted));

            try {
                tryLayout(graphics2D, scaleUnit, scale, niceIntervalLengthInWorldUnits, settings, 0);

                path = File.createTempFile("scalebar-graphic-", ".svg", tempFolder);
                CreateMapProcessor.saveSvgFile(graphics2D, path);
            } finally {
                graphics2D.dispose();
            }
        } else {
            // render scalebar as raster graphic
            final BufferedImage bufferedImage = new BufferedImage(maxWidthInPixelAdjusted, maxHeightInPixelAdjusted,
                    BufferedImage.TYPE_4BYTE_ABGR);
            final Graphics2D graphics2D = bufferedImage.createGraphics();

            try {
                tryLayout(graphics2D, scaleUnit, scale, niceIntervalLengthInWorldUnits, settings, 0);

                path = File.createTempFile("scalebar-graphic-", ".tiff", tempFolder);
                ImageIO.write(bufferedImage, "tiff", path);
            } finally {
                graphics2D.dispose();
            }
        }

        return path.toURI();
    }
View Full Code Here

        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

            = 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

     */
    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

TOP

Related Classes of org.apache.batik.svggen.SVGGraphics2D

Copyright © 2018 www.massapicom. 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.