use of org.jfree.data.xy.YIntervalSeries in project SIMVA-SoS by SESoS.
the class DatasetUtilitiesTest method testIterateRangeBounds4.
/**
* 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);
}
use of org.jfree.data.xy.YIntervalSeries in project SIMVA-SoS by SESoS.
the class YIntervalRendererTest method testGetLegendItemSeriesIndex.
/**
* 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());
}
use of org.jfree.data.xy.YIntervalSeries in project SIMVA-SoS by SESoS.
the class DatasetUtilitiesTest method testFindRangeBounds2.
/**
* A test for the findRangeBounds(XYDataset) method using
* an IntervalXYDataset.
*/
@Test
public void testFindRangeBounds2() {
YIntervalSeriesCollection dataset = new YIntervalSeriesCollection();
Range r = DatasetUtilities.findRangeBounds(dataset);
assertNull(r);
YIntervalSeries s1 = new YIntervalSeries("S1");
dataset.addSeries(s1);
r = DatasetUtilities.findRangeBounds(dataset);
assertNull(r);
// try a single item
s1.add(1.0, 2.0, 1.5, 2.5);
r = DatasetUtilities.findRangeBounds(dataset);
assertEquals(1.5, r.getLowerBound(), EPSILON);
assertEquals(2.5, r.getUpperBound(), EPSILON);
r = DatasetUtilities.findRangeBounds(dataset, false);
assertEquals(2.0, r.getLowerBound(), EPSILON);
assertEquals(2.0, r.getUpperBound(), EPSILON);
// another item
s1.add(2.0, 2.0, 1.4, 2.1);
r = DatasetUtilities.findRangeBounds(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.findRangeBounds(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.findRangeBounds(dataset);
assertEquals(1.4, r.getLowerBound(), EPSILON);
assertEquals(2.6, r.getUpperBound(), EPSILON);
// what if we don't want the interval?
r = DatasetUtilities.findRangeBounds(dataset, false);
assertEquals(2.0, r.getLowerBound(), EPSILON);
assertEquals(2.0, r.getUpperBound(), EPSILON);
}
Aggregations