org.jfree.data.xy.XYIntervalSeriesCollection Java Examples

The following examples show how to use org.jfree.data.xy.XYIntervalSeriesCollection. 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: XYBarRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A test for the findDomainBounds method to ensure it correctly accounts 
 * for the series visibility.
 */
@Test
public void testFindDomainBounds2() {
    XYIntervalSeries s1 = new XYIntervalSeries("S1");
    s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5);
    s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3);
    XYIntervalSeries s2 = new XYIntervalSeries("S2");
    s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5);
    s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0);
    XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);
    
    XYBarRenderer renderer = new XYBarRenderer();
    Range r = renderer.findDomainBounds(dataset);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(4.1, r.getUpperBound(), EPSILON);
    
    renderer.setSeriesVisible(1, Boolean.FALSE);
    r = renderer.findDomainBounds(dataset);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(2.1, r.getUpperBound(), EPSILON);
}
 
Example #2
Source File: DatasetUtilitiesTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Yet another test for bug 2849731.
 */
@Test
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 #3
Source File: DatasetUtilitiesTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Another test for bug 2849731.
 */
@Test
public void testBug2849731_2() {
    XYIntervalSeriesCollection d = new XYIntervalSeriesCollection();
    XYIntervalSeries s = new XYIntervalSeries("S1");
    s.add(1.0, Double.NaN, Double.NaN, Double.NaN, 1.5, Double.NaN);
    d.addSeries(s);
    Range r = DatasetUtilities.iterateDomainBounds(d);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(1.0, r.getUpperBound(), EPSILON);

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

    s.add(1.0, Double.NaN, 0.5, Double.NaN, 1.5, Double.NaN);
    r = DatasetUtilities.iterateDomainBounds(d);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(1.5, r.getUpperBound(), EPSILON);
}
 
Example #4
Source File: XYBarRendererTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * A test for the findRangeBounds method to ensure it correctly accounts 
 * for the series visibility.
 */
@Test
public void testFindRangeBounds2() {
    XYIntervalSeries s1 = new XYIntervalSeries("S1");
    s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5);
    s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3);
    XYIntervalSeries s2 = new XYIntervalSeries("S2");
    s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5);
    s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0);
    XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);
    
    XYBarRenderer renderer = new XYBarRenderer();
    renderer.setUseYInterval(false);
    Range r = renderer.findRangeBounds(dataset);
    assertEquals(9.0, r.getLowerBound(), EPSILON);
    assertEquals(30.0, r.getUpperBound(), EPSILON);
    
    renderer.setSeriesVisible(1, Boolean.FALSE);
    r = renderer.findRangeBounds(dataset);
    assertEquals(10.0, r.getLowerBound(), EPSILON);
    assertEquals(20.0, r.getUpperBound(), EPSILON);
}
 
Example #5
Source File: XYBarRendererTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * A test for the findDomainBounds method to ensure it correctly accounts 
 * for the series visibility.
 */
@Test
public void testFindDomainBounds2() {
    XYIntervalSeries s1 = new XYIntervalSeries("S1");
    s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5);
    s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3);
    XYIntervalSeries s2 = new XYIntervalSeries("S2");
    s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5);
    s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0);
    XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);
    
    XYBarRenderer renderer = new XYBarRenderer();
    Range r = renderer.findDomainBounds(dataset);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(4.1, r.getUpperBound(), EPSILON);
    
    renderer.setSeriesVisible(1, Boolean.FALSE);
    r = renderer.findDomainBounds(dataset);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(2.1, r.getUpperBound(), EPSILON);
}
 
Example #6
Source File: XYIntervalSeriesCollectionTests.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() {
    XYIntervalSeriesCollection c1 = new XYIntervalSeriesCollection();
    XYIntervalSeriesCollection c2 = new XYIntervalSeriesCollection();
    assertEquals(c1, c2);
    
    // add a series
    XYIntervalSeries s1 = new XYIntervalSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5);
    c1.addSeries(s1);
    assertFalse(c1.equals(c2));
    XYIntervalSeries s2 = new XYIntervalSeries("Series");
    s2.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5);
    c2.addSeries(s2);
    assertTrue(c1.equals(c2));
    
    // add an empty series
    c1.addSeries(new XYIntervalSeries("Empty Series"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new XYIntervalSeries("Empty Series"));
    assertTrue(c1.equals(c2));
}
 
