Example usage for org.jfree.chart ChartUtilities writeChartAsPNG

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

Introduction

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

Prototype

public static void writeChartAsPNG(OutputStream out, JFreeChart chart, int width, int height,
        ChartRenderingInfo info, boolean encodeAlpha, int compression) throws IOException 

Source Link

Document

Writes a chart to an output stream in PNG format.

Usage

From source file:com.googlecode.tawus.jfreechart.internal.services.PNGChartRenderer.java

public void render(ChartModel chartModel, JFreeChart jfreeChart, OutputStream out) throws IOException {
    PNGChartModel pngChart = (PNGChartModel) chartModel;

    ChartUtilities.writeChartAsPNG(out, jfreeChart, chartModel.getWidth(), chartModel.getHeight(),
            pngChart.getInfo(), pngChart.isEncodeAlpha(), pngChart.getCompression());

}

From source file:org.orbeon.oxf.processor.serializer.legacy.JFreeChartSerializer.java

protected void readInput(PipelineContext pipelineContext, ProcessorInput input, Config config,
        OutputStream outputStream) {
    try {/*from w  w w .ja  va2  s . c  om*/
        ChartConfig chartConfig = readCacheInputAsObject(pipelineContext, getInputByName(INPUT_CHART),
                new CacheableInputReader<ChartConfig>() {
                    public ChartConfig read(org.orbeon.oxf.pipeline.api.PipelineContext context,
                            org.orbeon.oxf.processor.ProcessorInput input) {
                        return createChartConfig(context, input);
                    }
                });
        Document data = readInputAsDOM4J(pipelineContext, (input != null) ? input : getInputByName(INPUT_DATA));

        Dataset ds;
        if (chartConfig.getType() == ChartConfig.PIE_TYPE || chartConfig.getType() == ChartConfig.PIE3D_TYPE)
            ds = createPieDataset(chartConfig, data);
        else if (chartConfig.getType() == ChartConfig.XY_LINE_TYPE)
            ds = createXYDataset(chartConfig, data);
        else if (chartConfig.getType() == ChartConfig.TIME_SERIES_TYPE)
            ds = createTimeSeriesDataset(chartConfig, data);
        else
            ds = createDataset(chartConfig, data);
        JFreeChart chart = drawChart(chartConfig, ds);
        ChartRenderingInfo info = new ChartRenderingInfo();
        ChartUtilities.writeChartAsPNG(outputStream, chart, chartConfig.getxSize(), chartConfig.getySize(),
                info, true, 5);
    } catch (Exception e) {
        throw new OXFException(e);
    }
}