Java Code Examples for org.jfree.data.general.DatasetUtilities#iterateRangeBounds()

The following examples show how to use org.jfree.data.general.DatasetUtilities#iterateRangeBounds() . 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: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the iterateRangeBounds() method.
 */
public void testIterateRangeBounds2_CategoryDataset() {
    // an empty dataset should return a null range
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    Range r = DatasetUtilities.iterateRangeBounds(dataset, false);
    assertNull(r);

    // a dataset with a single value
    dataset.addValue(1.23, "R1", "C1");
    r = DatasetUtilities.iterateRangeBounds(dataset, false);
    assertEquals(1.23, r.getLowerBound(), EPSILON);
    assertEquals(1.23, r.getUpperBound(), EPSILON);

    // null is ignored
    dataset.addValue(null, "R2", "C1");
    r = DatasetUtilities.iterateRangeBounds(dataset, false);
    assertEquals(1.23, r.getLowerBound(), EPSILON);
    assertEquals(1.23, r.getUpperBound(), EPSILON);

    // a Double.NaN should be ignored
    dataset.addValue(Double.NaN, "R2", "C1");
    r = DatasetUtilities.iterateRangeBounds(dataset, false);
    assertEquals(1.23, r.getLowerBound(), EPSILON);
    assertEquals(1.23, r.getUpperBound(), EPSILON);
}
 
Example 2
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the iterateRangeBounds() method using an
 * IntervalCategoryDataset.
 */
public void testIterateRangeBounds3_CategoryDataset() {
    Number[][] starts = new Double[2][3];
    Number[][] ends = new Double[2][3];
    starts[0][0] = new Double(1.0);
    starts[0][1] = new Double(2.0);
    starts[0][2] = new Double(3.0);
    starts[1][0] = new Double(11.0);
    starts[1][1] = new Double(12.0);
    starts[1][2] = new Double(13.0);
    ends[0][0] = new Double(4.0);
    ends[0][1] = new Double(5.0);
    ends[0][2] = new Double(6.0);
    ends[1][0] = new Double(16.0);
    ends[1][1] = new Double(15.0);
    ends[1][2] = new Double(14.0);

    DefaultIntervalCategoryDataset d = new DefaultIntervalCategoryDataset(
            starts, ends);
    Range r = DatasetUtilities.iterateRangeBounds(d, false);
    assertEquals(4.0, r.getLowerBound(), EPSILON);
    assertEquals(16.0, r.getUpperBound(), EPSILON);
    r = DatasetUtilities.iterateRangeBounds(d, true);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(16.0, r.getUpperBound(), EPSILON);
}
 
Example 3
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Yet another test for bug 2849731.
 */
public void testBug2849731_3() {
    XYIntervalSeriesCollection d = new XYIntervalSeriesCollection();
    XYIntervalSeries s = new XYIntervalSeries("S1");
    s.add(1.0, Double.NaN, Double.NaN, 1.5, Double.NaN, Double.NaN);
    d.addSeries(s);
    Range r = DatasetUtilities.iterateRangeBounds(d);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(1.5, r.getUpperBound(), EPSILON);

    s.add(1.0, 1.5, Double.NaN, Double.NaN, Double.NaN, 2.5);
    r = DatasetUtilities.iterateRangeBounds(d);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(2.5, r.getUpperBound(), EPSILON);

    s.add(1.0, Double.NaN, 0.5, Double.NaN, 3.5, Double.NaN);
    r = DatasetUtilities.iterateRangeBounds(d);
    assertEquals(1.5, r.getLowerBound(), EPSILON);
    assertEquals(3.5, r.getUpperBound(), EPSILON);
}
 
Example 4
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some tests for the iterateRangeBounds() method.
 */
public void testIterateRangeBounds_CategoryDataset() {
    CategoryDataset dataset = createCategoryDataset1();
    Range r = DatasetUtilities.iterateRangeBounds(dataset, false);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(6.0, r.getUpperBound(), EPSILON);
}
 
Example 5
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some tests for the iterateRangeBounds() method.
 */
public void testIterateRangeBounds() {
    XYDataset dataset = createXYDataset1();
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(100.0, r.getLowerBound(), EPSILON);
    assertEquals(105.0, r.getUpperBound(), EPSILON);
}
 
Example 6
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check the range returned when a series contains a null value.
 */
public void testIterateRangeBounds2() {
    XYSeries s1 = new XYSeries("S1");
    s1.add(1.0, 1.1);
    s1.add(2.0, null);
    s1.add(3.0, 3.3);
    XYSeriesCollection dataset = new XYSeriesCollection(s1);
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.1, r.getLowerBound(), EPSILON);
    assertEquals(3.3, r.getUpperBound(), EPSILON);
}
 
Example 7
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the iterateRangeBounds() method.
 */
public void testIterateRangeBounds3() {
    // an empty dataset should return a null range
    XYSeriesCollection dataset = new XYSeriesCollection();
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);
    XYSeries s1 = new XYSeries("S1");
    dataset.addSeries(s1);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertNull(r);

    // a dataset with a single value
    s1.add(1.0, 1.23);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.23, r.getLowerBound(), EPSILON);
    assertEquals(1.23, r.getUpperBound(), EPSILON);

    // null is ignored
    s1.add(2.0, null);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.23, r.getLowerBound(), EPSILON);
    assertEquals(1.23, r.getUpperBound(), EPSILON);

    // Double.NaN DOESN'T mess things up
    s1.add(3.0, Double.NaN);
    r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.23, r.getLowerBound(), EPSILON);
    assertEquals(1.23, r.getUpperBound(), EPSILON);
}
 
Example 8
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 9
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some tests for the iterateCategoryRangeBounds() method.
 */
public void testIterateCategoryRangeBounds() {
    CategoryDataset dataset = createCategoryDataset1();
    Range r = DatasetUtilities.iterateRangeBounds(dataset, false);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(6.0, r.getUpperBound(), EPSILON);           
}
 
Example 10
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some tests for the iterateRangeBounds() method.
 */
public void testIterateRangeBounds() {
    XYDataset dataset = createXYDataset1();
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(100.0, r.getLowerBound(), EPSILON);
    assertEquals(105.0, r.getUpperBound(), EPSILON);           
}
 
Example 11
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check the range returned when a series contains a null value.
 */
public void testIterateRangeBounds2() {
    XYSeries s1 = new XYSeries("S1");
    s1.add(1.0, 1.1);
    s1.add(2.0, null);
    s1.add(3.0, 3.3);
    XYSeriesCollection dataset = new XYSeriesCollection(s1);
    Range r = DatasetUtilities.iterateRangeBounds(dataset);
    assertEquals(1.1, r.getLowerBound(), EPSILON);
    assertEquals(3.3, r.getUpperBound(), EPSILON);
}