List of usage examples for org.jfree.chart JFreeChart JFreeChart
public JFreeChart(String title, Font titleFont, Plot plot, boolean createLegend)
From source file:org.jfree.chart.demo.StatisticalBarChartDemo.java
/** * Creates a new demo./*from w w w.j av a2 s . c o m*/ * * @param title the frame title. */ public StatisticalBarChartDemo(final String title) { 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); //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:org.jtotus.gui.graph.GraphPrinter.java
private JFreeChart createChart(String title) { // valueAxis.setAutoRangeMinimumSize(1); DateAxis domain = new DateAxis("Date"); domain.setDateFormatOverride(new SimpleDateFormat("dd-MM-yyyy")); mainPlot = new CombinedDomainXYPlot(domain); mainPlot.setGap(4.0);/*from www .j ava2s . c o m*/ //mainPlot.setOrientation(PlotOrientation.HORIZONTAL); mainPlot.setBackgroundPaint(Color.lightGray); mainPlot.setRangePannable(true); mainPlot.setDomainGridlinesVisible(true); mainPlot.setOutlineVisible(true); mainPlot.setDomainCrosshairVisible(true); mainPlot.setRangeMinorGridlinesVisible(true); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true); chart.setBackgroundPaint(Color.white); return chart; }
From source file:com.idealista.solrmeter.view.statistic.QueryTimeHistoryPanel.java
/** * Creates and initializes the chart panel. *//*w ww. j a v a 2s . co m*/ public ChartPanel createChartPanel() { XYBarDataset barDataset = new XYBarDataset(dataset, BAR_WIDTH); NumberAxis xaxis = new NumberAxis(I18n.get("statistic.queryTimeHistoryPanel.time")); NumberAxis yaxis = new NumberAxis(I18n.get("statistic.queryTimeHistoryPanel.averageQueryTime")); xaxis.setStandardTickUnits( new ChartUtils.LowerBoundedTickUnitSource(xaxis.getStandardTickUnits(), LOWER_TICK_UNIT)); XYPlot plot = new XYPlot(barDataset, xaxis, yaxis, new XYBarRenderer()); JFreeChart chart = new JFreeChart(I18n.get("statistic.queryTimeHistoryPanel.queryHistory"), null, plot, false); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(CHART_BORDER); chartPanel.setMinimumDrawHeight(0); chartPanel.setMinimumDrawWidth(0); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); return chartPanel; }
From source file:net.sf.profiler4j.console.MemoryPlotPanel.java
public MemoryPlotPanel(int maxAge, String title) { super(new BorderLayout()); totalSeries = new TimeSeries("Committed Memory", Millisecond.class); totalSeries.setMaximumItemAge(maxAge); usedSeries = new TimeSeries("Used Memory", Millisecond.class); usedSeries.setMaximumItemAge(maxAge); TimeSeriesCollection seriesCollection = new TimeSeriesCollection(); seriesCollection.addSeries(totalSeries); seriesCollection.addSeries(usedSeries); NumberAxis numberAxis = new NumberAxis("Memory (KB)"); numberAxis.setLabelFont(new Font("SansSerif", 0, 14)); numberAxis.setTickLabelFont(new Font("SansSerif", 0, 12)); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); DateAxis dateAxis = new DateAxis("Time"); dateAxis.setTickLabelFont(new Font("SansSerif", 0, 12)); dateAxis.setLabelFont(new Font("SansSerif", 0, 14)); dateAxis.setAutoRange(true);// w w w .jav a 2s. c om dateAxis.setLowerMargin(0); dateAxis.setUpperMargin(0); dateAxis.setTickLabelsVisible(true); dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false); lineRenderer.setSeriesPaint(0, Color.RED); lineRenderer.setSeriesPaint(1, Color.GREEN.darker()); lineRenderer.setStroke(new BasicStroke(2F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); XYPlot xyplot = new XYPlot(seriesCollection, dateAxis, numberAxis, lineRenderer); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY); xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); JFreeChart chart = new JFreeChart(title, new Font("SansSerif", Font.PLAIN, 14), xyplot, true); chart.setBackgroundPaint(Color.white); ChartPanel panel = new ChartPanel(chart); panel.setBorder(createCompoundBorder(createEmptyBorder(8, 8, 8, 8), createLineBorder(Color.LIGHT_GRAY))); add(panel); setBorder(createEmptyBorder(8, 8, 8, 8)); }
From source file:unalcol.termites.boxplots.ECALMessages.java
/** * Creates a new demo.//from ww w .j av a 2 s . c o m * * @param title the frame title. * @param pf */ public ECALMessages(final String title, ArrayList<Double> pf) { super(title); final CategoryAxis xAxis = new CategoryAxis(""); //final NumberAxis yAxis = new NumberAxis("Messages Sent"); final NumberAxis yAxis = new NumberAxis(""); yAxis.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf, renderer); 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("Messages Sent " + 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.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legendText); LegendTitle legend = chart.getLegend(); legend.setPadding(new RectangleInsets(UnitType.RELATIVE, 0, 0.1, 0, 0)); FileOutputStream output; try { output = new FileOutputStream("messagesECAL" + pf + ".jpg"); ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 670, 250, null); } catch (FileNotFoundException ex) { Logger.getLogger(ECALMessages.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ECALMessages.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:unalcol.termites.boxplots.MessagesSent2.java
/** * Creates a new demo.//from ww w. ja va 2 s. c o m * * @param title the frame title. * @param pf */ public MessagesSent2(final String title, ArrayList<Double> pf) { super(title); final CategoryAxis xAxis = new CategoryAxis(""); //final NumberAxis yAxis = new NumberAxis("Messages Sent"); final NumberAxis yAxis = new NumberAxis(""); yAxis.setAutoRangeIncludesZero(false); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); final BoxAndWhiskerCategoryDataset dataset = createSampleDataset(pf, renderer); 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("Messages Sent " + 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.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legendText); LegendTitle legend = chart.getLegend(); legend.setPadding(new RectangleInsets(UnitType.RELATIVE, 0, 0.1, 0, 0)); FileOutputStream output; try { output = new FileOutputStream("messagesnumber2" + pf + ".jpg"); ChartUtilities.writeChartAsJPEG(output, 1.0f, chart, 670, 250, null); } catch (FileNotFoundException ex) { Logger.getLogger(MessagesSent2.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(MessagesSent2.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:no.uio.medicine.virsurveillance.charts.BoxAndWhiskerChart_AWT.java
/** * Creates a new demo.// w w w . j ava2s. co m * * @param applicationTitle * @param chartTitle * @param xTitle * @param yTitle * @param dataPoints * @param categories * @param seriesTitles */ public BoxAndWhiskerChart_AWT(String applicationTitle, String chartTitle, String xTitle, String yTitle, ArrayList<ArrayList<ArrayList<Float>>> dataPoints, ArrayList<ArrayList<String>> categories, ArrayList<String> seriesTitles) { super(applicationTitle); this.dataPoints = dataPoints; this.categories = categories; this.seriesTitles = seriesTitles; this.chartTitle = chartTitle; this.xAxisTitle = xTitle; this.yAxisTitle = yTitle; this.Title = applicationTitle; BoxAndWhiskerCategoryDataset dataset = (BoxAndWhiskerCategoryDataset) createDataset(this.dataPoints, this.categories, this.seriesTitles); final CategoryAxis xAxis = new CategoryAxis(this.xAxisTitle); final NumberAxis yAxis = new NumberAxis(this.yAxisTitle); yAxis.setAutoRangeIncludesZero(false); this.renderer = new BoxAndWhiskerRenderer(); this.renderer.setFillBox(false); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); this.plot = new CategoryPlot(dataset, xAxis, yAxis, this.renderer); final JFreeChart chart = new JFreeChart(this.chartTitle, new Font("SansSerif", Font.BOLD, 14), this.plot, true); chart.setBackgroundPaint(Color.white); this.chartPanel = new ChartPanel(chart); this.chartPanel.setBackground(Color.white); this.chartPanel.setPreferredSize(new java.awt.Dimension(800, 500)); setContentPane(this.chartPanel); this.setDefaultCloseOperation(HIDE_ON_CLOSE); }
From source file:de.iteratec.visualizationmodel.jfreechart.ChartFactory.java
public JFreeChart createXYStepChart(XYDataset dataset) { XYToolTipGenerator toolTipGenerator = !showTooltips ? null : new StandardXYToolTipGenerator(); XYURLGenerator urlGenerator = !showUrls ? null : new StandardXYURLGenerator(); XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, urlGenerator); XYPlot plot = new XYPlot(dataset, (ValueAxis) xAxis, (ValueAxis) yAxis, null); plot.setRenderer(renderer);//from www .ja va2s . c om plot.setOrientation(orientation); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.getRenderer().setSeriesStroke(0, new BasicStroke(5.0f)); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend); THEME.apply(chart); return chart; }
From source file:playground.anhorni.surprice.analysis.SupriceBoxPlot.java
public JFreeChart createChart() { String title = chartTitle;//from www . j av a 2s.co m final CategoryAxis xAxis = new CategoryAxis(this.xAxisName); xAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10)); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); final NumberAxis yAxis = new NumberAxis(this.yAxisName); yAxis.setAutoRangeIncludesZero(true); if (Math.abs(yrangeLower - yrangeUpper) > Double.MIN_VALUE) { yAxis.setRange(yrangeLower, yrangeUpper); } 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:smellminer.engine.JFreeChartDemo.java
/** * Creates a new demo.//from w w w . j a v a 2s . c o m * * @param title the frame title. */ public JFreeChartDemo(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); }