org.jfree.data.xy.DefaultTableXYDataset Java Examples

The following examples show how to use org.jfree.data.xy.DefaultTableXYDataset. 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 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 #2
Source File: DefaultTableXYDatasetTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    DefaultTableXYDataset d1 = new DefaultTableXYDataset();
    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.1);
    s1.add(2.0, 2.2);
    d1.addSeries(s1);

    DefaultTableXYDataset d2 = new DefaultTableXYDataset();
    XYSeries s2 = new XYSeries("Series 1", true, false);
    s2.add(1.0, 1.1);
    s2.add(2.0, 2.2);
    d2.addSeries(s2);

    assertTrue(d1.equals(d2));
    assertTrue(d2.equals(d1));

    s1.add(3.0, 3.3);
    assertFalse(d1.equals(d2));

    s2.add(3.0, 3.3);
    assertTrue(d1.equals(d2));

}
 
Example #3
Source File: TableXYDatasetTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests the auto-pruning feature.
 */
public void testAutoPrune() {

    // WITH AUTOPRUNING
    DefaultTableXYDataset dataset = new DefaultTableXYDataset(true);
    dataset.addSeries(createSeriesA());
    assertEquals(2, dataset.getItemCount());  // should be 2 items
    dataset.addSeries(createSeriesB());
    assertEquals(2, dataset.getItemCount());  // still 2
    dataset.removeSeries(1);
    assertEquals(1, dataset.getItemCount());  // 1 value pruned.

    // WITHOUT AUTOPRUNING
    DefaultTableXYDataset dataset2 = new DefaultTableXYDataset(true);
    dataset2.addSeries(createSeriesA());
    assertEquals(2, dataset2.getItemCount());  // should be 2 items
    dataset2.addSeries(createSeriesB());
    assertEquals(2, dataset2.getItemCount());  // still 2
    dataset2.removeSeries(1);
    assertEquals(1, dataset2.getItemCount());  // still 2.

}
 
Example #4
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a sample dataset for testing purposes.
 * 
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();
    
    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);
    
    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);
    
    return dataset;  
}
 
Example #5
Source File: TableXYDatasetTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests the auto-pruning feature.
 */
public void testAutoPrune() {
    
    // WITH AUTOPRUNING
    DefaultTableXYDataset dataset = new DefaultTableXYDataset(true);
    dataset.addSeries(createSeriesA());
    assertEquals(2, dataset.getItemCount());  // should be 2 items
    dataset.addSeries(createSeriesB());
    assertEquals(2, dataset.getItemCount());  // still 2
    dataset.removeSeries(1);
    assertEquals(1, dataset.getItemCount());  // 1 value pruned.

    // WITHOUT AUTOPRUNING
    DefaultTableXYDataset dataset2 = new DefaultTableXYDataset(true);
    dataset2.addSeries(createSeriesA());
    assertEquals(2, dataset2.getItemCount());  // should be 2 items
    dataset2.addSeries(createSeriesB());
    assertEquals(2, dataset2.getItemCount());  // still 2
    dataset2.removeSeries(1);
    assertEquals(1, dataset2.getItemCount());  // still 2.
    
}
 
Example #6
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 #7
Source File: DatasetUtilitiesTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a sample dataset for testing purposes.
 *
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);

    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);

    return dataset;
}
 
Example #8
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 #9
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 #10
Source File: DatasetUtilitiesTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a sample dataset for testing purposes.
 *
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);

    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);

    return dataset;
}
 
Example #11
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 #12
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 #13
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 #14
Source File: DefaultTableXYDatasetTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    
    DefaultTableXYDataset d1 = new DefaultTableXYDataset();
    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.1);
    s1.add(2.0, 2.2);
    d1.addSeries(s1);
    
    DefaultTableXYDataset d2 = new DefaultTableXYDataset();
    XYSeries s2 = new XYSeries("Series 1", true, false);
    s2.add(1.0, 1.1);
    s2.add(2.0, 2.2);
    d2.addSeries(s2);
    
    assertTrue(d1.equals(d2));
    assertTrue(d2.equals(d1));

    s1.add(3.0, 3.3);
    assertFalse(d1.equals(d2));

    s2.add(3.0, 3.3);
    assertTrue(d1.equals(d2));

}
 
