List of usage examples for org.jfree.chart JFreeChart createBufferedImage
public BufferedImage createBufferedImage(int imageWidth, int imageHeight, double drawWidth, double drawHeight, ChartRenderingInfo info)
From source file:org.jfree.chart.demo.MeterChartDemo4.java
public static void main(String args[]) { DefaultValueDataset defaultvaluedataset = new DefaultValueDataset(75D); MeterPlot meterplot = new MeterPlot(defaultvaluedataset); JFreeChart jfreechart = new JFreeChart("Scaled Image Test", meterplot); try {/*from www . j av a 2 s . co m*/ File file = new File("meterchart100.png"); BufferedOutputStream bufferedoutputstream = new BufferedOutputStream(new FileOutputStream(file)); java.awt.image.BufferedImage bufferedimage = jfreechart.createBufferedImage(200, 200, 400D, 400D, null); ChartUtilities.writeBufferedImageAsPNG(bufferedoutputstream, bufferedimage); } catch (IOException ioexception) { System.out.println(ioexception.toString()); } }
From source file:org.jfree.chart.demo.MeterChartDemo2.java
/** * Starting point for the demo./*from w w w .jav a 2 s . c om*/ * * @param args ignored. */ public static void main(final String[] args) { final ValueDataset dataset = new DefaultValueDataset(75.0); final MeterPlot plot = new MeterPlot(dataset); final JFreeChart chart = new JFreeChart("Scaled Image Test", plot); // **************************************************************************** // * JFREECHART DEVELOPER GUIDE * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final File file1 = new File("meterchart100.png"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file1)); final BufferedImage image = chart.createBufferedImage(200, 200, 400, 400, null); ChartUtilities.writeBufferedImageAsPNG(out, image); } catch (IOException e) { System.out.println(e.toString()); } }
From source file:org.jfree.chart.demo.ThumbnailDemo1.java
public static JPanel createDemoPanel() { JPanel jpanel = new JPanel(new GridLayout(2, 3)); JFreeChart jfreechart = createChart1(createDataset1()); ChartUtilities.applyCurrentTheme(jfreechart); java.awt.image.BufferedImage bufferedimage = jfreechart.createBufferedImage(120, 80, 360D, 240D, null); ImageIcon imageicon = new ImageIcon(bufferedimage); jpanel.add(new JButton(imageicon)); JFreeChart jfreechart1 = createChart2(createDataset2()); ChartUtilities.applyCurrentTheme(jfreechart1); java.awt.image.BufferedImage bufferedimage1 = jfreechart1.createBufferedImage(120, 80, 360D, 240D, null); ImageIcon imageicon1 = new ImageIcon(bufferedimage1); jpanel.add(new JButton(imageicon1)); JFreeChart jfreechart2 = createChart3(createDataset3()); ChartUtilities.applyCurrentTheme(jfreechart2); java.awt.image.BufferedImage bufferedimage2 = jfreechart2.createBufferedImage(120, 80, 360D, 240D, null); ImageIcon imageicon2 = new ImageIcon(bufferedimage2); jpanel.add(new JButton(imageicon2)); JFreeChart jfreechart3 = createChart4(createDataset4()); ChartUtilities.applyCurrentTheme(jfreechart3); java.awt.image.BufferedImage bufferedimage3 = jfreechart3.createBufferedImage(120, 80, 360D, 240D, null); ImageIcon imageicon3 = new ImageIcon(bufferedimage3); jpanel.add(new JButton(imageicon3)); JFreeChart jfreechart4 = createChart5(createDataset5()); ChartUtilities.applyCurrentTheme(jfreechart4); java.awt.image.BufferedImage bufferedimage4 = jfreechart4.createBufferedImage(120, 80, 360D, 240D, null); ImageIcon imageicon4 = new ImageIcon(bufferedimage4); jpanel.add(new JButton(imageicon4)); JFreeChart jfreechart5 = createChart6(createDataset6()); ChartUtilities.applyCurrentTheme(jfreechart5); java.awt.image.BufferedImage bufferedimage5 = jfreechart5.createBufferedImage(120, 80, 360D, 240D, null); ImageIcon imageicon5 = new ImageIcon(bufferedimage5); jpanel.add(new JButton(imageicon5)); return jpanel; }
From source file:uk.ac.lkl.cram.ui.wizard.TLAPropertiesWizardPanel.java
@Override public void readSettings(WizardDescriptor wiz) { // use wiz.getProperty to retrieve previous panel state JFreeChart chart = TLALearningTypeChartFactory.createChart(lineItem.getActivity()); BufferedImage image = chart.createBufferedImage(TLACreatorWizardIterator.LEFT_WIDTH, TLACreatorWizardIterator.LEFT_WIDTH, 300, 300, null); wiz.putProperty(WizardDescriptor.PROP_IMAGE, image); wiz.putProperty(WizardDescriptor.PROP_INFO_MESSAGE, getInfoMessage()); //Read the current activity and update the line item TLActivity activity = (TLActivity) wiz.getProperty(TLACreatorWizardIterator.PROP_ACTIVITY); if (lineItem.getActivity() != activity) { lineItem.setActivity(activity);/*from w w w . j a va 2s . c o m*/ } }
From source file:uk.ac.lkl.cram.ui.wizard.PredefinedWizardPanel.java
/** * Set the selected TLA for the wizard/*from ww w .j a v a2 s. c o m*/ * @param selectedValue a TLA that is now the activity of the line item */ private void setSelectedTLA(TLActivity selectedValue) { //set the value of the variable selectedTLA = selectedValue; //set the activity of the line item, if it's not null if (selectedTLA != null) { lineItem.setActivity(selectedTLA); } //Set the validity of this step of the wizard to be true if the TLA is not null setValid(selectedTLA != null); //Create an learning type image that describes the activity BufferedImage image = TLACreatorWizardIterator.EMPTY_IMAGE; if (selectedTLA != null) { JFreeChart chart = TLALearningTypeChartFactory.createChart(selectedTLA); image = chart.createBufferedImage(TLACreatorWizardIterator.LEFT_WIDTH, TLACreatorWizardIterator.LEFT_WIDTH, 300, 300, null); } wizardDesc.putProperty(WizardDescriptor.PROP_IMAGE, image); //Set the contents of the description of the TLA in the visual panel if (selectedTLA == null) { getComponent().setTLAInfo(""); } else { getComponent().setTLAInfo(getInfoMessage(selectedTLA)); } }