Java Code Examples for org.jfree.chart.ChartFactory#createStackedXYAreaChart()

The following examples show how to use org.jfree.chart.ChartFactory#createStackedXYAreaChart() . 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: StackedXYAreaRenderer2Test.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Test chart drawing with an empty dataset to ensure that this special
 * case doesn't cause any exceptions.
 */
@Test
public void testDrawWithEmptyDataset() {
    boolean success = false;
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
            "y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL,
            true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYAreaRenderer2());
    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 2
Source File: StackedXYAreaRenderer2Test.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Test chart drawing with an empty dataset to ensure that this special
 * case doesn't cause any exceptions.
 */
@Test
public void testDrawWithEmptyDataset() {
    boolean success = false;
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
            "y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL,
            true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYAreaRenderer2());
    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: StackedXYBarRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
@Test
public void testFindDomainBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYBarRenderer());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.3));
    assertTrue(bounds.contains(0.5));
    assertTrue(bounds.contains(2.5));
    assertFalse(bounds.contains(2.8));
}
 
Example 4
Source File: StackedXYBarRendererTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
public void testFindDomainBounds() {
    TableXYDataset dataset
            = RendererXYPackageTests.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("Test Chart",
            "X", "Y", dataset, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYBarRenderer());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.3));
    assertTrue(bounds.contains(0.5));
    assertTrue(bounds.contains(2.5));
    assertFalse(bounds.contains(2.8));
}
 
Example 5
Source File: StackedXYAreaRenderer2Test.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test chart drawing with an empty dataset to ensure that this special
 * case doesn't cause any exceptions.
 */
@Test
public void testDrawWithEmptyDataset() {
    boolean success = false;
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
            "y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL,
            true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYAreaRenderer2());
    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 6
Source File: StackedXYBarRendererTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
@Test
public void testFindDomainBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYBarRenderer());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.3));
    assertTrue(bounds.contains(0.5));
    assertTrue(bounds.contains(2.5));
    assertFalse(bounds.contains(2.8));
}
 
Example 7
Source File: StackedXYAreaRenderer2Test.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));

    // try null argument
    assertNull(renderer.findRangeBounds(null));

    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
 
Example 8
Source File: StackedXYAreaRenderer2Tests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test chart drawing with an empty dataset to ensure that this special
 * case doesn't cause any exceptions.
 */
public void testDrawWithEmptyDataset() {
    boolean success = false;
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
            "y", new DefaultTableXYDataset(), true);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYAreaRenderer2());
    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 9
Source File: StackedXYBarRendererTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
public void testFindDomainBounds() {
    TableXYDataset dataset 
            = RendererXYPackageTests.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, 
            PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYBarRenderer());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.3));
    assertTrue(bounds.contains(0.5));
    assertTrue(bounds.contains(2.5));
    assertFalse(bounds.contains(2.8));
}
 
Example 10
Source File: StackedXYAreaRenderer2Test.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Test chart drawing with an empty dataset to ensure that this special
 * case doesn't cause any exceptions.
 */
@Test
public void testDrawWithEmptyDataset() {
    boolean success = false;
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
            "y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL,
            true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYAreaRenderer2());
    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: StackedXYAreaRenderer2Tests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
public void testFindRangeBounds() {
    TableXYDataset dataset 
            = RendererXYPackageTests.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, 
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));
    
    // try null argument
    assertNull(renderer.findRangeBounds(null));
    
    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
 
Example 12
Source File: StackedXYAreaRenderer2Test.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));

    // try null argument
    assertNull(renderer.findRangeBounds(null));

    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
 
Example 13
Source File: StackedXYAreaRenderer2Test.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
    plot.setRenderer(renderer);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));

    // try null argument
    assertNull(renderer.findRangeBounds(null));

    // try empty dataset
    assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
 
Example 14
Source File: StackedXYBarRendererTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYBarRenderer());
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));
}
 
Example 15
Source File: StackedXYAreaRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
public void testFindRangeBounds() {
    TableXYDataset dataset 
            = RendererXYPackageTests.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, 
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));
}
 
Example 16
Source File: StackedXYAreaRenderer2Tests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test chart drawing with an empty dataset to ensure that this special
 * case doesn't cause any exceptions.
 */
public void testDrawWithEmptyDataset() {
    boolean success = false;
    JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
            "y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL,
            true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYAreaRenderer2());
    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 17
Source File: StackedXYAreaRendererTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));
}
 
Example 18
Source File: StackedXYAreaRendererTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL,
            false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));
}
 
Example 19
Source File: StackedXYBarRendererTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYBarRenderer());
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));
}
 
Example 20
Source File: StackedXYBarRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that the renderer is calculating the range bounds correctly.
 */
@Test
public void testFindRangeBounds() {
    TableXYDataset dataset
            = RendererXYPackageUtils.createTestTableXYDataset();
    JFreeChart chart = ChartFactory.createStackedXYAreaChart(
            "Test Chart", "X", "Y", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRenderer(new StackedXYBarRenderer());
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    Range bounds = rangeAxis.getRange();
    assertTrue(bounds.contains(6.0));
    assertTrue(bounds.contains(8.0));
}