Example #7
Source File: XYIntervalSeriesCollectionTests.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() {
    XYIntervalSeriesCollection c1 = new XYIntervalSeriesCollection();
    XYIntervalSeriesCollection c2 = new XYIntervalSeriesCollection();
    assertEquals(c1, c2);

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

    // add an empty series
    c1.addSeries(new XYIntervalSeries("Empty Series"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new XYIntervalSeries("Empty Series"));
    assertTrue(c1.equals(c2));
}
 
Example #8
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 #9
Source File: DatasetUtilitiesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Another test for bug 2849731.
 */
public void testBug2849731_2() {
    XYIntervalSeriesCollection d = new XYIntervalSeriesCollection();
    XYIntervalSeries s = new XYIntervalSeries("S1");
    s.add(1.0, Double.NaN, Double.NaN, Double.NaN, 1.5, Double.NaN);
    d.addSeries(s);
    Range r = DatasetUtilities.iterateDomainBounds(d);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(1.0, r.getUpperBound(), EPSILON);

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

    s.add(1.0, Double.NaN, 0.5, Double.NaN, 1.5, Double.NaN);
    r = DatasetUtilities.iterateDomainBounds(d);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(1.5, r.getUpperBound(), EPSILON);
}
 
Example #10
Source File: DatasetUtilitiesTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Yet another test for bug 2849731.
 */
@Test
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 #11
Source File: DatasetUtilitiesTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Another test for bug 2849731.
 */
@Test
public void testBug2849731_2() {
    XYIntervalSeriesCollection d = new XYIntervalSeriesCollection();
    XYIntervalSeries s = new XYIntervalSeries("S1");
    s.add(1.0, Double.NaN, Double.NaN, Double.NaN, 1.5, Double.NaN);
    d.addSeries(s);
    Range r = DatasetUtilities.iterateDomainBounds(d);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(1.0, r.getUpperBound(), EPSILON);

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

    s.add(1.0, Double.NaN, 0.5, Double.NaN, 1.5, Double.NaN);
    r = DatasetUtilities.iterateDomainBounds(d);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(1.5, r.getUpperBound(), EPSILON);
}
 
Example #12
Source File: XYBarRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A test for the findRangeBounds method to ensure it correctly accounts 
 * for the series visibility.
 */
@Test
public void testFindRangeBounds2() {
    XYIntervalSeries s1 = new XYIntervalSeries("S1");
    s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5);
    s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3);
    XYIntervalSeries s2 = new XYIntervalSeries("S2");
    s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5);
    s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0);
    XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);
    
    XYBarRenderer renderer = new XYBarRenderer();
    renderer.setUseYInterval(false);
    Range r = renderer.findRangeBounds(dataset);
    assertEquals(9.0, r.getLowerBound(), EPSILON);
    assertEquals(30.0, r.getUpperBound(), EPSILON);
    
    renderer.setSeriesVisible(1, Boolean.FALSE);
    r = renderer.findRangeBounds(dataset);
    assertEquals(10.0, r.getLowerBound(), EPSILON);
    assertEquals(20.0, r.getUpperBound(), EPSILON);
}
 
Example #13
Source File: XYBarRendererTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * A test for the findDomainBounds method to ensure it correctly accounts 
 * for the series visibility.
 */
@Test
public void testFindDomainBounds2() {
    XYIntervalSeries s1 = new XYIntervalSeries("S1");
    s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5);
    s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3);
    XYIntervalSeries s2 = new XYIntervalSeries("S2");
    s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5);
    s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0);
    XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);
    
    XYBarRenderer renderer = new XYBarRenderer();
    Range r = renderer.findDomainBounds(dataset);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(4.1, r.getUpperBound(), EPSILON);
    
    renderer.setSeriesVisible(1, Boolean.FALSE);
    r = renderer.findDomainBounds(dataset);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(2.1, r.getUpperBound(), EPSILON);
}
 
Example #14
Source File: ChartJFreeChartOutputScatter.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void clearDataSet(final IScope scope) {
	// TODO Auto-generated method stub
	super.clearDataSet(scope);
	final XYPlot plot = (XYPlot) this.chart.getPlot();
	for (int i = plot.getDatasetCount() - 1; i >= 1; i--) {
		plot.setDataset(i, null);
		plot.setRenderer(i, null);
	}
	((XYIntervalSeriesCollection) jfreedataset.get(0)).removeAllSeries();
	jfreedataset.clear();
	jfreedataset.add(0, new XYIntervalSeriesCollection());
	plot.setDataset((XYIntervalSeriesCollection) jfreedataset.get(0));
	plot.setRenderer(0, null);
	IdPosition.clear();
}
 
