Package org.apache.batik.svggen

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


                    + "MathML document, but was: " + rootElementName);
        }

        final MathBase mathBase = new MathBase(MathBase.getDefaultParameters());
        new DOMBuilder(dom, mathBase);
        final SVGGraphics2D svgGenerator = this.createSVGGenerator(mathBase);
        mathBase.paint(svgGenerator);

        /* The following line is what /should/ work. However, there appears to
         * be some disconnect in Batik between the Document and the root
         * Element. The root Element recognizes the Document as its Document,
         * but the Document does not see the root Element as its root Element
         * ... */
//        final Document svgDocument = svgGenerator.getDOMFactory();

        final Element svgRoot = svgGenerator.getRoot();

        /* The variable svgDocument below is the same object as the one
         * commented out above ... */
        final Document svgDocument = svgRoot.getOwnerDocument();
        if (svgDocument == null) {
View Full Code Here

            throws GraphicException {
        final SVGDocument svgDocument = this.makeSvgDocument();
        final SVGGeneratorContext svgContext = SVGGeneratorContext
                .createDefault(svgDocument);
        svgContext.setComment("Converted from MathML using JEuclid");
        final SVGGraphics2D svgGenerator = new SVGGraphics2D(svgContext, true);

        final Dimension size = new Dimension((int) Math.ceil(mathBase
                .getWidth(svgGenerator)), (int) Math.ceil(mathBase
                .getHeight(svgGenerator)));
        svgGenerator.setSVGCanvasSize(size);
        return svgGenerator;
    }
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

    protected SVGGraphics2D buildSVGGraphics2D() {
        // CSSDocumentHandler.setParserClassName(CSS_PARSER_CLASS_NAME);
        DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
        String namespaceURI = SVGDOMImplementation.SVG_NAMESPACE_URI;
        Document domFactory = impl.createDocument(namespaceURI, SVG_SVG_TAG, null);
        return new SVGGraphics2D(domFactory);
    }
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

        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

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

      DOMImplementation domImpl = SVGDOMImplementation.getDOMImplementation();
      doc = domImpl.createDocument(SVGConstants.SVG_NAMESPACE_URI, SVGConstants.SVG_SVG_TAG, null);
    } else doc = output.getDocument();

    // Render GVT tree into document.
    SVGGraphics2D svgGenerator = new SVGGraphics2D(
        SVGGeneratorContext.createDefault(doc),
        ((Boolean) hints.get(KEY_TEXT_AS_SHAPES)).booleanValue());
    // Get size of canvas to render into.
    Dimension d = new Dimension();
    d.setSize(width, height);
    svgGenerator.setSVGCanvasSize(d);

    // Paint the GVT tree into the SVG generator.
    this.root.paint(svgGenerator);

    // Output the resulting document to the output transcoder.
    try {
      OutputStream os = output.getOutputStream();
      if (os != null) {
        svgGenerator.stream(svgGenerator.getRoot(), new OutputStreamWriter(os), false, false);
        return;
      }

      // Writer
      Writer wr = output.getWriter();
      if (wr != null) {
        svgGenerator.stream(svgGenerator.getRoot(), wr, false, false);
        return;
      }

      // URI
      String outputuri = output.getURI();
      if ( outputuri != null ){
        try{
          URL url = new URL(outputuri);
          URLConnection urlCnx = url.openConnection();
          os = urlCnx.getOutputStream();
          svgGenerator.stream(svgGenerator.getRoot(), new OutputStreamWriter(os), false, false);
          return;
        } catch (MalformedURLException e){
          handler.fatalError(new TranscoderException(e));
        } catch (IOException e){
          handler.fatalError(new TranscoderException(e));
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.