/** * 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(); } }
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); } }
/** * Saves a chart to the specified file in PNG format. * * @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. * * @throws IOException if there are any I/O errors. */ public static void saveChartAsPNG(File file, JFreeChart chart, int width, int height) throws IOException { // defer argument checking... saveChartAsPNG(file, chart, width, height, null); }
/** * Saves the given chart to a PNG image file. * * @param aFile * File to be saved to. * @param aChart * Chart to be saved. * @param aWidth * Desired width of the image. * @param aHeight * Desired height of the image. * @throws IOException * If I/O error occurs. */ public static void saveAsPng(File aFile, JFreeChart aChart, int aWidth, int aHeight) throws IOException { ChartUtilities.saveChartAsPNG(aFile, aChart, aWidth, aHeight); }
public File saveAsPNG(JFreeChart chart, int width, int height) throws IOException { File imageFile = File.createTempFile("chart-", ".png"); ChartUtilities.saveChartAsPNG(imageFile, chart, width, height); return imageFile; }
/** * 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(); } }
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); } }
private String createChartImage(final JFreeChart chart, final int width, final int height, final ChartRenderingInfo renderingInfo) throws IOException { File tempFile = getChartTempFile(); ChartUtilities.saveChartAsPNG(tempFile, chart, width, height, renderingInfo); return tempFile.getName(); }
public void savePlot(String fileName){ createChartFromData(); File filename_png = new File(fileName); try { ChartUtilities.saveChartAsPNG(filename_png, chart, graphSizeInXDimension, graphSizeInYDimension); } catch (IOException ex) { throw new RuntimeException("Error saving a file",ex); } }
public JFreeChartInstance(JFreeChart chart, File file, String mapId, String alt, int width, int height, String chartUrl) throws IOException { this.chart = chart; this.file = file; this.mapId = mapId; this.alt = alt; this.width = width; this.height = height; this.chartUrl = chartUrl; renderingInfo = new ChartRenderingInfo(); ChartUtilities.saveChartAsPNG(file, chart, width, height, renderingInfo); }
/** * Save a {@link JFreeChart} to the filesystem. * * @param filename The filename of the chart to save * @param chart the {@link JFreeChart} to save as a file * @throws IOException If the file cannot be saved */ public void renderChart( String filename, JFreeChart chart ) throws IOException { File parentDir = new File( outputDirectory ); File imageDir = new File( parentDir, "images" ); if ( !imageDir.exists() ) { imageDir.mkdirs(); } File pngFile = new File( imageDir, filename + ".png" ); ChartUtilities.saveChartAsPNG( pngFile, chart, WIDTH, HEIGHT ); } }
/** * Writes a graphic showing the number of departures, arrivals and vehicles * en route of all legs/trips to the specified file. * * @param filename * * @see #getGraphic() */ public void writeGraphic(final String filename) { try { ChartUtilities.saveChartAsPNG(new File(filename), getGraphic(), 1024, 768); } catch (IOException e) { e.printStackTrace(); } }
/** * Writes a graphic showing the number of departures, arrivals and vehicles * en route of all legs/trips with the specified transportation mode to the * specified file. * * @param filename * @param legMode * * @see #getGraphic(String) */ public void writeGraphic(final String filename, final String legMode) { try { ChartUtilities.saveChartAsPNG(new File(filename), getGraphic(legMode), 1024, 768); } catch (IOException e) { e.printStackTrace(); } }
/** * Stores the chart as PNG image file. * * @param filename The filename of the resulting PNG file. * @param width The width of the chart. * @param height The height of the chart. */ public void saveAsPng(final String filename, final int width, final int height) { try { ChartUtilities.saveChartAsPNG(new File(filename), getChart(), width, height, null, true, 9); } catch (IOException e) { e.printStackTrace(); } catch ( Exception e ) { e.printStackTrace() ; // I just had an out of bounds error inside the method; don't know what that means but does not feel like a reason // to not continue. kai, apr'30 } }
private void writePieChart(final StringBuilder sb, JFreeChart chart, Dimension dimension) throws IOException { TempDir tempDir = TempDirUtils.createTempDir(); String fileName = "frequencies-pie-chart.png"; File file = tempDir.createFile(fileName); String imageFile = "<center><img src=\"file:" + file.getAbsolutePath() + "\"</img></center>"; ChartUtilities.saveChartAsPNG(file, chart, dimension != null ? dimension.width : 1000, dimension != null ? dimension.height : 1000); sb.append(imageFile); } }
public static void writeGraphic(CourtesyHistogram courtesyHistogram, final String actType, final String filename) { try { ChartUtilities.saveChartAsPNG( new File(filename), getGraphic( courtesyHistogram.getDataFrames().get( actType ), courtesyHistogram.getIteration(), actType), 1024, 768); } catch (IOException e) { throw new UncheckedIOException(e); } } }
private Chart generatePngChart(JFreeChart jfchart, ChartParams params, XWikiContext context) throws IOException, GenerateException { File file = getTempFile(params.hashCode(), "png"); ChartUtilities.saveChartAsPNG(file, jfchart, params.getInteger(ChartParams.WIDTH).intValue(), params .getInteger(ChartParams.HEIGHT).intValue()); String imageURL = context.getDoc().getAttachmentURL(file.getName(), "charting", context); String pageURL = imageURL; return new ChartImpl(params, imageURL, pageURL); }
/** * Writes a graphic showing the number of departures, arrivals and vehicles * en route of all legs/trips to the specified file. * * @param legHistogram * @param filename * */ public static void writeGraphic(LegHistogram legHistogram, final String filename) { try { ChartUtilities.saveChartAsPNG(new File(filename), getGraphic(legHistogram.getAllModesData(), "all", legHistogram.getIteration()), 1024, 768); } catch (IOException e) { throw new UncheckedIOException(e); } }
public static String renderChart(JFreeChart chart, String fileName) { String imageFile = ""; try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); TempDir tempDir = TempDirUtils.createTempDir(); File file1 = tempDir.createFile(fileName); imageFile = "<IMG SRC=\"file:" + file1.getAbsolutePath() + "\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\"></IMG>"; ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); } catch (IOException e) { } return imageFile; }
public void saveAndDisplayPlot(String fileName) { createChartFromData(); File filename_png = new File(fileName); //saving try { ChartUtilities.saveChartAsPNG(filename_png, chart, graphSizeInXDimension, graphSizeInYDimension); } catch (IOException ex) { throw new RuntimeException("Error saving a file",ex); } //display final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(graphSizeInXDimension, graphSizeInYDimension)); setContentPane(chartPanel); this.pack(); RefineryUtilities.centerFrameOnScreen(this); this.setVisible(true); }