Java Code Examples for org.jfree.data.xy.DefaultTableXYDataset#addSeries()

The following examples show how to use org.jfree.data.xy.DefaultTableXYDataset#addSeries() . 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: 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 2
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 3
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 4
Source File: TableXYDatasetTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A test for bug report 788597.
 */
public void test788597() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();
    dataset.addSeries(createSeries1());
    assertEquals(4, dataset.getItemCount());
    dataset.removeAllSeries();
    assertEquals(0, dataset.getItemCount());
}
 
Example 5
Source File: XYStepRendererTests.java    From astor 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.
 */
public void testDrawWithNullValue() {
    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, 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);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
Example 6
Source File: XYStepRendererTest.java    From ccu-historian with GNU General Public License v3.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 7
Source File: StackedXYAreaRendererTest.java    From ccu-historian with GNU General Public License v3.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 8
Source File: StackedXYAreaRendererTest.java    From SIMVA-SoS with Apache License 2.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 9
Source File: XYBoxAnnotationTest.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.
 */
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 XYBoxAnnotation(10.0, 12.0, 3.0, 4.0,
                new BasicStroke(1.2f), Color.red, Color.blue));
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
    }
    catch (NullPointerException e) {
        fail("No exception should be triggered.");
    }
}
 
Example 10
Source File: XYBoxAnnotationTest.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.
 */
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 XYBoxAnnotation(10.0, 12.0, 3.0, 4.0,
                new BasicStroke(1.2f), Color.red, Color.blue));
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
    }
    catch (NullPointerException e) {
        fail("No exception should be triggered.");
    }
}
 
Example 11
Source File: XYAreaRendererTests.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 XYAreaRenderer());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
Example 12
Source File: XYBoxAnnotationTests.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.
 */
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 XYLineAndShapeRenderer());
        plot.addAnnotation(new XYBoxAnnotation(10.0, 12.0, 3.0, 4.0, 
        		new BasicStroke(1.2f), Color.red, Color.blue));
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200, 
                null);
        success = true;
    }
    catch (NullPointerException e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
Example 13
Source File: TableXYDatasetTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Tests to see that pruning removes unwanted x values.
 */
public void testPrune() {
    DefaultTableXYDataset dataset = new DefaultTableXYDataset();
    dataset.addSeries(createSeries1());
    dataset.addSeries(createSeries2());
    dataset.removeSeries(1);
    dataset.prune();
    assertEquals(4, dataset.getItemCount());
}
 
Example 14
Source File: XYAreaRenderer2Test.java    From openstock 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 XYAreaRenderer2());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
    }
    catch (NullPointerException e) {
        fail("No exception should be thrown.");
    }
}
 
Example 15
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 16
Source File: XYStepRendererTest.java    From openstock with GNU General Public License v3.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 17
Source File: RendererXYPackageUtils.java    From SIMVA-SoS with Apache License 2.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 18
Source File: XYBoxAnnotationTest.java    From ccu-historian 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.
 */
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 XYBoxAnnotation(10.0, 12.0, 3.0, 4.0,
                new BasicStroke(1.2f), Color.red, Color.blue));
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
    }
    catch (NullPointerException e) {
        fail("No exception should be triggered.");
    }
}
 
Example 19
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 20
Source File: XYAreaRenderer2Test.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 XYAreaRenderer2());
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */ chart.createBufferedImage(300, 200,
                null);
    }
    catch (NullPointerException e) {
        fail("No exception should be thrown.");
    }
}