org.jfree.data.xy.YIntervalSeries Java Examples

The following examples show how to use org.jfree.data.xy.YIntervalSeries. 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: YIntervalSeriesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the add() method for an UNSORTED series.
 */
public void testAdd() {
    YIntervalSeries series = new YIntervalSeries("Series", false, true);
    series.add(5.0, 5.50, 5.50, 5.50);
    series.add(5.1, 5.51, 5.51, 5.51);
    series.add(6.0, 6.6, 6.6, 6.6);
    series.add(3.0, 3.3, 3.3, 3.3);
    series.add(4.0, 4.4, 4.4, 4.4);
    series.add(2.0, 2.2, 2.2, 2.2);
    series.add(1.0, 1.1, 1.1, 1.1);
    assertEquals(5.5, series.getYValue(0), EPSILON);
    assertEquals(5.51, series.getYValue(1), EPSILON);
    assertEquals(6.6, series.getYValue(2), EPSILON);
    assertEquals(3.3, series.getYValue(3), EPSILON);
    assertEquals(4.4, series.getYValue(4), EPSILON);
    assertEquals(2.2, series.getYValue(5), EPSILON);
    assertEquals(1.1, series.getYValue(6), EPSILON);
}
 
Example #2
Source File: YIntervalSeriesCollectionTests.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() {
    YIntervalSeriesCollection c1 = new YIntervalSeriesCollection();
    YIntervalSeriesCollection c2 = new YIntervalSeriesCollection();
    assertEquals(c1, c2);
    
    // add a series
    YIntervalSeries s1 = new YIntervalSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3);
    c1.addSeries(s1);
    assertFalse(c1.equals(c2));
    YIntervalSeries s2 = new YIntervalSeries("Series");
    s2.add(1.0, 1.1, 1.2, 1.3);
    c2.addSeries(s2);
    assertTrue(c1.equals(c2));
    
    // add an empty series
    c1.addSeries(new YIntervalSeries("Empty Series"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new YIntervalSeries("Empty Series"));
    assertTrue(c1.equals(c2));
}
 
Example #3
Source File: YIntervalSeriesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the add() method for an UNSORTED series.
 */
public void testAdd() {
    YIntervalSeries series = new YIntervalSeries("Series", false, true);
    series.add(5.0, 5.50, 5.50, 5.50);
    series.add(5.1, 5.51, 5.51, 5.51);
    series.add(6.0, 6.6, 6.6, 6.6);
    series.add(3.0, 3.3, 3.3, 3.3);
    series.add(4.0, 4.4, 4.4, 4.4);
    series.add(2.0, 2.2, 2.2, 2.2);
    series.add(1.0, 1.1, 1.1, 1.1);
    assertEquals(5.5, series.getYValue(0), EPSILON);
    assertEquals(5.51, series.getYValue(1), EPSILON);
    assertEquals(6.6, series.getYValue(2), EPSILON);
    assertEquals(3.3, series.getYValue(3), EPSILON);
    assertEquals(4.4, series.getYValue(4), EPSILON);
    assertEquals(2.2, series.getYValue(5), EPSILON);
    assertEquals(1.1, series.getYValue(6), EPSILON);
}
 
Example #4
Source File: YIntervalSeriesCollectionTests.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() {
    YIntervalSeriesCollection c1 = new YIntervalSeriesCollection();
    YIntervalSeriesCollection c2 = new YIntervalSeriesCollection();
    assertEquals(c1, c2);

    // add a series
    YIntervalSeries s1 = new YIntervalSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3);
    c1.addSeries(s1);
    assertFalse(c1.equals(c2));
    YIntervalSeries s2 = new YIntervalSeries("Series");
    s2.add(1.0, 1.1, 1.2, 1.3);
    c2.addSeries(s2);
    assertTrue(c1.equals(c2));

    // add an empty series
    c1.addSeries(new YIntervalSeries("Empty Series"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new YIntervalSeries("Empty Series"));
    assertTrue(c1.equals(c2));
}
 
Example #5
Source File: YIntervalSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Simple test for the remove() method.
 */
public void testRemove() {
    YIntervalSeries s1 = new YIntervalSeries("Series 1");
    s1.add(1.0, 1.0, 1.0, 2.0);
    s1.add(2.0, 2.0, 2.0, 2.0);
    s1.add(3.0, 3.0, 3.0, 3.0);
    assertEquals(3, s1.getItemCount());
    
    s1.remove(new Double(2.0));
    assertEquals(new Double(3.0), s1.getX(1));
    
    s1.remove(new Double(1.0));
    assertEquals(new Double(3.0), s1.getX(0));    
}
 
