Package org.apache.batik.svggen

Examples of org.apache.batik.svggen.SVGGraphics2D


          svgRoot.setAttributeNS(null, "width", "2400");
          svgRoot.setAttributeNS(null, "height", "1600");
         

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

//          SVGGraphics2D svgGenerator8 = new SVGGraphics2D(svgGenerator);
//          //SVGGraphics2D svgGenerator2 = new SVGGraphics2D(document);
//         
//          //NOTE: Font.ITALIC+Font.BOLD = Font AND Bold !
//          exportToImageTest.paintTextByWidthHeight(svgGenerator8, 500, 300, 100, 200, "Process", Font.BOLD+Font.ITALIC, 28,
//              new Color(255,0,0));
//         
//          SVGGraphics2D svgGenerator11 = new SVGGraphics2D(svgGenerator);
//         
//          exportToImageTest.paintTextByWidthHeight(svgGenerator11, 100, 300, 100, 200, "Process", Font.BOLD+Font.ITALIC, 111,
//              new Color(255,0,0));
//         
//          SVGGraphics2D svgGenerator9 = new SVGGraphics2D(svgGenerator);
        //NOTE: Font.ITALIC+Font.BOLD = Font AND Bold !
//          exportToImageTest._paintTextByWidthHeight(svgGenerator9, 500, 300, 100, 200, "Hans", Font.BOLD, 28,
//              new Color(255,0,0));
     
     
          // 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(System.out, "UTF-8");
         
          //OutputStream out = httpServletResponse.getOutputStream();
      //httpServletResponse.setContentType("APPLICATION/OCTET-STREAM");
      //httpServletResponse.setHeader("Content-Disposition","attachment; filename=\"" + requestedFile + "\"");
          Writer out = new OutputStreamWriter(System.out, "UTF-8");

          //StringWriter out = new StringWriter();
         
          svgGenerator.stream(out, useCSS);
    } catch (Exception er) {
      log.error("ERROR ", er);
      System.out.println("Error exporting: " + er);
      er.printStackTrace();
    }