Example #15
Source File: XYBarRendererTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * A test for the findRangeBounds method to ensure it correctly accounts 
 * for the series visibility.
 */
@Test
public void testFindRangeBounds2() {
    XYIntervalSeries s1 = new XYIntervalSeries("S1");
    s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5);
    s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3);
    XYIntervalSeries s2 = new XYIntervalSeries("S2");
    s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5);
    s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0);
    XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);
    
    XYBarRenderer renderer = new XYBarRenderer();
    renderer.setUseYInterval(false);
    Range r = renderer.findRangeBounds(dataset);
    assertEquals(9.0, r.getLowerBound(), EPSILON);
    assertEquals(30.0, r.getUpperBound(), EPSILON);
    
    renderer.setSeriesVisible(1, Boolean.FALSE);
    r = renderer.findRangeBounds(dataset);
    assertEquals(10.0, r.getLowerBound(), EPSILON);
    assertEquals(20.0, r.getUpperBound(), EPSILON);
}
 
Example #16
Source File: DatasetUtilitiesTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Another test for bug 2849731.
 */
@Test
public void testBug2849731_2() {
    XYIntervalSeriesCollection d = new XYIntervalSeriesCollection();
    XYIntervalSeries s = new XYIntervalSeries("S1");
    s.add(1.0, Double.NaN, Double.NaN, Double.NaN, 1.5, Double.NaN);
    d.addSeries(s);
    Range r = DatasetUtilities.iterateDomainBounds(d);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(1.0, r.getUpperBound(), EPSILON);

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

    s.add(1.0, Double.NaN, 0.5, Double.NaN, 1.5, Double.NaN);
    r = DatasetUtilities.iterateDomainBounds(d);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(1.5, r.getUpperBound(), EPSILON);
}
 
Example #17
Source File: DatasetUtilitiesTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Yet another test for bug 2849731.
 */
@Test
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 #18
Source File: DatasetUtilitiesTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Another test for bug 2849731.
 */
@Test
public void testBug2849731_2() {
    XYIntervalSeriesCollection d = new XYIntervalSeriesCollection();
    XYIntervalSeries s = new XYIntervalSeries("S1");
    s.add(1.0, Double.NaN, Double.NaN, Double.NaN, 1.5, Double.NaN);
    d.addSeries(s);
    Range r = DatasetUtilities.iterateDomainBounds(d);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(1.0, r.getUpperBound(), EPSILON);

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

    s.add(1.0, Double.NaN, 0.5, Double.NaN, 1.5, Double.NaN);
    r = DatasetUtilities.iterateDomainBounds(d);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(1.5, r.getUpperBound(), EPSILON);
}
 
Example #19
Source File: XYBarRendererTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * A test for the findRangeBounds method to ensure it correctly accounts 
 * for the series visibility.
 */
@Test
public void testFindRangeBounds2() {
    XYIntervalSeries s1 = new XYIntervalSeries("S1");
    s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5);
    s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3);
    XYIntervalSeries s2 = new XYIntervalSeries("S2");
    s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5);
    s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0);
    XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);
    
    XYBarRenderer renderer = new XYBarRenderer();
    renderer.setUseYInterval(false);
    Range r = renderer.findRangeBounds(dataset);
    assertEquals(9.0, r.getLowerBound(), EPSILON);
    assertEquals(30.0, r.getUpperBound(), EPSILON);
    
    renderer.setSeriesVisible(1, Boolean.FALSE);
    r = renderer.findRangeBounds(dataset);
    assertEquals(10.0, r.getLowerBound(), EPSILON);
    assertEquals(20.0, r.getUpperBound(), EPSILON);
}
 
Example #20
Source File: XYBarRendererTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * A test for the findDomainBounds method to ensure it correctly accounts 
 * for the series visibility.
 */
@Test
public void testFindDomainBounds2() {
    XYIntervalSeries s1 = new XYIntervalSeries("S1");
    s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5);
    s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3);
    XYIntervalSeries s2 = new XYIntervalSeries("S2");
    s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5);
    s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0);
    XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);
    
    XYBarRenderer renderer = new XYBarRenderer();
    Range r = renderer.findDomainBounds(dataset);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(4.1, r.getUpperBound(), EPSILON);
    
    renderer.setSeriesVisible(1, Boolean.FALSE);
    r = renderer.findDomainBounds(dataset);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(2.1, r.getUpperBound(), EPSILON);
}
 
