Example usage for org.jfree.chart.encoders KeypointPNGEncoderAdapter encode

List of usage examples for org.jfree.chart.encoders KeypointPNGEncoderAdapter encode

Introduction

In this page you can find the example usage for org.jfree.chart.encoders KeypointPNGEncoderAdapter encode.

Prototype

@Override
public void encode(BufferedImage bufferedImage, OutputStream outputStream) throws IOException 

Source Link

Document

Encodes an image in PNG format and writes it to an OutputStream.

Usage

From source file:au.edu.jcu.kepler.hydrant.JFreeChartPlot.java

public synchronized void fillPlot() {
    ReplacementManager man = ReplacementUtils.getReplacementManager(_plotterBase);
    HashMap data_map = new HashMap();
    String fullName = _plotterBase.getFullName();
    data_map.put("name", fullName);
    data_map.put("type", "IMAGE");

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    KeypointPNGEncoderAdapter encoder = new KeypointPNGEncoderAdapter();
    try {/* w  ww. jav a 2 s . c om*/
        encoder.encode(_chart.createBufferedImage(480, 300), baos);

    } catch (IOException e) {
        e.printStackTrace();
        return;
    }
    data_map.put("plotOutput", baos);
    data_map.put("format", "png");
    //data_map.put("output", file.getAbsolutePath());
    man.writeData(data_map);
}

From source file:org.sonar.server.charts.deprecated.BaseChart.java

public void exportChartAsPNG(OutputStream out) throws IOException {
    KeypointPNGEncoderAdapter encoder = new KeypointPNGEncoderAdapter();
    encoder.setEncodingAlpha(true);/* ww w  .j  a v  a 2 s. c o  m*/
    encoder.encode(getChartImage(), out);
}

From source file:org.sonar.server.charts.ChartsServlet.java

private void exportAsPNG(BufferedImage image, OutputStream out) throws IOException {
    KeypointPNGEncoderAdapter encoder = new KeypointPNGEncoderAdapter();
    encoder.setEncodingAlpha(true);//  www.j  a v  a2 s.  c  o  m
    encoder.encode(image, out);
}

From source file:userinterface.graph.Graph.java

/**
 * Renders the current graph to a JPEG file.
 * // w  ww. j a  v  a  2s.c  o  m
 * @param file
 *             The file to export the JPEG data to.
 * @throws GraphException, IOException
 *             If file cannot be written to.
 */
public void exportToPNG(File file, int width, int height, boolean alpha) throws GraphException, IOException {

    FileOutputStream fileOutputStream = new FileOutputStream(file);

    KeypointPNGEncoderAdapter encoder = new KeypointPNGEncoderAdapter();
    encoder.setEncodingAlpha(alpha);

    Paint bgPaint = chart.getBackgroundPaint();

    if (alpha) {
        chart.setBackgroundPaint(null);
    }

    BufferedImage bufferedImage = chart.createBufferedImage(width, height,
            alpha ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB, null);

    if (alpha) {
        chart.setBackgroundPaint(bgPaint);
    }

    encoder.encode(bufferedImage, fileOutputStream);

    fileOutputStream.flush();
    fileOutputStream.close();

    //ChartUtilities.saveChartAsPNG(file, this.chart, width, height, null, alpha, 9);
}