Java Code Examples for org.jfree.chart.JFreeChart#draw()
The following examples show how to use
org.jfree.chart.JFreeChart#draw() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CombinedRangeXYPlotTest.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Check that only one chart change event is generated by a change to a * subplot. */ @Test public void testNotification() { CombinedRangeXYPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); XYPlot subplot1 = (XYPlot) plot.getSubplots().get(0); NumberAxis xAxis = (NumberAxis) subplot1.getDomainAxis(); xAxis.setAutoRangeIncludesZero(!xAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); }
Example 2
Source File: PiePlot3DTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Draws a pie chart where the label generator returns null. */ @Test public void testDrawWithNullDataset() { JFreeChart chart = ChartFactory.createPieChart3D("Test", null, true, false, false); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); }
Example 3
Source File: MeterChartTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Draws the chart with a single range. At one point, this caused a null * pointer exception (fixed now). */ public void testDrawWithNullInfo() { boolean success = false; MeterPlot plot = new MeterPlot(new DefaultValueDataset(60.0)); plot.addInterval(new MeterInterval("Normal", new Range(0.0, 80.0))); JFreeChart chart = new JFreeChart(plot); try { BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); }
Example 4
Source File: CombinedDomainCategoryPlotTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Check that only one chart change event is generated by a change to a * subplot. */ @Test public void testNotification() { CombinedDomainCategoryPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); CategoryPlot subplot1 = (CategoryPlot) plot.getSubplots().get(0); NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); }
Example 5
Source File: XYPlotTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * A test for drawing a plot where a series has zero items. With * JFreeChart 1.0.5+cvs this was throwing an exception at one point. */ @Test public void testDrawSeriesWithZeroItems() { DefaultXYDataset dataset = new DefaultXYDataset(); dataset.addSeries("Series 1", new double[][] {{1.0, 2.0}, {3.0, 4.0}}); dataset.addSeries("Series 2", new double[][] {{}, {}}); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false); try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); } catch (Exception e) { fail("No exception should be thrown."); } }
Example 6
Source File: CombinedRangeCategoryPlotTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Check that only one chart change event is generated by a change to a * subplot. */ @Test public void testNotification() { CombinedRangeCategoryPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); CategoryPlot subplot1 = (CategoryPlot) plot.getSubplots().get(0); NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); }
Example 7
Source File: CombinedRangeXYPlotTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Check that only one chart change event is generated by a change to a * subplot. */ @Test public void testNotification() { CombinedRangeXYPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); XYPlot subplot1 = (XYPlot) plot.getSubplots().get(0); NumberAxis xAxis = (NumberAxis) subplot1.getDomainAxis(); xAxis.setAutoRangeIncludesZero(!xAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); }
Example 8
Source File: ROCChartPlotter.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
public void paintDeviationChart(Graphics graphics, int width, int height) { prepareData(); JFreeChart chart = createChart(this.dataset); // set the background color for the chart... chart.setBackgroundPaint(Color.white); // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); } Rectangle2D drawRect = new Rectangle2D.Double(0, 0, width, height); chart.draw((Graphics2D) graphics, drawRect); }
Example 9
Source File: CombinedRangeXYPlotTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Check that only one chart change event is generated by a change to a * subplot. */ @Test public void testNotification() { CombinedRangeXYPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); XYPlot subplot1 = (XYPlot) plot.getSubplots().get(0); NumberAxis xAxis = (NumberAxis) subplot1.getDomainAxis(); xAxis.setAutoRangeIncludesZero(!xAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); }
Example 10
Source File: SpiderWebPlotTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Draws the chart with a null info object to make sure that no exceptions * are thrown. */ public void testDrawWithNullInfo() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(35.0, "S1", "C1"); dataset.addValue(45.0, "S1", "C2"); dataset.addValue(55.0, "S1", "C3"); dataset.addValue(15.0, "S1", "C4"); dataset.addValue(25.0, "S1", "C5"); SpiderWebPlot plot = new SpiderWebPlot(dataset); JFreeChart chart = new JFreeChart(plot); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); }
Example 11
Source File: CombinedRangeCategoryPlotTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Check that only one chart change event is generated by a change to a * subplot. */ @Test public void testNotification() { CombinedRangeCategoryPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); CategoryPlot subplot1 = (CategoryPlot) plot.getSubplots().get(0); NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); }
Example 12
Source File: CombinedDomainCategoryPlotTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Check that only one chart change event is generated by a change to a * subplot. */ @Test public void testNotification() { CombinedDomainCategoryPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); CategoryPlot subplot1 = (CategoryPlot) plot.getSubplots().get(0); NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); }
Example 13
Source File: XYBoxAndWhiskerRendererTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * A test for bug report 2909215. */ @Test public void test2909215() { DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset( "Series"); d1.add(new Date(1L), new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), new Double(3.0), new Double(4.0), new Double(5.0), new Double(6.0), null, null, null)); JFreeChart chart = ChartFactory.createBoxAndWhiskerChart("Title", "X", "Y", d1, true); try { BufferedImage image = new BufferedImage(400, 200, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 400, 200), null, null); g2.dispose(); } catch (Exception e) { fail("No exception should be thrown."); } }
Example 14
Source File: PiePlot3DTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Draws a pie chart where the label generator returns null. */ public void testDrawWithNullDataset() { JFreeChart chart = ChartFactory.createPieChart3D("Test", null, true, false, false); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); }
Example 15
Source File: CombinedDomainCategoryPlotTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Check that only one chart change event is generated by a change to a * subplot. */ public void testNotification() { CombinedDomainCategoryPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); CategoryPlot subplot1 = (CategoryPlot) plot.getSubplots().get(0); NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); }
Example 16
Source File: XYPlotTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * A test for drawing a plot where a series has zero items. With * JFreeChart 1.0.5+cvs this was throwing an exception at one point. */ @Test public void testDrawSeriesWithZeroItems() { DefaultXYDataset dataset = new DefaultXYDataset(); dataset.addSeries("Series 1", new double[][] {{1.0, 2.0}, {3.0, 4.0}}); dataset.addSeries("Series 2", new double[][] {{}, {}}); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false); try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); } catch (Exception e) { fail("No exception should be thrown."); } }
Example 17
Source File: XYPlotTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * A test for drawing a plot where a series has zero items. With * JFreeChart 1.0.5+cvs this was throwing an exception at one point. */ public void testDrawSeriesWithZeroItems() { DefaultXYDataset dataset = new DefaultXYDataset(); dataset.addSeries("Series 1", new double[][] {{1.0, 2.0}, {3.0, 4.0}}); dataset.addSeries("Series 2", new double[][] {{}, {}}); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, true); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { e.printStackTrace(); success = false; } assertTrue(success); }
Example 18
Source File: XYPlotTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A test for bug 1654215 (where a renderer is added to the plot without * a corresponding dataset and it throws an exception at drawing time). */ public void test1654215() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, true); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(1, new XYLineAndShapeRenderer()); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { e.printStackTrace(); success = false; } assertTrue(success); }
Example 19
Source File: BoxAndWhiskerRendererTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * A check for bug 1572478 (for the vertical orientation). */ public void testBug1572478Vertical() { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset() { public Number getQ1Value(int row, int column) { return null; } public Number getQ1Value(Comparable rowKey, Comparable columnKey) { return null; } }; List values = new ArrayList(); values.add(new Double(1.0)); values.add(new Double(10.0)); values.add(new Double(100.0)); dataset.add(values, "row", "column"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), new NumberAxis("y"), new BoxAndWhiskerRenderer()); JFreeChart chart = new JFreeChart(plot); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); BufferedImageRenderingSource birs = new BufferedImageRenderingSource(image); ChartRenderingInfo info = new ChartRenderingInfo(); info.setRenderingSource(birs); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); }
Example 20
Source File: BoxAndWhiskerRendererTest.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * A check for bug 1572478 (for the vertical orientation). */ @Test public void testBug1572478Vertical() { DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset() { @Override public Number getQ1Value(int row, int column) { return null; } @Override public Number getQ1Value(Comparable rowKey, Comparable columnKey) { return null; } }; List values = new ArrayList(); values.add(new Double(1.0)); values.add(new Double(10.0)); values.add(new Double(100.0)); dataset.add(values, "row", "column"); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), new NumberAxis("y"), new BoxAndWhiskerRenderer()); JFreeChart chart = new JFreeChart(plot); boolean success; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, new ChartRenderingInfo()); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); }