Example #21
Source File: DatasetUtilitiesTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Yet another test for bug 2849731.
 */
@Test
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 #22
Source File: DatasetUtilitiesTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Another test for bug 2849731.
 */
@Test
public void testBug2849731_2() {
    XYIntervalSeriesCollection d = new XYIntervalSeriesCollection();
    XYIntervalSeries s = new XYIntervalSeries("S1");
    s.add(1.0, Double.NaN, Double.NaN, Double.NaN, 1.5, Double.NaN);
    d.addSeries(s);
    Range r = DatasetUtilities.iterateDomainBounds(d);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(1.0, r.getUpperBound(), EPSILON);

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

    s.add(1.0, Double.NaN, 0.5, Double.NaN, 1.5, Double.NaN);
    r = DatasetUtilities.iterateDomainBounds(d);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(1.5, r.getUpperBound(), EPSILON);
}
 
Example #23
Source File: DatasetUtilitiesTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Yet another test for bug 2849731.
 */
@Test
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 #24
Source File: XYBarRendererTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * A test for the findRangeBounds method to ensure it correctly accounts 
 * for the series visibility.
 */
@Test
public void testFindRangeBounds2() {
    XYIntervalSeries s1 = new XYIntervalSeries("S1");
    s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5);
    s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3);
    XYIntervalSeries s2 = new XYIntervalSeries("S2");
    s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5);
    s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0);
    XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);
    
    XYBarRenderer renderer = new XYBarRenderer();
    renderer.setUseYInterval(false);
    Range r = renderer.findRangeBounds(dataset);
    assertEquals(9.0, r.getLowerBound(), EPSILON);
    assertEquals(30.0, r.getUpperBound(), EPSILON);
    
    renderer.setSeriesVisible(1, Boolean.FALSE);
    r = renderer.findRangeBounds(dataset);
    assertEquals(10.0, r.getLowerBound(), EPSILON);
    assertEquals(20.0, r.getUpperBound(), EPSILON);
}
 
Example #25
Source File: XYBarRendererTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * A test for the findDomainBounds method to ensure it correctly accounts 
 * for the series visibility.
 */
@Test
public void testFindDomainBounds2() {
    XYIntervalSeries s1 = new XYIntervalSeries("S1");
    s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5);
    s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3);
    XYIntervalSeries s2 = new XYIntervalSeries("S2");
    s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5);
    s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0);
    XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);
    
    XYBarRenderer renderer = new XYBarRenderer();
    Range r = renderer.findDomainBounds(dataset);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(4.1, r.getUpperBound(), EPSILON);
    
    renderer.setSeriesVisible(1, Boolean.FALSE);
    r = renderer.findDomainBounds(dataset);
    assertEquals(0.5, r.getLowerBound(), EPSILON);
    assertEquals(2.1, r.getUpperBound(), EPSILON);
}
 
Example #26
Source File: ChartJFreeChartOutputScatter.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void createNewSerie(final IScope scope, final String serieid) {

	final ChartDataSeries dataserie = chartdataset.getDataSeries(scope, serieid);
	final XYIntervalSeries serie = new XYIntervalSeries(dataserie.getSerieLegend(scope), false, true);
	final XYPlot plot = (XYPlot) this.chart.getPlot();

	final XYIntervalSeriesCollection firstdataset = (XYIntervalSeriesCollection) plot.getDataset();

	if (!IdPosition.containsKey(serieid)) {

		if (firstdataset.getSeriesCount() == 0) {
			firstdataset.addSeries(serie);
			plot.setDataset(0, firstdataset);

		} else {

			final XYIntervalSeriesCollection newdataset = new XYIntervalSeriesCollection();
			newdataset.addSeries(serie);
			jfreedataset.add(newdataset);
			plot.setDataset(jfreedataset.size() - 1, newdataset);

		}
		plot.setRenderer(jfreedataset.size() - 1, (XYItemRenderer) getOrCreateRenderer(scope, serieid));
		IdPosition.put(serieid, jfreedataset.size() - 1);
		// DEBUG.LOG("new serie"+serieid+" at
		// "+IdPosition.get(serieid)+" fdsize "+plot.getSeriesCount()+" jfds
		// "+jfreedataset.size()+" datasc "+plot.getDatasetCount());
		// TODO Auto-generated method stub

	}
}
 
