Search in sources :

Example 1 with SVGGraphics2D

use of org.freehep.graphicsio.svg.SVGGraphics2D in project abstools by abstools.

the class ExporterImpl method getGraphics.

private VectorGraphics getGraphics() {
    VectorGraphics vectorGraphics;
    if (orientation == null) {
        orientation = dim.getWidth() <= dim.getHeight() ? "Portrait" : "Landscape";
    }
    if (type.equals("gif")) {
        vectorGraphics = new GIFGraphics2D(stream, dim);
    } else if (type.equals("png")) {
        vectorGraphics = new ImageGraphics2D(stream, dim, "png");
    } else if (type.equals("bmp")) {
        vectorGraphics = new ImageGraphics2D(stream, dim, "bmp");
    } else if (type.equals("jpg")) {
        vectorGraphics = new ImageGraphics2D(stream, dim, "jpg");
    } else if (type.equals("pdf")) {
        PDFGraphics2D pdf = new PDFGraphics2D(stream, dim);
        Properties properties = new Properties();
        properties.setProperty(PDFGraphics2D.ORIENTATION, orientation);
        properties.setProperty(PDFGraphics2D.PAGE_SIZE, format);
        pdf.setProperties(properties);
        vectorGraphics = pdf;
    } else if (type.equals("ps")) {
        PSGraphics2D ps = new PSGraphics2D(stream, dim);
        Properties properties = new Properties();
        properties.setProperty(PSGraphics2D.ORIENTATION, orientation);
        properties.setProperty(PSGraphics2D.PAGE_SIZE, format);
        ps.setProperties(properties);
        ps.setMultiPage(true);
        vectorGraphics = ps;
    } else if (type.equals("emf")) {
        vectorGraphics = new EMFGraphics2D(stream, dim);
    } else if (type.equals("svg")) {
        vectorGraphics = new SVGGraphics2D(stream, dim);
    } else if (type.equals("swf")) {
        vectorGraphics = new SWFGraphics2D(stream, dim);
    } else {
        throw new IllegalArgumentException("Unknown type: " + type);
    }
    return vectorGraphics;
}
Also used : EMFGraphics2D(org.freehep.graphicsio.emf.EMFGraphics2D) ImageGraphics2D(org.freehep.graphicsio.ImageGraphics2D) PDFGraphics2D(org.freehep.graphicsio.pdf.PDFGraphics2D) GIFGraphics2D(org.freehep.graphicsio.gif.GIFGraphics2D) SVGGraphics2D(org.freehep.graphicsio.svg.SVGGraphics2D) SWFGraphics2D(org.freehep.graphicsio.swf.SWFGraphics2D) PSGraphics2D(org.freehep.graphicsio.ps.PSGraphics2D) Properties(java.util.Properties) VectorGraphics(org.freehep.graphics2d.VectorGraphics)

Example 2 with SVGGraphics2D

use of org.freehep.graphicsio.svg.SVGGraphics2D in project cytoscape-impl by cytoscape.

the class SVGWriter method run.

@Override
public void run(TaskMonitor taskMonitor) throws Exception {
    taskMonitor.setProgress(0.0);
    taskMonitor.setStatusMessage("SVG Rendering Start...");
    logger.debug("SVG Rendering Start.");
    final SVGGraphics2D g = new SVGGraphics2D(stream, new Dimension(width.intValue(), height.intValue()));
    // this sets text as shape
    final Properties p = new Properties();
    p.setProperty("org.freehep.graphicsio.AbstractVectorGraphicsIO.TEXT_AS_SHAPES", Boolean.toString(!exportTextAsFont));
    g.setProperties(p);
    taskMonitor.setProgress(0.2);
    g.startExport();
    engine.printCanvas(g);
    g.endExport();
    logger.debug("SVG Rendering DONE.");
    taskMonitor.setStatusMessage("SVG Rendering DONE.");
    taskMonitor.setProgress(1.0);
}
Also used : SVGGraphics2D(org.freehep.graphicsio.svg.SVGGraphics2D) Dimension(java.awt.Dimension) Properties(java.util.Properties)

Example 3 with SVGGraphics2D

use of org.freehep.graphicsio.svg.SVGGraphics2D in project clusterMaker2 by RBVI.

the class GraphicsExportPanel method svgSave.

private void svgSave(String format) {
    com.itextpdf.text.Rectangle pageSize = PageSize.LETTER;
    Properties p = new Properties();
    p.setProperty(PSGraphics2D.PAGE_SIZE, "Letter");
    p.setProperty("org.freehep.graphicsio.AbstractVectorGraphicsIO.TEXT_AS_SHAPES", Boolean.toString(false));
    try {
        OutputStream output = new BufferedOutputStream(new FileOutputStream(getFile()));
        SVGGraphics2D g = new SVGGraphics2D(output, view);
        double imageScale = Math.min(pageSize.getWidth() / ((double) estimateWidth() + getBorderPixels()), pageSize.getHeight() / ((double) estimateHeight() + getBorderPixels()));
        g.setProperties(p);
        g.startExport();
        g.scale(imageScale, imageScale);
        drawAll(g, 1.0);
        g.endExport();
        output.close();
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, new JTextArea("Dendrogram export had problem " + e));
    // logger.error("Exception " + e);
    // e.printStackTrace();
    }
}
Also used : JTextArea(javax.swing.JTextArea) BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) SVGGraphics2D(org.freehep.graphicsio.svg.SVGGraphics2D) Properties(java.util.Properties) BufferedOutputStream(java.io.BufferedOutputStream)

Aggregations

Properties (java.util.Properties)3 SVGGraphics2D (org.freehep.graphicsio.svg.SVGGraphics2D)3 Dimension (java.awt.Dimension)1 BufferedOutputStream (java.io.BufferedOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 JTextArea (javax.swing.JTextArea)1 VectorGraphics (org.freehep.graphics2d.VectorGraphics)1 ImageGraphics2D (org.freehep.graphicsio.ImageGraphics2D)1 EMFGraphics2D (org.freehep.graphicsio.emf.EMFGraphics2D)1 GIFGraphics2D (org.freehep.graphicsio.gif.GIFGraphics2D)1 PDFGraphics2D (org.freehep.graphicsio.pdf.PDFGraphics2D)1 PSGraphics2D (org.freehep.graphicsio.ps.PSGraphics2D)1 SWFGraphics2D (org.freehep.graphicsio.swf.SWFGraphics2D)1