Example usage for org.jfree.chart ChartUtilities writeBufferedImageAsJPEG

List of usage examples for org.jfree.chart ChartUtilities writeBufferedImageAsJPEG

Introduction

In this page you can find the example usage for org.jfree.chart ChartUtilities writeBufferedImageAsJPEG.

Prototype

public static void writeBufferedImageAsJPEG(OutputStream out, BufferedImage image) throws IOException 

Source Link

Document

Writes a BufferedImage to an output stream in JPEG format.

Usage

From source file:com.beetle.framework.web.controller.DrawController.java

private void drawing(OutputStream out, DrawInfo drawInfo) throws IOException {
    if (drawInfo.getPlusObj() != null && drawInfo.getQuality() == -1) {
        BufferedImage image = (BufferedImage) drawInfo.getPlusObj();
        ChartUtilities.writeBufferedImageAsJPEG(out, image);
    } else {/*from   www  . ja  v  a2s  .c  om*/
        ChartUtilities.writeChartAsJPEG(out, drawInfo.getQuality(), drawInfo.getChart(), drawInfo.getWidth(),
                drawInfo.getHeight(), drawInfo.getInfo());
    }
    drawInfo = null;
}

From source file:gov.nih.nci.caintegrator.plots.kaplanmeier.JFreeChartIKMPlottermpl.java

public void writeBufferedImage(OutputStream out, BufferedImage image, ImageTypes imgType) throws KMException {
    if (imgType == null)
        imgType = ImageTypes.PNG; // default

    try {/*from   ww  w.  ja v a  2  s  . c o  m*/
        if (imgType == ImageTypes.PNG)
            ChartUtilities.writeBufferedImageAsPNG(out, image);
        else if (imgType == ImageTypes.JPEG)
            ChartUtilities.writeBufferedImageAsJPEG(out, image);
        else {
            logger.debug(new String("UnSupported File Format: " + imgType.getValue()));
            throw new KMException("UnSupported File Format: " + imgType.getValue());
        }
    } catch (IOException ioe) {
        logger.debug(ioe);
        throw new KMException(ioe);
    }

}

From source file:gov.nih.nci.caintegrator.plots.kaplanmeier.JFreeChartIKMPlottermpl.java

public void writeBufferedImageAsJPEG(OutputStream out, BufferedImage image) throws IOException {
    ChartUtilities.writeBufferedImageAsJPEG(out, image);
}

From source file:org.gumtree.vis.awt.CompositePanel.java

@Override
public void saveTo(String filename, String fileType) throws IOException {
    int filterIndex = 0;
    if (fileType != null) {
        if (fileType.toLowerCase().contains("png")) {
            filterIndex = 0;/*from   www . j  a  v  a 2  s . c  o m*/
        } else if (fileType.toLowerCase().contains("jpg") || fileType.toLowerCase().contains("jpeg")) {
            filterIndex = 1;
        }
    }
    if (filterIndex == 0) {
        OutputStream out = new BufferedOutputStream(new FileOutputStream(filename));
        BufferedImage chartImage = getImage();
        try {
            ChartUtilities.writeBufferedImageAsPNG(out, chartImage);
        } finally {
            out.close();
        }
    } else if (filterIndex == 1) {
        OutputStream out = new BufferedOutputStream(new FileOutputStream(filename));
        BufferedImage chartImage = getImage();
        try {
            ChartUtilities.writeBufferedImageAsJPEG(out, chartImage);
        } finally {
            out.close();
        }
    }
}

From source file:lucee.runtime.tag.Chart.java

private void copy(OutputStream os, JFreeChart jfc, ChartRenderingInfo info)
        throws ApplicationException, IOException, ExpressionException {
    //OutputStream os = null;
    try {/*from ww  w .ja  v a2 s .c  o m*/
        //os = res.getOutputStream();

        BufferedImage bi;
        if (format == FORMAT_JPG) {
            bi = jfc.createBufferedImage(chartwidth, chartheight, BufferedImage.TYPE_INT_RGB, info);
        } else {
            bi = jfc.createBufferedImage(chartwidth, chartheight, info);
        }
        Image img;

        // add border
        if (showborder) {
            try {
                img = new Image(bi);
                img.addBorder(1, Color.BLACK, Image.BORDER_TYPE_CONSTANT);
                bi = img.getBufferedImage();
            } catch (PageException e) {
            }
        }
        if (format == FORMAT_PNG)
            ChartUtilities.writeBufferedImageAsPNG(os, bi);
        else if (format == FORMAT_JPG)
            ChartUtilities.writeBufferedImageAsJPEG(os, bi);
        else if (format == FORMAT_GIF) {
            img = new lucee.runtime.img.Image(bi);
            img.writeOut(os, "gif", 1, true);

            //throw new ApplicationException("format gif not supported");
        } else if (format == FORMAT_FLASH)
            throw new ApplicationException("format flash not supported");
    } finally {
        IOUtil.flushEL(os);
        IOUtil.closeEL(os);
    }
}