Example #27
Source File: ChartJFreeChartOutputScatter.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void createChart(final IScope scope) {
	super.createChart(scope);

	jfreedataset.add(0, new XYIntervalSeriesCollection());
	PlotOrientation orientation = PlotOrientation.VERTICAL;
	if (reverse_axes) {
		orientation = PlotOrientation.HORIZONTAL;
	}

	switch (type) {
		case SERIES_CHART:
		case XY_CHART:
		case SCATTER_CHART:
			chart = ChartFactory.createXYLineChart(getName(), "", "",
					(XYIntervalSeriesCollection) jfreedataset.get(0), orientation, true, false, false);
			break;
		case BOX_WHISKER_CHART: {
			chart = ChartFactory.createBoxAndWhiskerChart(getName(), "Time", "Value",
					(BoxAndWhiskerCategoryDataset) jfreedataset.get(0), true);
			chart.setBackgroundPaint(new Color(249, 231, 236));

			break;
		}

	}

}
 
Example #28
Source File: ScatterPlotPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private void createUI() {

        final XYPlot plot = getPlot();
        plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
        plot.setNoDataMessage(NO_DATA_MESSAGE);
        int confidenceDSIndex = 0;
        int regressionDSIndex = 1;
        int scatterpointsDSIndex = 2;
        plot.setDataset(confidenceDSIndex, acceptableDeviationDataset);
        plot.setDataset(regressionDSIndex, regressionDataset);
        plot.setDataset(scatterpointsDSIndex, scatterpointsDataset);

        plot.addAnnotation(r2Annotation);

        final DeviationRenderer identityRenderer = new DeviationRenderer(true, false);
        identityRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
        identityRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);
        plot.setRenderer(confidenceDSIndex, identityRenderer);

        final DeviationRenderer regressionRenderer = new DeviationRenderer(true, false);
        regressionRenderer.setSeriesPaint(0, StatisticChartStyling.REGRESSION_DATA_PAINT);
        regressionRenderer.setSeriesFillPaint(0, StatisticChartStyling.REGRESSION_DATA_FILL_PAINT);
        plot.setRenderer(regressionDSIndex, regressionRenderer);

        final XYErrorRenderer scatterPointsRenderer = new XYErrorRenderer();
        scatterPointsRenderer.setDrawXError(true);
        scatterPointsRenderer.setErrorStroke(new BasicStroke(1));
        scatterPointsRenderer.setErrorPaint(StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
        scatterPointsRenderer.setSeriesShape(0, StatisticChartStyling.CORRELATIVE_POINT_SHAPE);
        scatterPointsRenderer.setSeriesOutlinePaint(0, StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
        scatterPointsRenderer.setSeriesFillPaint(0, StatisticChartStyling.CORRELATIVE_POINT_FILL_PAINT);
        scatterPointsRenderer.setSeriesLinesVisible(0, false);
        scatterPointsRenderer.setSeriesShapesVisible(0, true);
        scatterPointsRenderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
        scatterPointsRenderer.setSeriesToolTipGenerator(0, (dataset, series, item) -> {
            final XYIntervalSeriesCollection collection = (XYIntervalSeriesCollection) dataset;
            final Comparable key = collection.getSeriesKey(series);
            final double xValue = collection.getXValue(series, item);
            final double endYValue = collection.getEndYValue(series, item);
            final double yValue = collection.getYValue(series, item);
            return String.format("%s: mean = %6.2f, sigma = %6.2f | %s: value = %6.2f",
                                 getRasterName(), yValue, endYValue - yValue,
                                 key, xValue);
        });
        plot.setRenderer(scatterpointsDSIndex, scatterPointsRenderer);

        final boolean autoRangeIncludesZero = false;
        final boolean xLog = scatterPlotModel.xAxisLogScaled;
        final boolean yLog = scatterPlotModel.yAxisLogScaled;
        plot.setDomainAxis(
                StatisticChartStyling.updateScalingOfAxis(xLog, plot.getDomainAxis(), autoRangeIncludesZero));
        plot.setRangeAxis(StatisticChartStyling.updateScalingOfAxis(yLog, plot.getRangeAxis(), autoRangeIncludesZero));

        createUI(createChartPanel(chart), createInputParameterPanel(), bindingContext);

        plot.getDomainAxis().addChangeListener(domainAxisChangeListener);
        scatterPlotDisplay.setMouseWheelEnabled(true);
        scatterPlotDisplay.setMouseZoomable(true);
    }
 
Example #29
Source File: ProfilePlotPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void initComponents() {
    if (hasAlternativeView()) {
        getAlternativeView().initComponents();
    }
    dataset = new XYIntervalSeriesCollection();
    this.chart = ChartFactory.createXYLineChart(
            CHART_TITLE,
            "Path in pixels",
            DEFAULT_SAMPLE_DATASET_NAME,
            dataset,
            PlotOrientation.VERTICAL,
            true,
            true,
            false
    );
    final XYPlot plot = chart.getXYPlot();

    deviationRenderer = new DeviationRenderer();
    deviationRenderer.setUseFillPaint(true);
    deviationRenderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator());
    deviationRenderer.setSeriesLinesVisible(0, true);
    deviationRenderer.setSeriesShapesVisible(0, false);
    deviationRenderer.setSeriesStroke(0, new BasicStroke(1.0f));
    deviationRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    deviationRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);

    pointRenderer = new XYErrorRenderer();
    pointRenderer.setUseFillPaint(true);
    pointRenderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator());
    pointRenderer.setSeriesLinesVisible(0, false);
    pointRenderer.setSeriesShapesVisible(0, true);
    pointRenderer.setSeriesStroke(0, new BasicStroke(1.0f));
    pointRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    pointRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);
    pointRenderer.setSeriesShape(0, StatisticChartStyling.SAMPLE_DATA_POINT_SHAPE);

    configureRendererForCorrelativeData(deviationRenderer);
    configureRendererForCorrelativeData(pointRenderer);

    plot.setNoDataMessage(NO_DATA_MESSAGE);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    plot.setRenderer(deviationRenderer);

    final AxisChangeListener axisListener = new AxisChangeListener() {
        @Override
        public void axisChanged(AxisChangeEvent event) {
            adjustAxisControlComponents();
        }
    };

    final ValueAxis domainAxis = plot.getDomainAxis();
    final ValueAxis rangeAxis = plot.getRangeAxis();
    // allow transfer from bounds into min/max fields, if auto min/maxis enabled
    domainAxis.setAutoRange(true);
    rangeAxis.setAutoRange(true);

    domainAxis.addChangeListener(axisListener);
    rangeAxis.addChangeListener(axisListener);

    intervalMarkers = new HashSet<>();

    xAxisRangeControl = new AxisRangeControl("X-Axis");
    yAxisRangeControl = new AxisRangeControl("Y-Axis");

    final PropertyChangeListener changeListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals(PROPERTY_NAME_MARK_SEGMENTS)) {
                updateDataSet();
            }
            if (evt.getPropertyName().equals(PROPERTY_NAME_LOG_SCALED)) {
                updateScalingOfYAxis();
            }
            updateUIState();
        }
    };
    xAxisRangeControl.getBindingContext().addPropertyChangeListener(changeListener);
    xAxisRangeControl.getBindingContext().getPropertySet().addProperty(Property.create(PROPERTY_NAME_MARK_SEGMENTS, false));
    xAxisRangeControl.getBindingContext().getPropertySet().getDescriptor(PROPERTY_NAME_MARK_SEGMENTS).setDescription("Toggle whether to mark segments");

    yAxisRangeControl.getBindingContext().addPropertyChangeListener(changeListener);
    yAxisRangeControl.getBindingContext().getPropertySet().addProperty(Property.create(PROPERTY_NAME_LOG_SCALED, false));
    yAxisRangeControl.getBindingContext().getPropertySet().getDescriptor(PROPERTY_NAME_LOG_SCALED).setDescription("Toggle whether to use a logarithmic axis");

    dataSourceConfig = new DataSourceConfig();
    final BindingContext bindingContext = new BindingContext(PropertyContainer.createObjectBacked(dataSourceConfig));

    JPanel middlePanel = createMiddlePanel(bindingContext);
    createUI(createChartPanel(chart), middlePanel, new RoiMaskSelector(bindingContext));

    isInitialized = true;

    updateComponents();
}
 
Example #30
Source File: IntervalXYSeriesCollector.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected Dataset createNewDataset() {
  return new XYIntervalSeriesCollection();
}