Example #15
Source File: DatasetUtilitiesTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a sample dataset for testing purposes.
 *
 * @return A sample dataset.
 */
private TableXYDataset createTableXYDataset1() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    XYSeries s1 = new XYSeries("Series 1", true, false);
    s1.add(1.0, 1.0);
    s1.add(2.0, 2.0);
    dataset.addSeries(s1);

    XYSeries s2 = new XYSeries("Series 2", true, false);
    s2.add(1.0, -2.0);
    s2.add(2.0, -1.0);
    dataset.addSeries(s2);

    return dataset;
}
 
Example #16
Source File: StackedXYAreaRenderer2Test.java    From ECG-Viewer with GNU General Public License v2.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 #17
Source File: XYStepAreaRendererTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the chart with a <code>null</code> info object to make sure that
 * no exceptions are thrown (particularly by code in the renderer).
 */
@Test
public void testDrawWithNullInfo() {
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();

        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);

        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset,
                new NumberAxis("X"), new NumberAxis("Y"),
                new XYStepAreaRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
    }
    catch (NullPointerException e) {
        fail("No exception should be thrown.");
    }
}
 
Example #18
Source File: XYStepRendererTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws the chart with a <code>null</code> info object to make sure that
 * no exceptions are thrown (particularly by code in the renderer).
 */
@Test
public void testDrawWithNullInfo() {
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();

        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);

        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset,
                new NumberAxis("X"), new NumberAxis("Y"),
                new XYStepRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
    }
    catch (NullPointerException e) {
        fail("No exception should be thrown.");
    }
}
 
Example #19
Source File: XYTitleAnnotationTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws the chart with a <code>null</code> info object to make sure that 
 * no exceptions are thrown.
 */
@Test
public void testDrawWithNullInfo() {
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();
    
        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);
    
        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset, 
                new NumberAxis("X"), new NumberAxis("Y"), 
                new XYLineAndShapeRenderer());
        plot.addAnnotation(new XYTitleAnnotation(5.0, 6.0, 
                new TextTitle("Hello World!")));
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
    }
    catch (NullPointerException e) {
        fail("There should be no exception.");
    }
}
 
Example #20
Source File: StackedXYAreaRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A test for bug 1593156.
 */
public void testBug1593156() {
    boolean success = false;
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();

        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);

        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        StackedXYAreaRenderer renderer = new StackedXYAreaRenderer(
                XYAreaRenderer.LINES);
        XYPlot plot = new XYPlot(dataset,
                new NumberAxis("X"), new NumberAxis("Y"),
                renderer);
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
Example #21
Source File: XYStepAreaRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws the chart with a <code>null</code> info object to make sure that
 * no exceptions are thrown (particularly by code in the renderer).
 */
@Test
public void testDrawWithNullInfo() {
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();

        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);

        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset,
                new NumberAxis("X"), new NumberAxis("Y"),
                new XYStepAreaRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
    }
    catch (NullPointerException e) {
        fail("No exception should be thrown.");
    }
}
 
Example #22
Source File: XYStepRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws the chart with a <code>null</code> value in the dataset to make
 * sure that no exceptions are thrown.
 */
@Test
public void testDrawWithNullValue() {
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();

        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, null);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);

        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, null);
        s2.add(20.0, null);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset,
                new NumberAxis("X"), new NumberAxis("Y"),
                new XYStepRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
    }
    catch (NullPointerException e) {
        fail("No exception should be thrown.");
    }
}
 
Example #23
Source File: XYStepRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws the chart with a <code>null</code> info object to make sure that
 * no exceptions are thrown (particularly by code in the renderer).
 */
@Test
public void testDrawWithNullInfo() {
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();

        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);

        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset,
                new NumberAxis("X"), new NumberAxis("Y"),
                new XYStepRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
    }
    catch (NullPointerException e) {
        fail("No exception should be thrown.");
    }
}
 
