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

The following examples show how to use org.jfree.data.xy.XYSeries#addOrUpdate() . 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 addOrUpdate() method.
 */
public void testAddOrUpdate() {
    XYSeries series = new XYSeries("S1", true, false);
    XYDataItem old = series.addOrUpdate(new Long(1), new Long(2));
    assertTrue(old == null);
    assertEquals(1, series.getItemCount());
    assertEquals(new Long(2), series.getY(0));

    old = series.addOrUpdate(new Long(2), new Long(3));
    assertTrue(old == null);
    assertEquals(2, series.getItemCount());
    assertEquals(new Long(3), series.getY(1));

    old = series.addOrUpdate(new Long(1), new Long(99));
    assertEquals(new XYDataItem(new Long(1), new Long(2)), old);
    assertEquals(2, series.getItemCount());
    assertEquals(new Long(99), series.getY(0));
    assertEquals(new Long(3), series.getY(1));
}
 
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 addOrUpdate() method.
 */
public void testAddOrUpdate() {
    XYSeries series = new XYSeries("S1");
    XYDataItem old = series.addOrUpdate(new Long(1), new Long(2));
    assertTrue(old == null);
    assertEquals(1, series.getItemCount());
    assertEquals(new Long(2), series.getY(0));
    
    old = series.addOrUpdate(new Long(2), new Long(3));
    assertTrue(old == null);
    assertEquals(2, series.getItemCount());
    assertEquals(new Long(3), series.getY(1));

    old = series.addOrUpdate(new Long(1), new Long(99));
    assertEquals(new XYDataItem(new Long(1), new Long(2)), old);
    assertEquals(2, series.getItemCount());
    assertEquals(new Long(99), series.getY(0));
    assertEquals(new Long(3), series.getY(1));
}
 
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 addOrUpdate() method for an UNSORTED series.
 */
public void testAddOrUpdate2() {
    XYSeries series = new XYSeries("Series", false, false);
    series.add(5.0, 5.5);
    series.add(6.0, 6.6);
    series.add(3.0, 3.3);
    series.add(4.0, 4.4);
    series.add(2.0, 2.2);
    series.add(1.0, 1.1);
    series.addOrUpdate(new Double(3.0), new Double(33.3));
    series.addOrUpdate(new Double(2.0), new Double(22.2));
    assertEquals(33.3, series.getY(2).doubleValue(), EPSILON);
    assertEquals(22.2, series.getY(4).doubleValue(), EPSILON);
}
 
Example 4
Source File: XYSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Another test for the addOrUpdate() method.
 */
public void testAddOrUpdate3() {
    XYSeries series = new XYSeries("Series", false, true);
    series.addOrUpdate(1.0, 1.0);
    series.addOrUpdate(1.0, 2.0);
    series.addOrUpdate(1.0, 3.0);
    assertEquals(new Double(1.0), series.getY(0));
    assertEquals(new Double(2.0), series.getY(1));
    assertEquals(new Double(3.0), series.getY(2));
    assertEquals(3, series.getItemCount());
}
 
Example 5
Source File: XYSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Another test for the addOrUpdate() method.
 */
public void testBug1955483() {
    XYSeries series = new XYSeries("Series", true, true);
    series.addOrUpdate(1.0, 1.0);
    series.addOrUpdate(1.0, 2.0);
    assertEquals(new Double(1.0), series.getY(0));
    assertEquals(new Double(2.0), series.getY(1));
    assertEquals(2, series.getItemCount());
}
 
Example 6
Source File: XYSeriesTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some checks for the addOrUpdate() method for an UNSORTED series.
 */
public void testAddOrUpdate2() {
    XYSeries series = new XYSeries("Series", false, true);
    series.add(5.0, 5.5);
    series.add(6.0, 6.6);
    series.add(3.0, 3.3);
    series.add(4.0, 4.4);
    series.add(2.0, 2.2);
    series.add(1.0, 1.1);
    series.addOrUpdate(new Double(3.0), new Double(33.3));
    series.addOrUpdate(new Double(2.0), new Double(22.2));
    assertEquals(33.3, series.getY(2).doubleValue(), EPSILON);
    assertEquals(22.2, series.getY(4).doubleValue(), EPSILON);
}