Example #6
Source File: YIntervalSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * When items are added with duplicate x-values, we expect them to remain
 * in the order they were added.
 */
public void testAdditionOfDuplicateXValues() {
    YIntervalSeries s1 = new YIntervalSeries("Series 1");
    s1.add(1.0, 1.0, 1.0, 1.0);
    s1.add(2.0, 2.0, 2.0, 2.0);
    s1.add(2.0, 3.0, 3.0, 3.0);
    s1.add(2.0, 4.0, 4.0, 4.0);
    s1.add(3.0, 5.0, 5.0, 5.0);
    assertEquals(1.0, s1.getYValue(0), EPSILON);
    assertEquals(2.0, s1.getYValue(1), EPSILON);
    assertEquals(3.0, s1.getYValue(2), EPSILON);
    assertEquals(4.0, s1.getYValue(3), EPSILON);
    assertEquals(5.0, s1.getYValue(4), EPSILON);
}
 
Example #7
Source File: YIntervalSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A simple check that the maximumItemCount attribute is working.
 */
public void testSetMaximumItemCount() {
    YIntervalSeries s1 = new YIntervalSeries("S1");
    assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount());
    s1.setMaximumItemCount(2);
    assertEquals(2, s1.getMaximumItemCount());
    s1.add(1.0, 1.1, 1.1, 1.1);
    s1.add(2.0, 2.2, 2.2, 2.2);
    s1.add(3.0, 3.3, 3.3, 3.3);
    assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON);
    assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON);
}
 
Example #8
Source File: YIntervalSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that the maximum item count can be applied retrospectively.
 */
public void testSetMaximumItemCount2() {
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.1, 1.1);
    s1.add(2.0, 2.2, 2.2, 2.2);
    s1.add(3.0, 3.3, 3.3, 3.3);
    s1.setMaximumItemCount(2);
    assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON);
    assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON);
}
 
Example #9
Source File: YIntervalSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the clear() method.
 */
public void testClear() {
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.addChangeListener(this);
    s1.clear();
    assertNull(this.lastEvent);
    assertTrue(s1.isEmpty());
    s1.add(1.0, 2.0, 3.0, 4.0);
    assertFalse(s1.isEmpty());
    s1.clear();
    assertNotNull(this.lastEvent);
    assertTrue(s1.isEmpty());
}
 
Example #10
Source File: YIntervalRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
public void testGetLegendItemSeriesIndex() {
    YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s2 = new YIntervalSeries("S2");
    s2.add(1.0, 1.1, 1.2, 1.3);
    d1.addSeries(s1);
    d1.addSeries(s2);
    
    YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
    YIntervalSeries s3 = new YIntervalSeries("S3");
    s3.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s4 = new YIntervalSeries("S4");
    s4.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s5 = new YIntervalSeries("S5");
    s5.add(1.0, 1.1, 1.2, 1.3);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);

    YIntervalRenderer r = new YIntervalRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example #11
Source File: YIntervalSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Simple test for the indexOf() method.
 */
public void testIndexOf() {
    YIntervalSeries s1 = new YIntervalSeries("Series 1");
    s1.add(1.0, 1.0, 1.0, 2.0);
    s1.add(2.0, 2.0, 2.0, 3.0);
    s1.add(3.0, 3.0, 3.0, 4.0);
    assertEquals(0, s1.indexOf(new Double(1.0)));
}
 
Example #12
Source File: YIntervalSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A check for the indexOf() method for an unsorted series.
 */
public void testIndexOf2() {
    YIntervalSeries s1 = new YIntervalSeries("Series 1", false, true);
    s1.add(1.0, 1.0, 1.0, 2.0);
    s1.add(3.0, 3.0, 3.0, 3.0);
    s1.add(2.0, 2.0, 2.0, 2.0);
    assertEquals(0, s1.indexOf(new Double(1.0)));        
    assertEquals(1, s1.indexOf(new Double(3.0)));        
    assertEquals(2, s1.indexOf(new Double(2.0)));        
}
 
