/** * Draws the chart with a <code>null</code> info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); dataset.add(1.0, 2.0, "S1", "C1"); dataset.add(3.0, 4.0, "S1", "C2"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new StatisticalBarRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); }
protected JFreeChart createLegend(CategoryDataset dataset) { // JFreeChart chart = ChartFactory.createAreaChart( JFreeChart chart = ChartFactory.createLineChart( chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setErrorIndicatorPaint(Color.black); renderer.setLegendItemLabelGenerator(new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT)); plot.setRenderer(renderer); return chart; }
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { StatisticalBarRenderer r1 = new StatisticalBarRenderer(); StatisticalBarRenderer r2 = new StatisticalBarRenderer(); assertEquals(r1, r2); r1.setErrorIndicatorPaint(Color.red); assertFalse(r1.equals(r2)); r2.setErrorIndicatorPaint(Color.red); assertTrue(r2.equals(r1)); r1.setErrorIndicatorStroke(new BasicStroke(1.5f)); assertFalse(r1.equals(r2)); r2.setErrorIndicatorStroke(new BasicStroke(1.5f)); assertTrue(r2.equals(r1)); }
/** * Draws the chart with a <code>null</code> mean value to make sure that * no exceptions are thrown (particularly by code in the renderer). See * bug report 1779941. */ public void testDrawWithNullMeanVertical() { boolean success = false; try { DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); dataset.add(1.0, 2.0, "S1", "C1"); dataset.add(null, new Double(4.0), "S1", "C2"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new StatisticalBarRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); }
/** * Draws the chart with a <code>null</code> mean value to make sure that * no exceptions are thrown (particularly by code in the renderer). See * bug report 1779941. */ public void testDrawWithNullMeanHorizontal() { boolean success = false; try { DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); dataset.add(1.0, 2.0, "S1", "C1"); dataset.add(null, new Double(4.0), "S1", "C2"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new StatisticalBarRenderer()); plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); }
/** * Draws the chart with a <code>null</code> standard deviation to make sure * that no exceptions are thrown (particularly by code in the renderer). * See bug report 1779941. */ public void testDrawWithNullDeviationVertical() { boolean success = false; try { DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); dataset.add(1.0, 2.0, "S1", "C1"); dataset.add(new Double(4.0), null, "S1", "C2"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new StatisticalBarRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); }
/** * Draws the chart with a <code>null</code> standard deviation to make sure * that no exceptions are thrown (particularly by code in the renderer). * See bug report 1779941. */ public void testDrawWithNullDeviationHorizontal() { boolean success = false; try { DefaultStatisticalCategoryDataset dataset = new DefaultStatisticalCategoryDataset(); dataset.add(1.0, 2.0, "S1", "C1"); dataset.add(new Double(4.0), null, "S1", "C2"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new StatisticalBarRenderer()); plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); }
@Override public JFreeChart getChart() throws IOException { final JFreeChart chart = ChartFactory.createLineChart("Time to reach uniform state", "Application State", "Time to reach state (s)", getDataset(), PlotOrientation.VERTICAL, false, false, false); final CategoryPlot category_plot = chart.getCategoryPlot(); category_plot.setRenderer(new StatisticalBarRenderer()); category_plot.getRangeAxis().setLowerBound(0); PlainChartTheme.applyTheme(chart); return chart; }
@Override public JFreeChart getChart() throws IOException { final DefaultStatisticalCategoryDataset dataset = getDataset(); final JFreeChart chart = ChartFactory.createLineChart(getName(), x_axis_label, "Time to reach " + name + " (s)", dataset, PlotOrientation.VERTICAL, showLegend, false, false); final StatisticalBarRenderer renderer = new StatisticalBarRenderer(); final CategoryPlot category_plot = chart.getCategoryPlot(); category_plot.setRenderer(renderer); final ValueAxis range_axis = category_plot.getRangeAxis(); range_axis.setLowerBound(0); PlainChartTheme.applyTheme(chart); return chart; }
@Override public JFreeChart getChart() throws IOException { final DefaultStatisticalCategoryDataset dataset = getDataset(); final JFreeChart chart = ChartFactory.createLineChart(getName(), x_axis_label, y_axis_label, dataset, PlotOrientation.VERTICAL, getDataset().getRowCount() > 1, false, false); final StatisticalBarRenderer renderer = new StatisticalBarRenderer(); final CategoryPlot category_plot = chart.getCategoryPlot(); category_plot.setRenderer(renderer); final ValueAxis range_axis = category_plot.getRangeAxis(); range_axis.setLowerBound(0); PlainChartTheme.applyTheme(chart); return chart; }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { StatisticalBarRenderer r1 = new StatisticalBarRenderer(); StatisticalBarRenderer r2 = new StatisticalBarRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); }
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { StatisticalBarRenderer r1 = new StatisticalBarRenderer(); StatisticalBarRenderer r2 = new StatisticalBarRenderer(); assertEquals(r1, r2); r1.setErrorIndicatorPaint(Color.red); assertFalse(r1.equals(r2)); r2.setErrorIndicatorPaint(Color.red); assertTrue(r2.equals(r1)); }
/** * Applies the settings of this theme to the specified renderer. * * @param renderer the renderer ({@code null} not permitted). */ protected void applyToCategoryItemRenderer(CategoryItemRenderer renderer) { Args.nullNotPermitted(renderer, "renderer"); if (renderer instanceof AbstractRenderer) { applyToAbstractRenderer((AbstractRenderer) renderer); } renderer.setDefaultItemLabelFont(this.regularFont); renderer.setDefaultItemLabelPaint(this.itemLabelPaint); // now we handle some special cases - yes, UGLY code alert! // BarRenderer if (renderer instanceof BarRenderer) { BarRenderer br = (BarRenderer) renderer; br.setBarPainter(this.barPainter); br.setShadowVisible(this.shadowVisible); br.setShadowPaint(this.shadowPaint); } // StatisticalBarRenderer if (renderer instanceof StatisticalBarRenderer) { StatisticalBarRenderer sbr = (StatisticalBarRenderer) renderer; sbr.setErrorIndicatorPaint(this.errorIndicatorPaint); } // MinMaxCategoryRenderer if (renderer instanceof MinMaxCategoryRenderer) { MinMaxCategoryRenderer mmcr = (MinMaxCategoryRenderer) renderer; mmcr.setGroupPaint(this.errorIndicatorPaint); } }
protected JFreeChart createLegend(CategoryDataset dataset) { // JFreeChart chart = ChartFactory.createAreaChart( JFreeChart chart = ChartFactory.createLineChart( chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setErrorIndicatorPaint(Color.black); // renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); plot.setRenderer(renderer); // renderer.setDrawOutlines(true); // renderer.setUseFillPaint(true); // renderer.setFillPaint(Color.white); return chart; }
/** * Creates a sample chart. * * @param dataset a dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createLineChart( chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // customise the renderer... StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setErrorIndicatorPaint(Color.black); // renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); plot.setRenderer(renderer); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
/** * Creates a sample chart. * * @param dataset a dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createLineChart( chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // customise the renderer... StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setErrorIndicatorPaint(Color.black); renderer.setLegendItemLabelGenerator(new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT)); plot.setRenderer(renderer); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
/** * Creates a chart. * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... // create the chart... JFreeChart chart = ChartFactory.createLineChart( chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // customise the renderer... StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setErrorIndicatorPaint(Color.black); plot.setRenderer(renderer); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
private JFreeChart createCategoryBarStatChart(String title, String xLabel, String yLabel, CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createLineChart( title, // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // data orientation, // orientation true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // customise the renderer... StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setErrorIndicatorPaint(Color.black); // renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); plot.setRenderer(renderer); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
public static JPanel createStatisticBarChart(String title,String categoryX,String valueY,CategoryDataset dataset) { final CategoryAxis xAxis = new CategoryAxis(categoryX); 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"); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, new StatisticalBarRenderer()); JFreeChart statChart = new JFreeChart(title, new Font("Helvetica", Font.BOLD, 14), plot, true); ChartPanel panel = new ChartPanel(statChart); panel.setPreferredSize(new Dimension(700, 440)); return panel; }
private StatisticalBarRenderer cusomtizeStatisticalBarChart(JFreeChart chart) { customizeAxisMargin(chart); StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setItemMargin(ITEM_MARGIN); renderer.setDrawBarOutline(true); chart.removeLegend(); return renderer; }
/** * Problem that the equals(...) method distinguishes all fields. */ public void testEquals() { StatisticalBarRenderer r1 = new StatisticalBarRenderer(); StatisticalBarRenderer r2 = new StatisticalBarRenderer(); assertEquals(r1, r2); }
/** * Applies the settings of this theme to the specified renderer. * * @param renderer the renderer (<code>null</code> not permitted). */ protected void applyToCategoryItemRenderer(CategoryItemRenderer renderer) { ParamChecks.nullNotPermitted(renderer, "renderer"); if (renderer instanceof AbstractRenderer) { applyToAbstractRenderer((AbstractRenderer) renderer); } renderer.setBaseItemLabelFont(this.regularFont); renderer.setBaseItemLabelPaint(this.itemLabelPaint); // now we handle some special cases - yes, UGLY code alert! // BarRenderer if (renderer instanceof BarRenderer) { BarRenderer br = (BarRenderer) renderer; br.setBarPainter(this.barPainter); br.setShadowVisible(this.shadowVisible); br.setShadowPaint(this.shadowPaint); } // BarRenderer3D if (renderer instanceof BarRenderer3D) { BarRenderer3D br3d = (BarRenderer3D) renderer; br3d.setWallPaint(this.wallPaint); } // LineRenderer3D if (renderer instanceof LineRenderer3D) { LineRenderer3D lr3d = (LineRenderer3D) renderer; lr3d.setWallPaint(this.wallPaint); } // StatisticalBarRenderer if (renderer instanceof StatisticalBarRenderer) { StatisticalBarRenderer sbr = (StatisticalBarRenderer) renderer; sbr.setErrorIndicatorPaint(this.errorIndicatorPaint); } // MinMaxCategoryRenderer if (renderer instanceof MinMaxCategoryRenderer) { MinMaxCategoryRenderer mmcr = (MinMaxCategoryRenderer) renderer; mmcr.setGroupPaint(this.errorIndicatorPaint); } }
/** * Applies the settings of this theme to the specified renderer. * * @param renderer the renderer (<code>null</code> not permitted). */ protected void applyToCategoryItemRenderer(CategoryItemRenderer renderer) { if (renderer == null) { throw new IllegalArgumentException("Null 'renderer' argument."); } if (renderer instanceof AbstractRenderer) { applyToAbstractRenderer((AbstractRenderer) renderer); } renderer.setBaseItemLabelFont(this.regularFont); renderer.setBaseItemLabelPaint(this.itemLabelPaint); // now we handle some special cases - yes, UGLY code alert! // BarRenderer if (renderer instanceof BarRenderer) { BarRenderer br = (BarRenderer) renderer; br.setBarPainter(this.barPainter); br.setShadowVisible(this.shadowVisible); br.setShadowPaint(this.shadowPaint); } // BarRenderer3D if (renderer instanceof BarRenderer3D) { BarRenderer3D br3d = (BarRenderer3D) renderer; br3d.setWallPaint(this.wallPaint); } // LineRenderer3D if (renderer instanceof LineRenderer3D) { LineRenderer3D lr3d = (LineRenderer3D) renderer; lr3d.setWallPaint(this.wallPaint); } // StatisticalBarRenderer if (renderer instanceof StatisticalBarRenderer) { StatisticalBarRenderer sbr = (StatisticalBarRenderer) renderer; sbr.setErrorIndicatorPaint(this.errorIndicatorPaint); } // MinMaxCategoryRenderer if (renderer instanceof MinMaxCategoryRenderer) { MinMaxCategoryRenderer mmcr = (MinMaxCategoryRenderer) renderer; mmcr.setGroupPaint(this.errorIndicatorPaint); } }
/** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { StatisticalBarRenderer r1 = new StatisticalBarRenderer(); assertTrue(r1 instanceof PublicCloneable); }