View Full Code Here


            Double y = Double.valueOf(graphObject.get(graphObject.size()-4).toString()).doubleValue();
           
            //log.debug("x,y,width,height: "+x+","+y+","+width+","+height);
           
            //Draw a Painting
              SVGGraphics2D svgGenerator_temp = new SVGGraphics2D(svgGenerator);
              //SVGGraphics2D svgGenerator2 = new SVGGraphics2D(document);
              
              log.debug("pointsList: "+pointsList);
              this.drawPointsObject(svgGenerator_temp, pointsList, new Color(col), lineWidth, x, y, alpha);
             
          } else if (graphType.equals("rectangle")) {
           
            /*actionObject[0] = 'rectangle';
            actionObject[1] = stroke;
            actionObject[2] = line;
            actionObject[3] = fill;
            actionObject[4] = strokeDis;
            actionObject[5] = fillDis;
            actionObject[6] = this.currentrectangleOpacity;*/
           
            Integer lineWidth = Integer.valueOf(graphObject.get(2).toString()).intValue();
           
            Integer stroke = Integer.valueOf(graphObject.get(1).toString()).intValue();
            Integer strokeDis= Integer.valueOf(graphObject.get(4).toString()).intValue();
           
            Color strokeColor = null;
            if (strokeDis != -1) {
              strokeColor = new Color(stroke);
            }
           
            Integer fill = Integer.valueOf(graphObject.get(3).toString()).intValue();
            Integer fillDis= Integer.valueOf(graphObject.get(5).toString()).intValue();
           
            Color fillColor = null;
            if (fillDis != -1) {
              fillColor = new Color(fill);
            }
           
            Float alpha = Float.valueOf(graphObject.get(6).toString()).floatValue();
           
            Double x = Double.valueOf(graphObject.get(graphObject.size()-5).toString()).doubleValue();
            Double y = Double.valueOf(graphObject.get(graphObject.size()-4).toString()).doubleValue();
            Double width = Double.valueOf(graphObject.get(graphObject.size()-3).toString()).doubleValue();
            Double height = Double.valueOf(graphObject.get(graphObject.size()-2).toString()).doubleValue();
         
            SVGGraphics2D svgGenerator_temp = new SVGGraphics2D(svgGenerator);
            this.paintRect2D(svgGenerator_temp, x, y, width, height, strokeColor, lineWidth, fillColor, alpha);
           
          } else if (graphType.equals("ellipse")) {
           
            Integer lineWidth = Integer.valueOf(graphObject.get(2).toString()).intValue();
           
            Integer stroke = Integer.valueOf(graphObject.get(1).toString()).intValue();
            Integer strokeDis= Integer.valueOf(graphObject.get(4).toString()).intValue();
           
            Color strokeColor = null;
            if (strokeDis != -1) {
              strokeColor = new Color(stroke);
            }
           
            Integer fill = Integer.valueOf(graphObject.get(3).toString()).intValue();
            Integer fillDis= Integer.valueOf(graphObject.get(5).toString()).intValue();
           
            Color fillColor = null;
            if (fillDis != -1) {
              fillColor = new Color(fill);
            }
           
            Float alpha = Float.valueOf(graphObject.get(6).toString()).floatValue();
           
            Double x = Double.valueOf(graphObject.get(graphObject.size()-5).toString()).doubleValue();
            Double y = Double.valueOf(graphObject.get(graphObject.size()-4).toString()).doubleValue();
            Double width = Double.valueOf(graphObject.get(graphObject.size()-3).toString()).doubleValue();
            Double height = Double.valueOf(graphObject.get(graphObject.size()-2).toString()).doubleValue();
         
            SVGGraphics2D svgGenerator_temp = new SVGGraphics2D(svgGenerator);
            this.paintEllipse2D(svgGenerator_temp, x, y, width, height, strokeColor, lineWidth, fillColor, alpha);
           
          } else if (graphType.equals("letter")) {
           
            String text = graphObject.get(1).toString();
            Color fontColor = new Color (Integer.valueOf(graphObject.get(2).toString()).intValue());
            Integer fontSize = Integer.valueOf(graphObject.get(3).toString()).intValue();
           
            String fontStyle = graphObject.get(4).toString();
            Integer style = null;
            if (fontStyle.equals("plain")) {
              style = Font.PLAIN;
            } else if (fontStyle.equals("bold")) {
              style = Font.BOLD;
            } else if (fontStyle.equals("italic")) {
              style = Font.ITALIC;
            } else if (fontStyle.equals("bolditalic")) {
              style = Font.ITALIC+Font.BOLD;
            }
           
            log.debug("fontStyle,style "+style+" fs: "+fontStyle);
           
            Double x = Double.valueOf(graphObject.get(graphObject.size()-5).toString()).doubleValue();
            Double y = Double.valueOf(graphObject.get(graphObject.size()-4).toString()).doubleValue();
            Double width = Double.valueOf(graphObject.get(graphObject.size()-3).toString()).doubleValue();
            Double height = Double.valueOf(graphObject.get(graphObject.size()-2).toString()).doubleValue();
           
            SVGGraphics2D svgGenerator_temp = new SVGGraphics2D(svgGenerator);
            this.paintTextByWidthHeight(svgGenerator_temp, (int) Math.round(x), (int) Math.round(y), (int) Math.round(width),
                  (int) Math.round(height), text, style, fontSize, fontColor);
           
          } else if (graphType.equals("drawarrow")) {
           
            Integer thickness = Integer.valueOf(graphObject.get(2).toString()).intValue();
           
            Integer stroke = Integer.valueOf(graphObject.get(1).toString()).intValue();
            Integer strokeDis= Integer.valueOf(graphObject.get(4).toString()).intValue();
           
            Color strokeColor = null;
            if (strokeDis != -1) {
              strokeColor = new Color(stroke);
            }
           
            Integer fill = Integer.valueOf(graphObject.get(3).toString()).intValue();
            Integer fillDis= Integer.valueOf(graphObject.get(5).toString()).intValue();
           
            Color fillColor = null;
            if (fillDis != -1) {
              fillColor = new Color(fill);
            }
           
            Float alpha = Float.valueOf(graphObject.get(6).toString()).floatValue();
           
            Double x = Double.valueOf(graphObject.get(graphObject.size()-5).toString()).doubleValue();
            Double y = Double.valueOf(graphObject.get(graphObject.size()-4).toString()).doubleValue();
            //Double width = Double.valueOf(graphObject.get(graphObject.size()-3).toString()).doubleValue();
            //Double height = Double.valueOf(graphObject.get(graphObject.size()-2).toString()).doubleValue();
           
            Double x1 = Double.valueOf(graphObject.get(7).toString()).doubleValue();
            Double y1 = Double.valueOf(graphObject.get(8).toString()).doubleValue();
            Double x2 = Double.valueOf(graphObject.get(9).toString()).doubleValue();
            Double y2 = Double.valueOf(graphObject.get(10).toString()).doubleValue();
           
            GeomPoint start = new GeomPoint();
              start.setLocation(x+x1,y+y1);
              GeomPoint end = new GeomPoint();
              end.setLocation(x+x2,y+y2);
             
              SVGGraphics2D svgGenerator_temp = new SVGGraphics2D(svgGenerator);
              this.drawArrow(svgGenerator_temp, start, end, thickness, alpha, strokeColor,fillColor);
          } else if (graphType.equals("image")) {
           
            //log.debug("graphObject image "+graphObject);
            //log.debug("",graphObject);
           
            String room = graphObject.get(6).toString();
            String parentPath = graphObject.get(5).toString();
            String fileItemName = graphObject.get(3).toString();
           
            File imageFile = new File(OmFileHelper.getUploadDir(), room);
           
            if (parentPath.length() > 1) {
              imageFile = new File(imageFile, parentPath);
            }
           
            //log.debug("fileItemName: "+fileItemName);
           
            File myFile = new File(imageFile, fileItemName);
           
            if (myFile.exists() && myFile.canRead()) {
             
              Image myImage = ImageIO.read(myFile);
             
              int x = (int) Math.round(Double.valueOf(graphObject.get(graphObject.size()-5).toString()).doubleValue());
              int y = (int) Math.round(Double.valueOf(graphObject.get(graphObject.size()-4).toString()).doubleValue());
              int width = (int) Math.round(Double.valueOf(graphObject.get(graphObject.size()-3).toString()).doubleValue());
              int height = (int) Math.round(Double.valueOf(graphObject.get(graphObject.size()-2).toString()).doubleValue());
             
              SVGGraphics2D svgGenerator_temp = new SVGGraphics2D(svgGenerator);
              svgGenerator_temp.drawImage(myImage, x, y, width, height, null);
             
            } else {
              log.error("tried to inculde a non existing File into SVG/Image Export Path: " + myFile);
            }
           
          } else if(graphType.equals("line") || graphType.equals("uline")) {
           
//            actionObject[0] = 'line';
//                actionObject[1] = stroke;
//                actionObject[2] = line;
//                actionObject[3] = opacity;
//                actionObject[4] = x1 
//                actionObject[5] = y1; 
//                actionObject[6] = x2;   
//                actionObject[7] = y2;   
//                actionObject[8] = this.counter;
//                actionObject[9] = x;
//                actionObject[10] = y;
//                actionObject[11] = width;
//                actionObject[12] = height; 
//                actionObject[13] = newName;
           
          Integer lineWidth = Integer.valueOf(graphObject.get(2).toString()).intValue();
           
            Integer stroke = Integer.valueOf(graphObject.get(1).toString()).intValue();
            Color strokeColor = new Color(stroke);
           
            Float alpha = Float.valueOf(graphObject.get(3).toString()).floatValue();
           
            Double x = Double.valueOf(graphObject.get(graphObject.size()-5).toString()).doubleValue();
            Double y = Double.valueOf(graphObject.get(graphObject.size()-4).toString()).doubleValue();
            //Double width = Double.valueOf(graphObject.get(graphObject.size()-3).toString()).doubleValue();
            //Double height = Double.valueOf(graphObject.get(graphObject.size()-2).toString()).doubleValue();

            Double x1 = Double.valueOf(graphObject.get(4).toString()).doubleValue();
            Double y1 = Double.valueOf(graphObject.get(5).toString()).doubleValue();
            Double x2 = Double.valueOf(graphObject.get(6).toString()).doubleValue();
            Double y2 = Double.valueOf(graphObject.get(7).toString()).doubleValue();
           
            SVGGraphics2D svgGenerator_temp = new SVGGraphics2D(svgGenerator);
            this.drawLine(svgGenerator_temp, x1, y1, x2, y2, strokeColor, lineWidth, x, y, alpha);
           
          } else {
            log.error("tried to include a non supported Graph-Object graphType: "+graphType);
          }