Example #13
Source File: DatasetUtilitiesTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Some checks for the range bounds of a dataset that implements the
 * {@link IntervalXYDataset} interface.
 */
@Test
public void testIterateRangeBounds4() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);
}
 
Example #14
Source File: YIntervalSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * When items are added with duplicate x-values, we expect them to remain 
 * in the order they were added.
 */
public void testAdditionOfDuplicateXValues() {
    YIntervalSeries s1 = new YIntervalSeries("Series 1");
    s1.add(1.0, 1.0, 1.0, 1.0);
    s1.add(2.0, 2.0, 2.0, 2.0);
    s1.add(2.0, 3.0, 3.0, 3.0);
    s1.add(2.0, 4.0, 4.0, 4.0);
    s1.add(3.0, 5.0, 5.0, 5.0);
    assertEquals(1.0, s1.getYValue(0), EPSILON);
    assertEquals(2.0, s1.getYValue(1), EPSILON);
    assertEquals(3.0, s1.getYValue(2), EPSILON);
    assertEquals(4.0, s1.getYValue(3), EPSILON);
    assertEquals(5.0, s1.getYValue(4), EPSILON);
}
 
Example #15
Source File: YIntervalSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A simple check that the maximumItemCount attribute is working.
 */
public void testSetMaximumItemCount() {
    YIntervalSeries s1 = new YIntervalSeries("S1");
    assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount());
    s1.setMaximumItemCount(2);
    assertEquals(2, s1.getMaximumItemCount());
    s1.add(1.0, 1.1, 1.1, 1.1);
    s1.add(2.0, 2.2, 2.2, 2.2);
    s1.add(3.0, 3.3, 3.3, 3.3);
    assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON);
    assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON);
}
 
Example #16
Source File: YIntervalSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that the maximum item count can be applied retrospectively.
 */
public void testSetMaximumItemCount2() {
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.1, 1.1);
    s1.add(2.0, 2.2, 2.2, 2.2);
    s1.add(3.0, 3.3, 3.3, 3.3);
    s1.setMaximumItemCount(2);
    assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON);
    assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON);
}
 
Example #17
Source File: YIntervalSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the clear() method.
 */
public void testClear() {
	YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.addChangeListener(this);
    s1.clear();
    assertNull(this.lastEvent);
    assertTrue(s1.isEmpty());
    s1.add(1.0, 2.0, 3.0, 4.0);
    assertFalse(s1.isEmpty());
    s1.clear();
    assertNotNull(this.lastEvent);
    assertTrue(s1.isEmpty());
}
 
Example #18
Source File: YIntervalRendererTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s2 = new YIntervalSeries("S2");
    s2.add(1.0, 1.1, 1.2, 1.3);
    d1.addSeries(s1);
    d1.addSeries(s2);

    YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
    YIntervalSeries s3 = new YIntervalSeries("S3");
    s3.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s4 = new YIntervalSeries("S4");
    s4.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s5 = new YIntervalSeries("S5");
    s5.add(1.0, 1.1, 1.2, 1.3);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);

    YIntervalRenderer r = new YIntervalRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example #19
Source File: YIntervalRendererTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s2 = new YIntervalSeries("S2");
    s2.add(1.0, 1.1, 1.2, 1.3);
    d1.addSeries(s1);
    d1.addSeries(s2);

    YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
    YIntervalSeries s3 = new YIntervalSeries("S3");
    s3.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s4 = new YIntervalSeries("S4");
    s4.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s5 = new YIntervalSeries("S5");
    s5.add(1.0, 1.1, 1.2, 1.3);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);

    YIntervalRenderer r = new YIntervalRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example #20
Source File: YIntervalSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A check for the indexOf() method for an unsorted series.
 */
public void testIndexOf2() {
    YIntervalSeries s1 = new YIntervalSeries("Series 1", false, true);
    s1.add(1.0, 1.0, 1.0, 2.0);
    s1.add(3.0, 3.0, 3.0, 3.0);
    s1.add(2.0, 2.0, 2.0, 2.0);
    assertEquals(0, s1.indexOf(new Double(1.0)));
    assertEquals(1, s1.indexOf(new Double(3.0)));
    assertEquals(2, s1.indexOf(new Double(2.0)));
}
 
Example #21
Source File: DatasetUtilitiesTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Some checks for the range bounds of a dataset that implements the
 * {@link IntervalXYDataset} interface.
 */
