List of usage examples for org.jfree.chart JFreeChart JFreeChart
public JFreeChart(String title, Font titleFont, Plot plot, boolean createLegend)
From source file:org.fhcrc.cpl.toolbox.gui.chart.PanelWithChart.java
protected void init(Plot plot) { _plot = plot;//from w w w .j a v a 2 s .co m if (_chart == null) init(new JFreeChart(null, null, _plot, showLegend)); else init(_chart); }
From source file:org.jfree.chart.demo.BoxAndWhiskerDemo.java
/** * Creates a new demo./* w w w . j ava 2 s. com*/ * * @param title the frame title. */ public BoxAndWhiskerDemo(final String title) { super(title); final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(); final CategoryAxis xAxis = new CategoryAxis("Type"); final NumberAxis yAxis = new NumberAxis("Value"); yAxis.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); final JFreeChart chart = new JFreeChart("Box-and-Whisker Demo", new Font("SansSerif", Font.BOLD, 14), plot, true); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(450, 270)); setContentPane(chartPanel); }
From source file:org.operamasks.faces.render.graph.CurveAreaChartRenderer.java
private JFreeChart createXYCurveAreaChart(XYDataset dataset, PlotOrientation orientation) { ValueAxis xAxis;/*from ww w .j a va 2 s .c o m*/ if (dataset instanceof TimeSeriesCollection) { xAxis = new DateAxis(); } else { xAxis = new NumberAxis(); ((NumberAxis) xAxis).setAutoRangeIncludesZero(false); } xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(); yAxis.setAutoRangeIncludesZero(false); XYCurveAndShapeRenderer renderer = new XYCurveAndShapeRenderer(true, false); renderer.setDrawArea(true); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); if (dataset.getSeriesCount() > 1) { plot.setForegroundAlpha(0.75f); } return new JFreeChart(null, null, plot, false); }
From source file:unalcol.termites.boxplots.BestAgentsRoundInfoCollected.java
/** * Creates a new demo./* w w w. ja va 2 s . c o m*/ * * @param title the frame title. * @param pf */ public BestAgentsRoundInfoCollected(final String title, ArrayList<Double> pf) { super(title); String sDirectorio = experimentsDir; Hashtable<String, List> info = new Hashtable(); /*for (String mode : aMode) { info.put(mode, new ArrayList()); }*/ createSampleDataset(pf, info); AddDataFailingExperiments(sDirectorio, pf, info); final BoxAndWhiskerCategoryDataset dataset = addDataSet(info); System.out.println("info" + info); final CategoryAxis xAxis = new CategoryAxis(""); //final NumberAxis yAxis = new NumberAxis("Information Collected"); final NumberAxis yAxis = new NumberAxis(""); yAxis.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); Font font = new Font("Dialog", Font.PLAIN, 13); xAxis.setTickLabelFont(font); yAxis.setTickLabelFont(font); yAxis.setLabelFont(font); final JFreeChart chart = new JFreeChart("Round of Best Agents " + getTitle(pf), new Font("SansSerif", Font.BOLD, 18), plot, true); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(650, 370)); setContentPane(chartPanel); TextTitle legendText = null; if (pf.size() == 1) { legendText = new TextTitle("Population Size"); } else { legendText = new TextTitle("Population Size - Probability of Failure"); } legendText.setFont(font); legendText.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legendText); chart.getLegend().setItemFont(font); FileOutputStream output; try { output = new FileOutputStream("BestAgentsRound" + pf + mazeMode + ".jpg"); ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 450, 350, null); } catch (FileNotFoundException ex) { Logger.getLogger(BestAgentsRoundInfoCollected.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(BestAgentsRoundInfoCollected.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.pentaho.plugin.jfreereport.reportcharts.XYBarChartExpression.java
protected static JFreeChart createTimeSeriesChart(final String title, final String timeAxisLabel, final String valueAxisLabel, final XYDataset dataset, final boolean legend, final boolean tooltips, final boolean urls, final boolean stacked) { final ValueAxis timeAxis = new DateAxis(timeAxisLabel); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02);//w w w . ja v a 2s . c o m final NumberAxis valueAxis = new NumberAxis(valueAxisLabel); valueAxis.setAutoRangeIncludesZero(false); // override default final XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); XYToolTipGenerator toolTipGenerator = null; if (tooltips) { toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); } XYURLGenerator urlGenerator = null; if (urls) { urlGenerator = new StandardXYURLGenerator(); } final XYBarRenderer renderer; if (stacked) { renderer = new StackedXYBarRenderer(); } else { renderer = new XYBarRenderer(); } renderer.setBaseToolTipGenerator(toolTipGenerator); renderer.setURLGenerator(urlGenerator); plot.setRenderer(renderer); return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); }
From source file:org.aksw.iguana.reborn.charts.datasets.StatisticalBarChartDemo.java
/** * Creates a new demo.//ww w.jav a 2s. co m * * @param title * the frame title. * @throws DocumentException * @throws FileNotFoundException */ public StatisticalBarChartDemo(final String title) throws FileNotFoundException, DocumentException { super(title); final StatisticalCategoryDataset dataset = createDataset(); final CategoryAxis xAxis = new CategoryAxis("Type"); xAxis.setLowerMargin(0.01d); // percentage of space before first bar xAxis.setUpperMargin(0.01d); // percentage of space after last bar xAxis.setCategoryMargin(0.05d); // percentage of space between // categories final ValueAxis yAxis = new NumberAxis("Value"); // define the plot final CategoryItemRenderer renderer = new StatisticalBarRenderer(); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); final JFreeChart chart = new JFreeChart("Statistical Bar Chart Demo", new Font("Helvetica", Font.BOLD, 14), plot, true); ChartUtilities2.saveChartAsPDF(new File("/home/raven/tmp/foo.pdf"), chart, 1000, 300); // chart.setBackgroundPaint(Color.white); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:tl.lib.dataCollection.gui.TimeSeriesChart.java
public TimeSeriesChart(_CollectionGUIScenario scenario, String label, String description, String labelAxisY) { super(null);//w w w.ja v a2s .co m this.sourceDescriptor = scenario.getSourceDescriptor(); this.collection = new XYSeriesCollection(); // ChartTheme currentTheme = new StandardChartTheme("JFree"); ValueAxis timeAxis = new DateAxis("Time"); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02); NumberAxis valueAxis = new NumberAxis(labelAxisY); valueAxis.setAutoRangeIncludesZero(false); // override default XYToolTipGenerator toolTipGenerator = null; toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); // XYURLGenerator urlGenerator = new StandardXYURLGenerator(); renderer.setBaseToolTipGenerator(toolTipGenerator); // renderer.setURLGenerator(urlGenerator); this.plot = new XYPlot(collection, timeAxis, valueAxis, renderer); this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true); // currentTheme.apply(chart); renderingInfo = new ChartRenderingInfo(); this.scenario = scenario; this.description = description; this.label = label; this.selected = new Vector<SourceId>(); default_all = true; super.setChart(chart); }
From source file:tl.lib.dataCollection.gui.NumXYChart.java
public NumXYChart(_CollectionGUIScenario scenario, String label, String description, String labelAxisY) { super(null);/*from www.ja v a 2s . co m*/ this.sourceDescriptor = scenario.getSourceDescriptor(); this.collection = new XYSeriesCollection(); // ChartTheme currentTheme = new StandardChartTheme("JFree"); NumberAxis valueAxisX = new NumberAxis("Sample Number"); valueAxisX.setAutoRangeIncludesZero(false); // override default NumberAxis valueAxisY = new NumberAxis(labelAxisY); valueAxisY.setAutoRangeIncludesZero(false); // override default XYToolTipGenerator toolTipGenerator = null; toolTipGenerator = new StandardXYToolTipGenerator(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); // XYURLGenerator urlGenerator = new StandardXYURLGenerator(); renderer.setBaseToolTipGenerator(toolTipGenerator); // renderer.setURLGenerator(urlGenerator); this.plot = new XYPlot(collection, valueAxisX, valueAxisY, renderer); this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true); // currentTheme.apply(chart); renderingInfo = new ChartRenderingInfo(); this.scenario = scenario; this.description = description; this.label = label; this.selected = new Vector<SourceId>(); default_all = true; super.setChart(chart); }
From source file:unalcol.termites.boxplots.BestAgentsPercentageInfoCollected.java
/** * Creates a new demo.//from ww w . jav a 2 s.c o m * * @param title the frame title. * @param pf */ public BestAgentsPercentageInfoCollected(final String title, ArrayList<Double> pf) { super(title); String sDirectorio = experimentsDir; Hashtable<String, List> info = new Hashtable(); //String[] aMode = {"levywalk", "lwphevap", "hybrid", "hybrid3", "hybrid4"}; /*for (String mode : aMode) { info.put(mode, new ArrayList()); }*/ createSampleDataset(pf, info); AddDataFailingExperiments(sDirectorio, pf, info); final BoxAndWhiskerCategoryDataset dataset = addDataSet(info); final CategoryAxis xAxis = new CategoryAxis(""); //final NumberAxis yAxis = new NumberAxis("Information Collected"); final NumberAxis yAxis = new NumberAxis(""); yAxis.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); Font font = new Font("Dialog", Font.PLAIN, 13); xAxis.setTickLabelFont(font); yAxis.setTickLabelFont(font); yAxis.setLabelFont(font); final JFreeChart chart = new JFreeChart("Information Collected " + getTitle(pf), new Font("SansSerif", Font.BOLD, 18), plot, true); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(650, 370)); setContentPane(chartPanel); TextTitle legendText = null; if (pf.size() == 1) { legendText = new TextTitle("Population Size"); } else { legendText = new TextTitle("Population Size - Probability of Failure"); } legendText.setFont(font); legendText.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legendText); chart.getLegend().setItemFont(font); FileOutputStream output; try { output = new FileOutputStream("BestAgentsPercentageInfoCollected" + pf + mazeMode + ".jpg"); ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 350, 350, null); } catch (FileNotFoundException ex) { Logger.getLogger(BestAgentsPercentageInfoCollected.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(BestAgentsPercentageInfoCollected.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.perfmon4j.visualvm.chart.DynamicTimeSeriesChart.java
public DynamicTimeSeriesChart(int maxAgeInSeconds) { super(new BorderLayout()); this.maxAgeInSeconds = maxAgeInSeconds; dataset = new TimeSeriesCollection(); renderer = new MyXYRenderer(); renderer.setBaseStroke(NORMAL_STROKE); NumberAxis numberAxis = new NumberAxis(); numberAxis.setAutoRange(false);/*from w ww . j a v a 2s . c o m*/ numberAxis.setRange(new Range(0d, 100d)); DateAxis dateAxis = new DateAxis(); dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); dateAxis.setAutoRange(true); dateAxis.setFixedAutoRange(maxAgeInSeconds * 1000); dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.SECOND, 30)); XYPlot plot = new XYPlot(dataset, dateAxis, numberAxis, renderer); JFreeChart chart = new JFreeChart(null, null, plot, false); chart.setBackgroundPaint(Color.white); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); chartPanel.setPopupMenu(null); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1), BorderFactory.createLineBorder(Color.black))); add(chartPanel); }