Package org.apache.batik.svggen

Examples of org.apache.batik.svggen.SVGGraphics2D


    // Create an instance of org.w3c.dom.Document
    String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
    org.w3c.dom.Document document = domImpl.createDocument(svgNS, "svg",
        null);
    // Create an instance of the SVG Generator
    SVGGraphics2D svgGenerator = new SVGGraphics2D(document);

    // Ask the chart to render into the SVG Graphics2D implementation
    Size size = config.getSize();
    int zoomLevel = size.getZoomLevel() > 0 ? size.getZoomLevel() : 1;
    int viewboxWidth = size.getWidth() / zoomLevel;
    int viewboxHeight = size.getHeight() / zoomLevel;
    int chartWidth = viewboxWidth - (60 / zoomLevel);
    int chartHeight = viewboxHeight - (28 / zoomLevel);

    chart.draw(svgGenerator, new Rectangle2D.Double(10, 10, chartWidth,
        chartHeight), null);
    Element root = svgGenerator.getRoot();
    root.setAttributeNS(null, "viewBox", "0 0 " + viewboxWidth + " "
        + viewboxHeight);
    // Finally, stream out SVG
    // character to byte encoding
    SVGContentImage svgImage = new SVGContentImage();
    svgGenerator.stream(root, svgImage.getWriter(), config.getVisibility()
        .isUseCSS(), false);
    return svgImage;
  }
View Full Code Here


     */
    public Graphics getGraphics(int width, int height) {
        if (svgGenerator == null) {
            DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
            Document document = domImpl.createDocument(null, "svg", null);
            svgGenerator = new SVGGraphics2D(document);
            svgGenerator.setClip(0, 0, width, height);
        }
        return svgGenerator;
    }
View Full Code Here

  {
    DOMImplementation domImpl =
      GenericDOMImplementation.getDOMImplementation();
    Document document =
      domImpl.createDocument(null, "svg", null);
    SVGGraphics2D grx =
      new SVGGraphics2D(document);
   
    grx.setSVGCanvasSize(rectangle.getBounds().getSize());

    List areaHyperlinks = null;

    if (chartHyperlinkProvider != null && chartHyperlinkProvider.hasHyperlinks())
    {
      areaHyperlinks = ChartUtil.getImageAreaHyperlinks(chart, chartHyperlinkProvider, grx, rectangle);
    }
    else
    {
      chart.draw(grx, rectangle);
    }

    try
    {
      StringWriter swriter = new StringWriter();
      grx.stream(swriter);
      return new BatikRenderer(swriter.getBuffer().toString(), areaHyperlinks);
    }
    catch (SVGGraphics2DIOException e)
    {
      throw new JRRuntimeException(e);
View Full Code Here

          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));
     
     
          SVGGraphics2D svgGenerator10 = new SVGGraphics2D(svgGenerator);
          //SVGGraphics2D svgGenerator2 = new SVGGraphics2D(document);
         
          //NOTE: Font.ITALIC+Font.BOLD = Font AND Bold !
//          GeomPoint start = new GeomPoint();
//          start.setLocation(100,100);
View Full Code Here

          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 1 asd asd as dasas " +
