List of usage examples for org.jfree.chart JFreeChart JFreeChart
public JFreeChart(String title, Font titleFont, Plot plot, boolean createLegend)
From source file:graph.jfreecharts.GraphFunction.java
/** * A custom xyerror renderer because jfreecharts does not * have it supported in the api./*from ww w.j av a 2s. c o m*/ * @param title the graph title * @param xAxisLabel the xaxis title * @param yAxisLabel the yaxis title * @param dataset the xydataset * @param orientation the plot orientation * @param legend true to turn on legend * @param tooltips true to turn on tooltips (the pop up when right click) * @param urls // no idea what this is for * @return */ private static JFreeChart createXYIntervalChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); } NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYErrorRenderer renderer = new XYErrorRenderer(); renderer.setDrawXError(true); renderer.setDrawYError(true); xAxis.setNumberFormatOverride(new DecimalFormat("0.######E0")); yAxis.setNumberFormatOverride(new DecimalFormat("0.######E0")); xAxis.setAutoRangeIncludesZero(false); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(orientation); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
From source file:playground.anhorni.PLOC.analysis.RunsEnsembleBoxPlot.java
public JFreeChart createChart() { String title = chartTitle;// w w w. j a v a 2s .com final CategoryAxis xAxis = new CategoryAxis("Hour"); xAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10)); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); final NumberAxis yAxis = new NumberAxis("AverageDays_Expenditures"); yAxis.setAutoRangeIncludesZero(true); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setSeriesPaint(0, Color.blue); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false); return this.chart_; }
From source file:sernet.gs.ui.rcp.main.bsi.views.chart.ISRSpiderChart.java
protected JFreeChart createSpiderChart(Object dataset) { SpiderWebPlot plot = new SpiderWebPlot((CategoryDataset) dataset); plot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); plot.setSeriesPaint(0, new Color(0.0f, 1f, 0f, 1f)); // green plot.setSeriesPaint(1, new Color(1f, 1f, 0f, 1f)); // yellow plot.setSeriesPaint(2, new Color(1f, 0f, 0f, 1f)); // red plot.setSeriesPaint(3, new Color(0f, 0f, 0f, 1f)); // grey plot.setWebFilled(true);//from w w w . ja va 2s .co m JFreeChart chart = new JFreeChart(Messages.ISRSpiderChart_0, TextTitle.DEFAULT_FONT, plot, false); LegendTitle legend = new LegendTitle(plot); legend.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legend); return chart; }
From source file:ste.travian.world.WorldChart.java
/** * Create the JFreeChart world chart/*w w w.j a va2s .c o m*/ * * @param title world title * @param dataset world data set * */ private void createWorldPlot(String title, XYDataset dataset) { NumberAxis xAxis = new NumberAxis(LABEL_X_AXIS); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(LABEL_Y_AXIS); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); TileRenderer renderer = new TileRenderer(3, 3); renderer.setBaseToolTipGenerator(new TileToolTipGenerator()); plot.setRenderer(renderer); plot.setOrientation(PlotOrientation.VERTICAL); chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.jfree.chart.demo.SymbolicXYPlotDemo.java
/** * Creates a XY graph with symbolic value on X and Y axis. * /*from w w w . j av a 2s. c om*/ * @param title * the title. * @param xAxisLabel * the x axis label. * @param yAxisLabel * the y axis label. * @param data * the dataset. * @param legend * create a legend? * @return a chart. */ public static JFreeChart createXYSymbolicPlot(final String title, final String xAxisLabel, final String yAxisLabel, final XYDataset data, final boolean legend) { final SymbolicAxis xSymbolicAxis = new SymbolicAxis(xAxisLabel, ((XisSymbolic) data).getXSymbolicValues()); final SymbolicAxis ySymbolicAxis = new SymbolicAxis(yAxisLabel, ((YisSymbolic) data).getYSymbolicValues()); final XYPlot plot = new XYPlot(data, xSymbolicAxis, ySymbolicAxis, null); final XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, new SymbolicXYItemLabelGenerator()); plot.setRenderer(renderer); final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
From source file:unalcol.termites.boxplots.ECALAgentsRight.java
/** * Creates a new demo.//from w w w . j ava 2 s . c om * * @param title the frame title. * @param pf */ public ECALAgentsRight(final String title, ArrayList<Double> pf) { super(title); final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf); final CategoryAxis xAxis = new CategoryAxis(""); // final NumberAxis yAxis = new NumberAxis("Round number"); 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("Agents Right " + 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("ECALright" + pf + ".jpg"); ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 400, 400, null); } catch (FileNotFoundException ex) { Logger.getLogger(ECALAgentsRight.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ECALAgentsRight.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:edu.msu.cme.rdp.classifier.train.validation.distance.BoxPlotUtils.java
public static void createBoxplot(DefaultBoxAndWhiskerCategoryDataset scatterDataset, PrintStream outStream, String title, String xAxisLabel, String yAxisLabel, Font lableFont) throws IOException { CategoryAxis xAxis = new CategoryAxis(xAxisLabel); xAxis.setLabelFont(lableFont);//from w ww . j a v a 2 s .c o m NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setTickLabelFont(lableFont); yAxis.setAutoRangeIncludesZero(false); yAxis.setRange(0, 100); yAxis.setLabelFont(lableFont); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(true); renderer.setBaseLegendTextFont(lableFont); renderer.setStroke(new BasicStroke(5.0f)); CategoryPlot plot = new CategoryPlot(scatterDataset, xAxis, yAxis, renderer); JFreeChart boxchart = new JFreeChart(title, new Font("Helvetica", Font.BOLD, 40), plot, true); // higher scale factor gives higher resolution ChartUtilities.writeScaledChartAsPNG(outStream, boxchart, 800, 1000, 3, 3); }
From source file:unalcol.termites.boxplots.RoundNumber2.java
/** * Creates a new demo./*from w w w. j a va2s .c o m*/ * * @param title the frame title. * @param pf */ public RoundNumber2(final String title, ArrayList<Double> pf) { super(title); final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf); final CategoryAxis xAxis = new CategoryAxis(""); // final NumberAxis yAxis = new NumberAxis("Round number"); 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 Number " + 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("roundnumber2" + pf + ".jpg"); ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 300, 250, null); } catch (FileNotFoundException ex) { Logger.getLogger(RoundNumber2.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(RoundNumber2.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:unalcol.termites.boxplots.ECALRoundNumber.java
/** * Creates a new demo./* ww w . ja v a 2 s .c om*/ * * @param title the frame title. * @param pf */ public ECALRoundNumber(final String title, ArrayList<Double> pf) { super(title); final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf); final CategoryAxis xAxis = new CategoryAxis(""); // final NumberAxis yAxis = new NumberAxis("Round number"); 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 Number " + 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("ECALround" + pf + ".jpg"); ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 400, 400, null); } catch (FileNotFoundException ex) { Logger.getLogger(ECALRoundNumber.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ECALRoundNumber.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:playground.anhorni.PLOC.analysis.MultipleEnsemblesBoxPlot.java
public JFreeChart createChart() { String title = chartTitle;//from w ww .j a v a 2 s . co m final CategoryAxis xAxis = new CategoryAxis("Runs ensemble size"); xAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10)); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); final NumberAxis yAxis = new NumberAxis("AvgDaysRuns_OfEnsembleAverageOfTotalExpenditures"); yAxis.setAutoRangeIncludesZero(true); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setSeriesPaint(0, Color.blue); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false); return this.chart_; }