List of usage examples for org.jfree.chart ChartUtilities saveChartAsPNG
public static void saveChartAsPNG(File file, JFreeChart chart, int width, int height) throws IOException
From source file:uk.co.bssd.reporting.chart.PngChartWriter.java
@Override public void write(JFreeChart chart) { try {/*from w w w . j av a2 s . com*/ ChartUtilities.saveChartAsPNG(this.file, chart, this.width, this.height); } catch (IOException e) { throw new IllegalStateException("Unable to save chart", e); } }
From source file:ui.FitnessGraph.java
public FitnessGraph(final String title, ArrayList<Double> data) { super(title); JFreeChart chart = createChart(createDataset(data)); File imageFile = new File(ConfigFile.getInstance("config.txt").getString("outputFitness")); int width = 1280; int height = 960; try {// w w w . j ava 2 s. c o m ChartUtilities.saveChartAsPNG(imageFile, chart, width, height); // System.exit(0); } catch (IOException ex) { System.err.println(ex); } final ChartPanel panel = new ChartPanel(chart); panel.setPreferredSize(new java.awt.Dimension(1500, 800)); this.setContentPane(panel); }
From source file:SQLite3ToChart.Chart.java
private void chart(ToChartData toChartData, int Xaxis) { String titleChart = "Daily chart of TOPIX"; String timeAxisLabel = "2000 Year"; String valueAxisLabel = "point"; OHLCDataset oHLCDataset = toChartData.toChartData(); JFreeChart chart = ChartFactory.createCandlestickChart(titleChart, timeAxisLabel, valueAxisLabel, oHLCDataset, false);//from ww w. j a v a2s. c o m ChartPanel cpanel = new ChartPanel(chart); getContentPane().add(cpanel, BorderLayout.CENTER); File file = new File("./filename_" + Xaxis + ".png"); try { ChartUtilities.saveChartAsPNG(file, chart, Xaxis, 500); } catch (IOException ex) { String msg = "saveChartAsPNG() make Exception "; Logger.getLogger(Chart.class.getName()).log(Level.SEVERE, msg, ex); } }
From source file:com.github.brandtg.stl.StlPlotter.java
static void plot(final StlResult stlResult, final String title, final Class<?> timePeriod, final File save) throws IOException { final ResultsPlot plot = new ResultsPlot(stlResult, title, timePeriod); ChartUtilities.saveChartAsPNG(save, plot.chart, 800, 600); }
From source file:com.github.ruananswer.stl.StlPlotter.java
static void plot(final STLResult stlResult, double[] series, double[] times, final String title, final Class<?> timePeriod, final File save) throws IOException { final ResultsPlot plot = new ResultsPlot(stlResult, series, times, title, timePeriod); ChartUtilities.saveChartAsPNG(save, plot.chart, 800, 600); }
From source file:no.met.jtimeseries.meteogram.PngChartSaver.java
@Override public void save(File out, JFreeChart chart, int width, int height) throws IOException { if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); }// w w w . ja v a 2 s . com ChartUtilities.saveChartAsPNG(out, chart, width, height); }
From source file:pertchart.Histogram.java
public JFreeChart createHistorgram(double[] data) { HistogramDataset dataset = new HistogramDataset(); dataset.setType(HistogramType.RELATIVE_FREQUENCY); dataset.addSeries("Histogram", data, this.bins); String plotTitle = "Project Completion Times"; String xaxis = "Completion Times"; String yaxis = ""; PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = false; boolean urls = false; JFreeChart chart = ChartFactory.createHistogram(plotTitle, xaxis, yaxis, dataset, orientation, show, toolTips, urls);//from w w w . j av a 2s . co m int width = 500; int height = 300; try { ChartUtilities.saveChartAsPNG(new File("histogram.png"), chart, width, height); } catch (Exception e) { System.out.println(e); } return chart; }
From source file:ui.Graph.java
public Graph(final String title, ArrayList<Setpoint> data, ArrayList<Setpoint> traj, Gains gains) { super(title); this.gains = gains; JFreeChart chart = createChart(data, traj); File imageFile = new File(ConfigFile.getInstance("config.txt").getString("outputPng")); int width = 1280; int height = 960; try {/* ww w. j av a 2s . com*/ ChartUtilities.saveChartAsPNG(imageFile, chart, width, height); } catch (IOException ex) { System.err.println(ex); } final ChartPanel panel = new ChartPanel(chart); panel.setPreferredSize(new java.awt.Dimension(1500, 800)); this.setContentPane(panel); }
From source file:controle.JfreeChartController.java
@PostConstruct public void init() { try {/* w ww. jav a 2s. c o m*/ //Graphic Text BufferedImage bufferedImg = new BufferedImage(100, 25, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = bufferedImg.createGraphics(); g2.drawString("This is a text", 0, 10); ByteArrayOutputStream os = new ByteArrayOutputStream(); ImageIO.write(bufferedImg, "png", os); graphicText = new DefaultStreamedContent(new ByteArrayInputStream(os.toByteArray()), "image/png"); //Chart JFreeChart jfreechart = ChartFactory.createLineChart("cosseno", "X", "Y", createDataset()); File chartFile = new File("dynamichart"); ChartUtilities.saveChartAsPNG(chartFile, jfreechart, 800, 400); chart = new DefaultStreamedContent(new FileInputStream(chartFile), "image/png"); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.marmoush.jann.chart.ChartImage.java
public void createPNG() { try {//from w w w. j ava 2 s . c om File file = new File(path); ChartUtilities.saveChartAsPNG(file, chart, width, height); } catch (IOException e) { e.printStackTrace(); } }