public static void writeChartToImageFile(JFreeChart chart, File chartFile) { BufferedImage chartImage = chart.createBufferedImage(1024, 768); try (OutputStream out = new FileOutputStream(chartFile)) { ImageIO.write(chartImage, "png", out); } catch (IOException e) { throw new IllegalArgumentException("Failed writing chartFile (" + chartFile + ").", e); } }
private File writeChartToImageFile(JFreeChart chart, String fileNameBase) { BufferedImage chartImage = chart.createBufferedImage(1024, 768); File summaryChartFile = new File(summaryDirectory, fileNameBase + ".png"); try (OutputStream out = new FileOutputStream(summaryChartFile)) { ImageIO.write(chartImage, "png", out); } catch (IOException e) { throw new IllegalArgumentException("Failed writing summaryChartFile (" + summaryChartFile + ").", e); } return summaryChartFile; }
private BufferedImage render(StaplerRequest req, ChartRenderingInfo info) { String w = req.getParameter("width"); if(w==null) w=String.valueOf(defaultW); String h = req.getParameter("height"); if(h==null) h=String.valueOf(defaultH); Color graphBg = stringToColor(req.getParameter("graphBg")); Color plotBg = stringToColor(req.getParameter("plotBg")); if (graph==null) graph = createGraph(); graph.setBackgroundPaint(graphBg); Plot p = graph.getPlot(); p.setBackgroundPaint(plotBg); return graph.createBufferedImage(Integer.parseInt(w),Integer.parseInt(h),info); }
renderer.setSeriesShape( 0, new Ellipse2D.Double( -3.0, -3.0, 6.0, 6.0 ) ); BufferedImage bufferedImage = chart.createBufferedImage( bounds.width, bounds.height ); ImageData imageData = ImageUtil.convertToSWT( bufferedImage );
renderer.setSeriesShape( 0, new Ellipse2D.Double( -3.0, -3.0, 6.0, 6.0 ) ); BufferedImage bufferedImage = chart.createBufferedImage( bounds.width, bounds.height ); ImageData imageData = ImageUtil.convertToSWT( bufferedImage );
private BufferedImage plot(VehicleRoutingProblem vrp, final Collection<VehicleRoute> routes, String pngFile, String title) { log.info("plot to {}", pngFile); XYSeriesCollection problem; XYSeriesCollection solution = null; final XYSeriesCollection shipments; try { retrieveActivities(vrp); problem = new XYSeriesCollection(activities); shipments = makeShipmentSeries(vrp.getJobs().values()); if (routes != null) solution = makeSolutionSeries(vrp, routes); } catch (NoLocationFoundException e) { log.warn("cannot plot vrp, since coord is missing"); return null; } final XYPlot plot = createPlot(problem, shipments, solution); JFreeChart chart = new JFreeChart(title, plot); LegendTitle legend = createLegend(routes, shipments, plot); chart.removeLegend(); chart.addLegend(legend); save(chart, pngFile); return chart.createBufferedImage(1024, 1024); }
private BufferedImage createChartImageInline(final JFreeChart chart, final int width, final int height, final ChartRenderingInfo renderingInfo) throws IOException { return chart.createBufferedImage(width, height, renderingInfo); }
/** * Creates and returns a buffered image into which the chart has been drawn. * * @param width the width. * @param height the height. * * @return A buffered image. */ public BufferedImage createBufferedImage(int width, int height) { return createBufferedImage(width, height, null); }
/** * Creates and returns a buffered image into which the chart has been drawn. * * @param width the width. * @param height the height. * * @return A buffered image. */ public BufferedImage createBufferedImage(int width, int height) { return createBufferedImage(width, height, null); }
.write(ChartUtilities.encodeAsPNG(chart.createBufferedImage(width, height)));
public void write(JFreeChart chart, File target) throws IOException { BufferedImage image = chart.createBufferedImage(640,480); FileOutputStream fos = new FileOutputStream(target); ImageIO.write(image, "PNG", fos); fos.close(); } }
/** * Updates the graph image displayed of this. Image includes graph data, axis, and legend. */ public void updateImage() { if (!lock) { ImageIcon icon = new ImageIcon(chart.createBufferedImage(150, 100, 150.0, 100.0, null)); this.setIcon(icon); } }
@Override public BufferedImage render(int width, int height) { createChart(); return jFreeChart.createBufferedImage(width, height, info); }
public static BufferedImage plotToImage(List<ExtendedResult> results, int width, int height) { return plotChart(results).createBufferedImage(width, height); }
private BufferedImage render(StaplerRequest req, ChartRenderingInfo info) { String w = req.getParameter("width"); if(w==null) w=String.valueOf(defaultW); String h = req.getParameter("height"); if(h==null) h=String.valueOf(defaultH); if (graph==null) graph = createGraph(); return graph.createBufferedImage(Integer.parseInt(w),Integer.parseInt(h),info); }
private String generateHeatChart(final TSTable info, final TimeSeries data, final int width, final int height) throws IOException { JFreeChart chart = TimeSeriesDatabase.createHeatJFreeChart(data, info); BufferedImage img = chart.createBufferedImage(width, height); File dbFile = new File(this.getDBFilePath()); File graphicFile = File.createTempFile(dbFile.getName() + '_' + fixName(info.getTableName()), ".dist.png", dbFile.getParentFile()); ImageIO.write(img, "png", graphicFile); return graphicFile.getAbsolutePath(); }
BufferedImage getChartImage(Map<String, String> parameters, String chartDataHtml) throws ParseException, MacroExecutionException { return getChart(parameters, chartDataHtml).createBufferedImage( getIntegerParameter(parameters, "width", DEFAULT_WIDTH, 0), getIntegerParameter(parameters, "height", DEFAULT_HEIGHT, 0) ); }
private BufferedImage render(StaplerRequest req, ChartRenderingInfo info) { String w = req.getParameter("width"); if(w==null) w=String.valueOf(defaultW); String h = req.getParameter("height"); if(h==null) h=String.valueOf(defaultH); Color graphBg = stringToColor(req.getParameter("graphBg")); Color plotBg = stringToColor(req.getParameter("plotBg")); if (graph==null) graph = createGraph(); graph.setBackgroundPaint(graphBg); Plot p = graph.getPlot(); p.setBackgroundPaint(plotBg); return graph.createBufferedImage(Integer.parseInt(w),Integer.parseInt(h),info); }
public CLineGraph(String title, int seriesNum, Color background) { super("", SwingConstants.CENTER); this.chartData = new LineData(title, true, 0.0, 30.0, 0.0, 100.0, seriesNum); this.chart = chartData.makeChart(); this.background = background == null ? DEFAULT_BACKGROUND : background; this.chart.setBackgroundPaint(this.background); this.chart.setBorderPaint(null); ImageIcon icon = new ImageIcon(chart.createBufferedImage(150, 100)); this.setLayout(null); this.setIcon(icon); this.setBounds(0, 0, 170, 130); }
/** * Generates a JFreeChart chart using a set of parameters * * @param params the chart parameters * @return the generated chart */ @Override public BufferedImage generateImage(ChartParameters params) { JFreeChart chart = new JFreeChart(null, TextTitle.DEFAULT_FONT, getPlot(params), hasLegend()); improveChart(chart, params); return chart.createBufferedImage(params.getWidth(), params.getHeight()); }