View Full Code Here

      //int x, int y, int width, int height
    n.setBounds( x, y , width, height );
    n.setOpaque( false );
   
    //Text
    SVGGraphics2D svgGenerator2 = (SVGGraphics2D) g2d.create(x, y, width, height);

    //svgGenerator2.create(x, y, width, height);
    //svgGenerator2.draw(.dra)
    n.paint( svgGenerator2 );
   
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

            Double y = Double.valueOf(graphObject.get(graphObject.size()-4).toString()).doubleValue();
           
            //log.debug("x,y,width,height: "+x+","+y+","+width+","+height);
           
            //Draw a Painting
              SVGGraphics2D svgGenerator_temp = new SVGGraphics2D(svgGenerator);
              //SVGGraphics2D svgGenerator2 = new SVGGraphics2D(document);
              
              log.debug("pointsList: "+pointsList);
              this.drawPointsObject(svgGenerator_temp, pointsList, new Color(col), lineWidth, x, y, alpha);
             
          } else if (graphType.equals("rectangle")) {
           
            /*actionObject[0] = 'rectangle';
            actionObject[1] = stroke;
            actionObject[2] = line;
            actionObject[3] = fill;
            actionObject[4] = strokeDis;
            actionObject[5] = fillDis;
            actionObject[6] = this.currentrectangleOpacity;*/
           
            Integer lineWidth = Integer.valueOf(graphObject.get(2).toString()).intValue();
           
            Integer stroke = Integer.valueOf(graphObject.get(1).toString()).intValue();
            Integer strokeDis= Integer.valueOf(graphObject.get(4).toString()).intValue();
           
            Color strokeColor = null;
            if (strokeDis != -1) {
              strokeColor = new Color(stroke);
            }
           
            Integer fill = Integer.valueOf(graphObject.get(3).toString()).intValue();
            Integer fillDis= Integer.valueOf(graphObject.get(5).toString()).intValue();
           
            Color fillColor = null;
            if (fillDis != -1) {
              fillColor = new Color(fill);
            }
           
            Float alpha = Float.valueOf(graphObject.get(6).toString()).floatValue();
           
            Double x = Double.valueOf(graphObject.get(graphObject.size()-5).toString()).doubleValue();
            Double y = Double.valueOf(graphObject.get(graphObject.size()-4).toString()).doubleValue();
            Double width = Double.valueOf(graphObject.get(graphObject.size()-3).toString()).doubleValue();
            Double height = Double.valueOf(graphObject.get(graphObject.size()-2).toString()).doubleValue();
         
            SVGGraphics2D svgGenerator_temp = new SVGGraphics2D(svgGenerator);
            this.paintRect2D(svgGenerator_temp, x, y, width, height, strokeColor, lineWidth, fillColor, alpha);
           
          } else if (graphType.equals("ellipse")) {
           
            Integer lineWidth = Integer.valueOf(graphObject.get(2).toString()).intValue();
           
            Integer stroke = Integer.valueOf(graphObject.get(1).toString()).intValue();
            Integer strokeDis= Integer.valueOf(graphObject.get(4).toString()).intValue();
           
            Color strokeColor = null;
            if (strokeDis != -1) {
              strokeColor = new Color(stroke);
            }
           
            Integer fill = Integer.valueOf(graphObject.get(3).toString()).intValue();
            Integer fillDis= Integer.valueOf(graphObject.get(5).toString()).intValue();
           
            Color fillColor = null;
            if (fillDis != -1) {
              fillColor = new Color(fill);
            }
           
            Float alpha = Float.valueOf(graphObject.get(6).toString()).floatValue();
           
            Double x = Double.valueOf(graphObject.get(graphObject.size()-5).toString()).doubleValue();
            Double y = Double.valueOf(graphObject.get(graphObject.size()-4).toString()).doubleValue();
            Double width = Double.valueOf(graphObject.get(graphObject.size()-3).toString()).doubleValue();
            Double height = Double.valueOf(graphObject.get(graphObject.size()-2).toString()).doubleValue();
         
            SVGGraphics2D svgGenerator_temp = new SVGGraphics2D(svgGenerator);
            this.paintEllipse2D(svgGenerator_temp, x, y, width, height, strokeColor, lineWidth, fillColor, alpha);
           
          } else if (graphType.equals("letter")) {
           
            String text = graphObject.get(1).toString();
            Color fontColor = new Color (Integer.valueOf(graphObject.get(2).toString()).intValue());
            Integer fontSize = Integer.valueOf(graphObject.get(3).toString()).intValue();
           
            String fontStyle = graphObject.get(4).toString();
            Integer style = null;
            if (fontStyle.equals("plain")) {
              style = Font.PLAIN;
            } else if (fontStyle.equals("bold")) {
              style = Font.BOLD;
            } else if (fontStyle.equals("italic")) {
              style = Font.ITALIC;
            } else if (fontStyle.equals("bolditalic")) {
              style = Font.ITALIC+Font.BOLD;
            }
           
            log.debug("fontStyle,style "+style+" fs: "+fontStyle);
           
            Double x = Double.valueOf(graphObject.get(graphObject.size()-5).toString()).doubleValue();
            Double y = Double.valueOf(graphObject.get(graphObject.size()-4).toString()).doubleValue();
            Double width = Double.valueOf(graphObject.get(graphObject.size()-3).toString()).doubleValue();
            Double height = Double.valueOf(graphObject.get(graphObject.size()-2).toString()).doubleValue();
           
            SVGGraphics2D svgGenerator_temp = new SVGGraphics2D(svgGenerator);
            this.paintTextByWidthHeight(svgGenerator_temp, (int) Math.round(x), (int) Math.round(y), (int) Math.round(width),
                  (int) Math.round(height), text, style, fontSize, fontColor);
           
          } else if (graphType.equals("drawarrow")) {
           
            Integer thickness = Integer.valueOf(graphObject.get(2).toString()).intValue();
           
            Integer stroke = Integer.valueOf(graphObject.get(1).toString()).intValue();
            Integer strokeDis= Integer.valueOf(graphObject.get(4).toString()).intValue();
           
            Color strokeColor = null;
            if (strokeDis != -1) {
              strokeColor = new Color(stroke);
            }
           
            Integer fill = Integer.valueOf(graphObject.get(3).toString()).intValue();
            Integer fillDis= Integer.valueOf(graphObject.get(5).toString()).intValue();
           
            Color fillColor = null;
            if (fillDis != -1) {
              fillColor = new Color(fill);
            }
           
            Float alpha = Float.valueOf(graphObject.get(6).toString()).floatValue();
           
            Double x = Double.valueOf(graphObject.get(graphObject.size()-5).toString()).doubleValue();
            Double y = Double.valueOf(graphObject.get(graphObject.size()-4).toString()).doubleValue();
            //Double width = Double.valueOf(graphObject.get(graphObject.size()-3).toString()).doubleValue();
            //Double height = Double.valueOf(graphObject.get(graphObject.size()-2).toString()).doubleValue();
           
            Double x1 = Double.valueOf(graphObject.get(7).toString()).doubleValue();
            Double y1 = Double.valueOf(graphObject.get(8).toString()).doubleValue();
            Double x2 = Double.valueOf(graphObject.get(9).toString()).doubleValue();
            Double y2 = Double.valueOf(graphObject.get(10).toString()).doubleValue();
           
            GeomPoint start = new GeomPoint();
              start.setLocation(x+x1,y+y1);
              GeomPoint end = new GeomPoint();
              end.setLocation(x+x2,y+y2);
             
              SVGGraphics2D svgGenerator_temp = new SVGGraphics2D(svgGenerator);
              this.drawArrow(svgGenerator_temp, start, end, thickness, alpha, strokeColor,fillColor);
          } else if (graphType.equals("image")) {
           
            //log.debug("graphObject image "+graphObject);
            //log.debug("",graphObject);
           
            String room = graphObject.get(6).toString();
            String parentPath = graphObject.get(5).toString();
            String fileItemName = graphObject.get(3).toString();
           
            File imageFile = new File(OmFileHelper.getUploadDir(), room);
           
            if (parentPath.length() > 1) {
              imageFile = new File(imageFile, parentPath);
            }
           
            //log.debug("fileItemName: "+fileItemName);
           
            File myFile = new File(imageFile, fileItemName);
           
            if (myFile.exists() && myFile.canRead()) {
             
              Image myImage = ImageIO.read(myFile);
             
              int x = (int) Math.round(Double.valueOf(graphObject.get(graphObject.size()-5).toString()).doubleValue());
              int y = (int) Math.round(Double.valueOf(graphObject.get(graphObject.size()-4).toString()).doubleValue());
              int width = (int) Math.round(Double.valueOf(graphObject.get(graphObject.size()-3).toString()).doubleValue());
              int height = (int) Math.round(Double.valueOf(graphObject.get(graphObject.size()-2).toString()).doubleValue());
             
              SVGGraphics2D svgGenerator_temp = new SVGGraphics2D(svgGenerator);
              svgGenerator_temp.drawImage(myImage, x, y, width, height, null);
             
            } else {
              log.error("tried to inculde a non existing File into SVG/Image Export Path: " + myFile);
            }
           
          } else if(graphType.equals("line") || graphType.equals("uline")) {
           
//            actionObject[0] = 'line';
//                actionObject[1] = stroke;
//                actionObject[2] = line;
//                actionObject[3] = opacity;
//                actionObject[4] = x1 
//                actionObject[5] = y1; 
//                actionObject[6] = x2;   
//                actionObject[7] = y2;   
//                actionObject[8] = this.counter;
//                actionObject[9] = x;
//                actionObject[10] = y;
//                actionObject[11] = width;
//                actionObject[12] = height; 
//                actionObject[13] = newName;
           
          Integer lineWidth = Integer.valueOf(graphObject.get(2).toString()).intValue();
           
            Integer stroke = Integer.valueOf(graphObject.get(1).toString()).intValue();
            Color strokeColor = new Color(stroke);
           
            Float alpha = Float.valueOf(graphObject.get(3).toString()).floatValue();
           
            Double x = Double.valueOf(graphObject.get(graphObject.size()-5).toString()).doubleValue();
            Double y = Double.valueOf(graphObject.get(graphObject.size()-4).toString()).doubleValue();
            //Double width = Double.valueOf(graphObject.get(graphObject.size()-3).toString()).doubleValue();
            //Double height = Double.valueOf(graphObject.get(graphObject.size()-2).toString()).doubleValue();

            Double x1 = Double.valueOf(graphObject.get(4).toString()).doubleValue();
            Double y1 = Double.valueOf(graphObject.get(5).toString()).doubleValue();
            Double x2 = Double.valueOf(graphObject.get(6).toString()).doubleValue();
            Double y2 = Double.valueOf(graphObject.get(7).toString()).doubleValue();
           
            SVGGraphics2D svgGenerator_temp = new SVGGraphics2D(svgGenerator);
            this.drawLine(svgGenerator_temp, x1, y1, x2, y2, strokeColor, lineWidth, x, y, alpha);
           
          } else {
            log.error("tried to include a non supported Graph-Object graphType: "+graphType);
          }
