/** * Writes a chart to an output stream in JPEG format. Please note that * JPEG is a poor format for chart images, use PNG if possible. * * @param out the output stream (<code>null</code> not permitted). * @param chart the chart (<code>null</code> not permitted). * @param width the image width. * @param height the image height. * * @throws IOException if there are any I/O errors. */ public static void writeChartAsJPEG(OutputStream out, JFreeChart chart, int width, int height) throws IOException { // defer argument checking... writeChartAsJPEG(out, chart, width, height, null); }
/** * Writes a chart to an output stream in JPEG format. Please note that * JPEG is a poor format for chart images, use PNG if possible. * * @param out the output stream (<code>null</code> not permitted). * @param quality the quality setting. * @param chart the chart (<code>null</code> not permitted). * @param width the image width. * @param height the image height. * * @throws IOException if there are any I/O errors. */ public static void writeChartAsJPEG(OutputStream out, float quality, JFreeChart chart, int width, int height) throws IOException { // defer argument checking... ChartUtilities.writeChartAsJPEG(out, quality, chart, width, height, null); }
/** * Saves a chart to a file in JPEG format. This method allows you to pass * in a {@link ChartRenderingInfo} object, to collect information about the * chart dimensions/entities. You will need this info if you want to * create an HTML image map. * * @param file the file name (<code>null</code> not permitted). * @param chart the chart (<code>null</code> not permitted). * @param width the image width. * @param height the image height. * @param info the chart rendering info (<code>null</code> permitted). * * @throws IOException if there are any I/O errors. */ public static void saveChartAsJPEG(File file, JFreeChart chart, int width, int height, ChartRenderingInfo info) throws IOException { if (file == null) { throw new IllegalArgumentException("Null 'file' argument."); } if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); } OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); try { writeChartAsJPEG(out, chart, width, height, info); } finally { out.close(); } }
file)); try { writeChartAsJPEG(out, quality, chart, width, height, info);
@Override protected byte[] getImageData(final Attributes attributes) { try { final JFreeChart chart = (JFreeChart) getDefaultModelObject(); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); if (imageType == JFreeChartImageType.JPEG) { ChartUtilities.writeChartAsJPEG(baos, chart, width, height); } else { ChartUtilities.writeChartAsPNG(baos, chart, width, height); } final byte[] ba = baos.toByteArray(); return ba; } catch (final IOException ex) { log.error(ex.getMessage(), ex); return null; } }
ChartUtilities.writeChartAsJPEG(bos, chart, 2400, 400); return bos.toByteArray();
ChartUtilities.writeChartAsJPEG(bos, chart, 2400, 400);
ChartUtilities.writeChartAsJPEG(os, chart, getIntValueFromString(width), getIntValueFromString(height));
/** * @param out * @return extension png or jpg for usage as file name extension. */ public String write(final OutputStream out) { final JFreeChart chart = getJFreeChart(); final int width = getWidth(); final int height = getHeight(); String extension = null; try { if (getImageType() == JFreeChartImageType.PNG) { extension = "png"; ChartUtilities.writeChartAsPNG(out, chart, width, height); } else { extension = "jpg"; ChartUtilities.writeChartAsJPEG(out, chart, width, height); } } catch (final IOException ex) { log.error("Exception encountered " + ex, ex); } return extension; }
ChartUtilities.writeChartAsJPEG(bos, chart, 2400, 400); return bos.toByteArray();
/** * Helper method that returns the JFreeChart to an output stream written in JPEG format. * * @param chartName a {@link java.lang.String} object. * @param out a {@link java.io.OutputStream} object. * @throws java.io.IOException if any. * @throws java.sql.SQLException if any. */ public static void getBarChart(String chartName, OutputStream out) throws IOException, SQLException { BarChart chartConfig = getBarChartConfigByName(chartName); JFreeChart chart = getBarChart(chartName); ImageSize imageSize = chartConfig.getImageSize(); int hzPixels; int vtPixels; if (imageSize == null) { hzPixels = 400; vtPixels = 400; } else { hzPixels = imageSize.getHzSize().getPixels(); vtPixels = imageSize.getVtSize().getPixels(); } ChartUtilities.writeChartAsJPEG(out, chart, hzPixels, vtPixels); }
/** * Helper method that returns the JFreeChart to an output stream written in JPEG format. * * @param chartName a {@link java.lang.String} object. * @param out a {@link java.io.OutputStream} object. * @throws java.io.IOException if any. * @throws java.sql.SQLException if any. */ public static void getBarChart(String chartName, OutputStream out) throws IOException, SQLException { BarChart chartConfig = getBarChartConfigByName(chartName); JFreeChart chart = getBarChart(chartName); ImageSize imageSize = chartConfig.getImageSize(); int hzPixels; int vtPixels; if (imageSize == null) { hzPixels = 400; vtPixels = 400; } else { hzPixels = imageSize.getHzSize().getPixels(); vtPixels = imageSize.getVtSize().getPixels(); } ChartUtilities.writeChartAsJPEG(out, chart, hzPixels, vtPixels); }
ChartUtilities.writeChartAsJPEG(imageStream, chart, width(), height(), info); } else { ChartUtilities.writeChartAsPNG(imageStream, chart, width(), height(), info, true, 0);
ChartUtilities.writeChartAsJPEG(bos, chart, 2400, 400); return bos.toByteArray();
} else { ByteArrayOutputStream stream = new ByteArrayOutputStream(); ChartUtilities.writeChartAsJPEG(stream, chart, getWidth(), getHeight());