@Test
public void testIterateRangeBounds4() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);
}
 
Example #22
Source File: YIntervalRendererTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s2 = new YIntervalSeries("S2");
    s2.add(1.0, 1.1, 1.2, 1.3);
    d1.addSeries(s1);
    d1.addSeries(s2);

    YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
    YIntervalSeries s3 = new YIntervalSeries("S3");
    s3.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s4 = new YIntervalSeries("S4");
    s4.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s5 = new YIntervalSeries("S5");
    s5.add(1.0, 1.1, 1.2, 1.3);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);

    YIntervalRenderer r = new YIntervalRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example #23
Source File: DatasetUtilitiesTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Some checks for the range bounds of a dataset that implements the
 * {@link IntervalXYDataset} interface.
 */
@Test
public void testIterateRangeBounds4() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);
}
 
Example #24
Source File: YIntervalRendererTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s2 = new YIntervalSeries("S2");
    s2.add(1.0, 1.1, 1.2, 1.3);
    d1.addSeries(s1);
    d1.addSeries(s2);

    YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
    YIntervalSeries s3 = new YIntervalSeries("S3");
    s3.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s4 = new YIntervalSeries("S4");
    s4.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s5 = new YIntervalSeries("S5");
    s5.add(1.0, 1.1, 1.2, 1.3);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);

    YIntervalRenderer r = new YIntervalRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example #25
Source File: DatasetUtilitiesTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Some checks for the range bounds of a dataset that implements the
 * {@link IntervalXYDataset} interface.
 */
@Test
public void testIterateRangeBounds4() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);
}
 
Example #26
Source File: YIntervalRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s2 = new YIntervalSeries("S2");
    s2.add(1.0, 1.1, 1.2, 1.3);
    d1.addSeries(s1);
    d1.addSeries(s2);

    YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
    YIntervalSeries s3 = new YIntervalSeries("S3");
    s3.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s4 = new YIntervalSeries("S4");
    s4.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s5 = new YIntervalSeries("S5");
    s5.add(1.0, 1.1, 1.2, 1.3);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);

    YIntervalRenderer r = new YIntervalRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example #27
Source File: DatasetUtilitiesTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the range bounds of a dataset that implements the
 * {@link IntervalXYDataset} interface.
 */
@Test
public void testIterateRangeBounds4() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);
}
 
Example #28
Source File: YIntervalRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
public void testGetLegendItemSeriesIndex() {
    YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
    YIntervalSeries s1 = new YIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s2 = new YIntervalSeries("S2");
    s2.add(1.0, 1.1, 1.2, 1.3);
    d1.addSeries(s1);
    d1.addSeries(s2);

    YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
    YIntervalSeries s3 = new YIntervalSeries("S3");
    s3.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s4 = new YIntervalSeries("S4");
    s4.add(1.0, 1.1, 1.2, 1.3);
    YIntervalSeries s5 = new YIntervalSeries("S5");
    s5.add(1.0, 1.1, 1.2, 1.3);
    d2.addSeries(s3);
    d2.addSeries(s4);
    d2.addSeries(s5);

    YIntervalRenderer r = new YIntervalRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example #29
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the range bounds of a dataset that implements the
 * {@link IntervalXYDataset} interface.
 */
public void testIterateRangeBounds4() {
    YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);
    YIntervalSeries s1 = new YIntervalSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);

    // try a single item
    s1.add(1.0, 2.0, 1.5, 2.5);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another item
    s1.add(2.0, 2.0, 1.4, 2.1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // another empty series
    YIntervalSeries s2 = new YIntervalSeries("S2");
    dataset.addSeries(s2);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    // an item in series 2
    s2.add(1.0, 2.0, 1.9, 2.6);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.4, r.getLowerBound(), EPSILON);
    assertEquals(2.6, r.getUpperBound(), EPSILON);
}
 
Example #30
Source File: YIntervalSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Simple test for the indexOf() method.
 */
public void testIndexOf() {
    YIntervalSeries s1 = new YIntervalSeries("Series 1");
    s1.add(1.0, 1.0, 1.0, 2.0);
    s1.add(2.0, 2.0, 2.0, 3.0);
    s1.add(3.0, 3.0, 3.0, 4.0);
    assertEquals(0, s1.indexOf(new Double(1.0)));
}