Java Code Examples for org.jfree.data.xy.XYSeries#updateByIndex()

The following examples show how to use org.jfree.data.xy.XYSeries#updateByIndex() . 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: XYSeriesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the updateByIndex() method.
 */
public void testUpdateByIndex() {
    XYSeries s1 = new XYSeries("S1");
    s1.add(1.0, 1.1);
    s1.add(2.0, 2.2);
    s1.add(3.0, 3.3);

    assertEquals(1.1, s1.getMinY(), EPSILON);
    assertEquals(3.3, s1.getMaxY(), EPSILON);

    s1.updateByIndex(0, new Double(-5.0));
    assertEquals(-5.0, s1.getMinY(), EPSILON);
    assertEquals(3.3, s1.getMaxY(), EPSILON);

    s1.updateByIndex(0, null);
    assertEquals(2.2, s1.getMinY(), EPSILON);
    assertEquals(3.3, s1.getMaxY(), EPSILON);

    s1.updateByIndex(2, null);
    assertEquals(2.2, s1.getMinY(), EPSILON);
    assertEquals(2.2, s1.getMaxY(), EPSILON);

    s1.updateByIndex(1, null);
    assertTrue(Double.isNaN(s1.getMinY()));
    assertTrue(Double.isNaN(s1.getMaxY()));
}
 
Example 2
Source File: XYSeriesTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some checks for the updateByIndex() method.
 */
public void testUpdateByIndex2() {
    XYSeries s1 = new XYSeries("S1");
    s1.add(1.0, Double.NaN);

    assertTrue(Double.isNaN(s1.getMinY()));
    assertTrue(Double.isNaN(s1.getMaxY()));

    s1.updateByIndex(0, new Double(1.0));
    assertEquals(1.0, s1.getMinY(), EPSILON);
    assertEquals(1.0, s1.getMaxY(), EPSILON);

    s1.updateByIndex(0, new Double(2.0));
    assertEquals(2.0, s1.getMinY(), EPSILON);
    assertEquals(2.0, s1.getMaxY(), EPSILON);

    s1.add(-1.0, -1.0);
    s1.updateByIndex(0, new Double(0.0));
    assertEquals(0.0, s1.getMinY(), EPSILON);
    assertEquals(2.0, s1.getMaxY(), EPSILON);
}
 
Example 3
Source File: XYSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the updateByIndex() method.
 */
public void testUpdateByIndex3() {
    XYSeries s1 = new XYSeries("S1");
    s1.add(1.0, 1.1);
    s1.add(2.0, 2.2);
    s1.add(3.0, 3.3);

    s1.updateByIndex(1, new Double(2.05));
    assertEquals(1.1, s1.getMinY(), EPSILON);
    assertEquals(3.3, s1.getMaxY(), EPSILON);
}