Example #24
Source File: StackedXYAreaRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A test for bug 1593156.
 */
@Test
public void testBug1593156() {
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();

        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);

        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        StackedXYAreaRenderer renderer = new StackedXYAreaRenderer(
                XYAreaRenderer.LINES);
        XYPlot plot = new XYPlot(dataset,
                new NumberAxis("X"), new NumberAxis("Y"),
                renderer);
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
    }
    catch (NullPointerException e) {
        fail("No exception should be thrown.");
    }
}
 
Example #25
Source File: StackedXYAreaRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws the chart with a <code>null</code> info object to make sure that
 * no exceptions are thrown (particularly by code in the renderer).
 */
@Test
public void testDrawWithNullInfo() {
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();

        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);

        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset,
                new NumberAxis("X"), new NumberAxis("Y"),
                new StackedXYAreaRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
    }
    catch (NullPointerException e) {
        fail("No exception should be thrown.");
    }
}
 
Example #26
Source File: RendererXYPackageUtils.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates and returns a sample dataset for testing purposes.
 *
 * @return A sample dataset.
 */
public static TableXYDataset createTestTableXYDataset() {
    DefaultTableXYDataset result = new DefaultTableXYDataset();
    XYSeries series1 = new XYSeries("Series 1", false, false);
    series1.add(1.0, 2.0);
    series1.add(2.0, 5.0);
    XYSeries series2 = new XYSeries("Series 2", false, false);
    series2.add(1.0, 4.0);
    series2.add(2.0, 3.0);
    result.addSeries(series1);
    result.addSeries(series2);
    return result;
}
 
Example #27
Source File: XYAreaRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Draws the chart with a <code>null</code> info object to make sure that
 * no exceptions are thrown (particularly by code in the renderer).
 */
@Test
public void testDrawWithNullInfo() {
    try {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();

        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);

        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset,
                new NumberAxis("X"), new NumberAxis("Y"),
                new XYAreaRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
    }
    catch (NullPointerException e) {
        fail("No exception should be thrown.");
    }
}
 
Example #28
Source File: TableXYDatasetTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test that removing all values for a given x works.
 */
public void testRemoveAllValuesForX() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();
    dataset.addSeries(createSeries1());
    dataset.addSeries(createSeries2());
    dataset.removeAllValuesForX(new Double(2.0));
    assertEquals(5, dataset.getItemCount());
    assertEquals(new Double(1.0), dataset.getX(0, 0));
    assertEquals(new Double(3.0), dataset.getX(0, 1));
    assertEquals(new Double(4.0), dataset.getX(0, 2));
    assertEquals(new Double(5.0), dataset.getX(0, 3));
    assertEquals(new Double(6.0), dataset.getX(0, 4));
}
 
Example #29
Source File: XYAreaRenderer2Tests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 {
        DefaultTableXYDataset dataset = new DefaultTableXYDataset();
    
        XYSeries s1 = new XYSeries("Series 1", true, false);
        s1.add(5.0, 5.0);
        s1.add(10.0, 15.5);
        s1.add(15.0, 9.5);
        s1.add(20.0, 7.5);
        dataset.addSeries(s1);
    
        XYSeries s2 = new XYSeries("Series 2", true, false);
        s2.add(5.0, 5.0);
        s2.add(10.0, 15.5);
        s2.add(15.0, 9.5);
        s2.add(20.0, 3.5);
        dataset.addSeries(s2);
        XYPlot plot = new XYPlot(dataset, 
                new NumberAxis("X"), new NumberAxis("Y"), 
                new XYAreaRenderer2());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
Example #30
Source File: TableXYDatasetTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    DefaultTableXYDataset d1 = new DefaultTableXYDataset();
    DefaultTableXYDataset d2 = new DefaultTableXYDataset();
    assertTrue(d1.equals(d2));
    assertTrue(d2.equals(d1));

    d1.addSeries(createSeries1());
    assertFalse(d1.equals(d2));

    d2.addSeries(createSeries1());
    assertTrue(d1.equals(d2));

}