/** * Helper that just saves the chart as specified png-file. The width of the image is 1000 and height 600. * * @param chart * @param pngFilename */ public static void saveChartAsPNG(JFreeChart chart, String pngFilename) { try { ChartUtilities.saveChartAsPNG(new File(pngFilename), chart, 1000, 600); } catch (IOException e) { e.printStackTrace(); } }
ChartUtilities.writeChartAsPNG(outputStream, chart, width, height);
/** * Renders a clickable map. */ public void doMap(StaplerRequest req, StaplerResponse rsp) throws IOException { if (req.checkIfModified(timestamp, rsp)) return; ChartRenderingInfo info = new ChartRenderingInfo(); render(req,info); rsp.setContentType("text/plain;charset=UTF-8"); rsp.getWriter().println(ChartUtilities.getImageMap( "map", 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; } }
case JPEG: try { ChartUtilities.saveChartAsJPEG(new File(params.path), chart, params.width, params.height); } catch (IOException e) { case PNG: try { ChartUtilities.saveChartAsPNG(new File(params.path), chart, params.width, params.height); } catch (IOException e) {
/** * Create a PNG image file from a JFreeChart object * * @param chart * The chart object to create an image from * @param path * The path and name of the image file to create * @param width * The width of the image in pixels * @param height * The height of the image in pixels * @param writer * A writer for the iamge map to be written to * @throws IOException */ private static void saveChartAsPNG( final JFreeChart chart, final String path, final int width, final int height, final PrintWriter writer, final ChartRenderingInfo info ) throws IOException { File file = new File( path + ".png" ); //$NON-NLS-1$ ChartUtilities.saveChartAsPNG( file, chart, width, height, info ); // TODO support tool tip generators // TODO support URL fragment generators // TODO: make the image map name unique on the page if ( writer != null ) { ChartUtilities.writeImageMap( writer, "map-name", info, true ); //$NON-NLS-1$ } }
/** * 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); }
/** * Saves a chart to a file in JPEG format. * * @param file the file (<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 saveChartAsJPEG(File file, JFreeChart chart, int width, int height) throws IOException { // defer argument checking... saveChartAsJPEG(file, chart, width, height, null); }
.write(ChartUtilities.encodeAsPNG(chart.createBufferedImage(width, 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; }
case JPEG: try { ChartUtilities.saveChartAsJPEG(new File(params.path), chart, params.width, params.height); } catch (IOException e) { case PNG: try { ChartUtilities.saveChartAsPNG(new File(params.path), chart, params.width, params.height); } catch (IOException e) {
/** * 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. * * @param file the file (<code>null</code> not permitted). * @param quality the JPEG 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 saveChartAsJPEG(File file, float quality, JFreeChart chart, int width, int height) throws IOException { // defer argument checking... saveChartAsJPEG(file, quality, chart, width, height, null); }
/** * Writes the given JFreeChart to the kmz file specified for the kmz writer attribute of this class. * @param filename the filename to use in the kmz * @param chart * @throws IOException */ private void writeChartToKmz(final String filename, final JFreeChart chart) throws IOException { byte [] img; img = ChartUtilities.encodeAsPNG(chart.createBufferedImage(CHARTWIDTH, CHARTHEIGHT)); this.writer.addNonKMLFile(img, filename); }
private void save(JFreeChart chart, String pngFile) { try { ChartUtilities.saveChartAsPNG(new File(pngFile), chart, 1000, 600); } catch (IOException e) { log.error("cannot plot"); log.error(e.toString()); e.printStackTrace(); throw new RuntimeException(e); } }
/** * Writes a chart to an output stream in PNG format. * * @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 writeChartAsPNG(OutputStream out, JFreeChart chart, int width, int height) throws IOException { // defer argument checking... writeChartAsPNG(out, chart, width, height, null); }
ChartUtilities.writeChartAsPNG(os, chart, getIntValueFromString(width), getIntValueFromString(height)); ChartUtilities.writeChartAsJPEG(os, chart, getIntValueFromString(width), getIntValueFromString(height));
/** * 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(); } }
public void saveToJPG(File jpgFileName, int width, int height) { try { ChartUtilities.saveChartAsJPEG(jpgFileName, graph, width, height); } catch (IOException e) { System.err.println("Problem occurred creating chart."); } }
@Override public String getImageMap(String id, int width, int height) { //Unfortunately we have to render it again, because the map is loaded lazily in another HTTP request render(width, height); return ChartUtilities.getImageMap(id, info); }