//              "  dasdasdasda sdasdad a  das dasdas dasdasdasd Process 1 asd asd as dasas dasdasdasdasdasdad a  das dasd" +
View Full Code Here

      //httpServletResponse.setContentType("APPLICATION/OCTET-STREAM");
      //httpServletResponse.setHeader("Content-Disposition","attachment; filename=\"" + requestedFile + "\"");
          Writer out = new OutputStreamWriter(System.out, "UTF-8");

          //Create an instance of the SVG Generator.
          SVGGraphics2D svgGenerator = new SVGGraphics2D(doc);
          svgGenerator.stream(out, useCSS);
         

    } catch (Exception er) {
      log.error("ERROR ", er);
      System.out.println("Error exporting: " + er);
View Full Code Here

          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));
     
     
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
            //Writer out = new OutputStreamWriter(System.out, "UTF-8");
           
           
            String requestedFile = fileName+"_"+CalendarPatterns.getTimeForStreamId(new Date())+".svg";
           
            if (exportType.equals("svg")) {
              //OutputStream out = httpServletResponse.getOutputStream();
          //httpServletResponse.setContentType("APPLICATION/OCTET-STREAM");
          //httpServletResponse.setHeader("Content-Disposition","attachment; filename=\"" + requestedFile + "\"");
              Writer out = httpServletResponse.getWriter();
             
              svgGenerator.stream(out, useCSS);
             
             
            } else if (exportType.equals("png") || exportType.equals("jpg")
                || exportType.equals("gif") || exportType.equals("tif")
                || exportType.equals("pdf")){
             
              String current_dir = getServletContext().getRealPath("/");
              String working_dir = current_dir + "uploadtemp" + File.separatorChar;
             
              String requestedFileSVG = fileName+"_"+CalendarPatterns.getTimeForStreamId(new Date())+".svg";
              String resultFileName = fileName+"_"+CalendarPatterns.getTimeForStreamId(new Date())+"."+exportType;
             
              log.debug("current_dir: "+current_dir);
              log.debug("working_dir: "+working_dir);
              log.debug("requestedFileSVG: "+requestedFileSVG);
              log.debug("resultFileName: "+resultFileName);
             
              File svgFile = new File(working_dir + requestedFileSVG);
              File resultFile = new File(working_dir + resultFileName);
             
              log.debug("svgFile: "+svgFile.getAbsolutePath());
              log.debug("resultFile: "+resultFile.getAbsolutePath());
              log.debug("svgFile P: "+svgFile.getPath());
              log.debug("resultFile P: "+resultFile.getPath());
             
              FileWriter out = new FileWriter(svgFile);
              svgGenerator.stream(out, useCSS);
             
              HashMap<String,Object> returnError = GenerateImage.getInstance().convertImageByTypeAndSize(
                  svgFile.getAbsolutePath(), resultFile.getAbsolutePath(),
                  pBean.getWidth(), pBean.getHeight());
             
View Full Code Here

        svgRoot.setAttributeNS(null, "width", ""+660);
        svgRoot.setAttributeNS(null, "height", ""+620);
       

        // Create an instance of the SVG Generator.
        SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
       
        //FIXME
        //svgGenerator = WhiteboardMapToSVG.getInstance().convertMapToSVG(svgGenerator, whiteBoardObjects);
   
        // 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");
       
       //log.debug(out.toString());
       
//       String firstImageName = this.generateFileName(recordingConversionJob.getRecordingConversionJobId(), fileNumber);
//       log.debug("Write File To: "+firstImageName);
//      
//       FileWriter fileWriter = new FileWriter(firstImageName);
//      
//       svgGenerator.stream(fileWriter, useCSS);
      
//       StringWriter stringWriter = new StringWriter();
//      
//       svgGenerator.stream(stringWriter, useCSS);
//      
//       log.debug("stringWriter"+stringWriter.toString());

        String firstImageName = "";
       
        if (isDebug) {
          firstImageName = this.generateSVGFileDebug(
                recordingConversionJob.getRecordingConversionJobId(),
                recordingConversionJob.getImageNumber());
        } else {
          firstImageName = this.generateSVGFileName(
            recordingConversionJob.getRecordingConversionJobId(),
            recordingConversionJob.getImageNumber());
        }

        log.debug("Write File To: " + firstImageName);

    FileWriter fileWriter = new FileWriter(firstImageName);
    svgGenerator.stream(fileWriter, useCSS);
   
    RecordingConversionJob recordingConversionJobToStore = RecordingConversionJobDaoImpl.getInstance().getRecordingConversionJobsByRecordingConversionJobsId(
        recordingConversionJob.getRecordingConversionJobId());

    recordingConversionJobToStore.setEndTimeInMilliSeconds(recordingConversionJob.getEndTimeInMilliSeconds() + numberOfMilliseconds);
View Full Code Here

        svgRoot.setAttributeNS(null, "width", ""+defaultWidth);
        svgRoot.setAttributeNS(null, "height", ""+defaultHeight);
       

        // Create an instance of the SVG Generator.
        SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
       
        //FIXME: Fix Recorder
        //svgGenerator = WhiteboardMapToSVG.getInstance().convertMapToSVG(svgGenerator, whiteBoardObjects);
   
        // 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");
       
       //log.debug(out.toString());
       
//       String firstImageName = this.generateFileName(recordingConversionJob.getRecordingConversionJobId(), fileNumber);
//       log.debug("Write File To: "+firstImageName);
//      
//       FileWriter fileWriter = new FileWriter(firstImageName);
//      
//       svgGenerator.stream(fileWriter, useCSS);
      
//       StringWriter stringWriter = new StringWriter();
//      
//       svgGenerator.stream(stringWriter, useCSS);
//      
//       log.debug("stringWriter"+stringWriter.toString());

        String firstImageName = "";
       
        if (isDebug) {
          firstImageName = this.generateSVGFileDebug(
                recordingConversionJob.getRecordingConversionJobId(),
                recordingConversionJob.getImageNumber());
        } else {
          firstImageName = this.generateSVGFileName(
            recordingConversionJob.getRecordingConversionJobId(),
            recordingConversionJob.getImageNumber());
        }

        log.debug("Write File To: " + firstImageName);

    FileWriter fileWriter = new FileWriter(firstImageName);
    svgGenerator.stream(fileWriter, useCSS);
   
    RecordingConversionJob recordingConversionJobToStore = RecordingConversionJobDaoImpl.getInstance().getRecordingConversionJobsByRecordingConversionJobsId(
        recordingConversionJob.getRecordingConversionJobId());

    recordingConversionJobToStore.setEndTimeInMilliSeconds(recordingConversionJob.getEndTimeInMilliSeconds() + numberOfMilliseconds);
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.