View Full Code Here

      //int x, int y, int width, int height
    n.setBounds( x, y , width, height );
    n.setOpaque( false );
   
    //Text
    SVGGraphics2D svgGenerator2 = (SVGGraphics2D) g2d.create(x, y, width, height);

    //svgGenerator2.create(x, y, width, height);
    //svgGenerator2.draw(.dra)
    n.paint( svgGenerator2 );
   
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

      ctx.setEmbeddedFontsOn(true);
      final GraphicContextDefaults defaults = new GraphicContextDefaults();
      defaults.setFont(new Font("Arial", Font.PLAIN, 12));
      ctx.setGraphicContextDefaults(defaults);
      ctx.setPrecision(12);
      final SVGGraphics2D g2d = new SVGGraphics2D(ctx, false);
      g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
      view.preparePrinting();
      final Rectangle innerBounds = view.getInnerBounds();
      g2d.setSVGCanvasSize(new Dimension(innerBounds.width, innerBounds.height));
      g2d.translate(-innerBounds.x, -innerBounds.y);
      view.print(g2d);
      view.endPrinting();
      return g2d;
    }
    finally
View Full Code Here

      final MapView view = (MapView) Controller.getCurrentController().getMapViewManager().getMapViewComponent();
      if (view == null) {
        return;
      }
      Controller.getCurrentController().getViewController().setWaitingCursor(true);
      final SVGGraphics2D g2d = fillSVGGraphics2D(view);
      final PDFTranscoder pdfTranscoder = new PDFTranscoder();
      /*
       * according to https: &aid=1921334&group_id=7118 Submitted By:
       * Frank Spangenberg (f_spangenberg) Summary: Large mind maps
       * produce invalid PDF
       */
      pdfTranscoder.addTranscodingHint(SVGAbstractTranscoder.KEY_MAX_HEIGHT, new Float(19200));
      pdfTranscoder.addTranscodingHint(SVGAbstractTranscoder.KEY_MAX_WIDTH, new Float(19200));
      pdfTranscoder.addTranscodingHint(ImageTranscoder.KEY_PIXEL_UNIT_TO_MILLIMETER, 25.4f/72f/UITools.FONT_SCALE_FACTOR);
      /* end patch */
      final Document doc = g2d.getDOMFactory();
      final Element rootE = doc.getDocumentElement();
      g2d.getRoot(rootE);
      final TranscoderInput input = new TranscoderInput(doc);
      final FileOutputStream ostream = new FileOutputStream(chosenFile);
      final BufferedOutputStream bufStream = new BufferedOutputStream(ostream);
      final TranscoderOutput output = new TranscoderOutput(bufStream);
      pdfTranscoder.transcode(input, output);
View Full Code Here

      final MapView view = (MapView) Controller.getCurrentController().getMapViewManager().getMapViewComponent();
      if (view == null) {
        return;
      }
      Controller.getCurrentController().getViewController().setWaitingCursor(true);
      final SVGGraphics2D g2d = fillSVGGraphics2D(view);
      final FileOutputStream bos = new FileOutputStream(chosenFile);
      final BufferedOutputStream bufStream = new BufferedOutputStream(bos);
      final OutputStreamWriter osw = new OutputStreamWriter(bufStream, "UTF-8");
      g2d.stream(osw);
      osw.flush();
      bos.flush();
      bos.close();
    }
    catch (final Exception ex) {
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.