Example usage for org.jfree.data.xy XIntervalSeries XIntervalSeries

List of usage examples for org.jfree.data.xy XIntervalSeries XIntervalSeries

Introduction

In this page you can find the example usage for org.jfree.data.xy XIntervalSeries XIntervalSeries.

Prototype

public XIntervalSeries(Comparable key) 

Source Link

Document

Creates a new empty series.

Usage

From source file:org.jfree.data.xy.junit.XIntervalSeriesCollectionTest.java

/**
 * Serialize an instance, restore it, and check for equality.
 *//* w  w w.  j av  a 2  s  .c om*/
public void testSerialization() {
    XIntervalSeriesCollection c1 = new XIntervalSeriesCollection();
    XIntervalSeries s1 = new XIntervalSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3);
    XIntervalSeriesCollection c2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(c1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
        c2 = (XIntervalSeriesCollection) in.readObject();
        in.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(c1, c2);
}

From source file:org.jfree.data.xy.XIntervalSeriesTest.java

/**
 * Simple test for the indexOf() method.
 *///w  ww .  j a  v a2 s .  c om
@Test
public void testIndexOf() {
    XIntervalSeries s1 = new XIntervalSeries("Series 1");
    s1.add(1.0, 1.0, 1.0, 2.0);
    s1.add(2.0, 2.0, 2.0, 3.0);
    s1.add(3.0, 3.0, 3.0, 4.0);
    assertEquals(0, s1.indexOf(new Double(1.0)));
}

From source file:org.jfree.data.xy.XIntervalSeriesCollectionTest.java

/**
 * A test for bug report 1170825 (originally affected XYSeriesCollection,
 * this test is just copied over).// w ww .j a va2 s  .  c  o m
 */
@Test
public void test1170825() {
    XIntervalSeries s1 = new XIntervalSeries("Series1");
    XIntervalSeriesCollection dataset = new XIntervalSeriesCollection();
    dataset.addSeries(s1);
    try {
        /* XYSeries s = */ dataset.getSeries(1);
    } catch (IllegalArgumentException e) {
        // correct outcome
    } catch (IndexOutOfBoundsException e) {
        assertTrue(false); // wrong outcome
    }
}

From source file:org.jfree.data.xy.junit.XIntervalSeriesCollectionTest.java

/**
 * Some basic checks for the removeSeries() method.
 *//*from  ww w .j a  va2  s . c  om*/
public void testRemoveSeries() {
    XIntervalSeriesCollection c = new XIntervalSeriesCollection();
    XIntervalSeries s1 = new XIntervalSeries("s1");
    c.addSeries(s1);
    c.removeSeries(0);
    assertEquals(0, c.getSeriesCount());
    c.addSeries(s1);

    boolean pass = false;
    try {
        c.removeSeries(-1);
    } catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);

    pass = false;
    try {
        c.removeSeries(1);
    } catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}

From source file:org.jfree.data.xy.XIntervalSeriesTest.java

/**
 * Simple test for the remove() method.//from  w  w  w . j a va2  s  .c  o  m
 */
@Test
public void testRemove() {
    XIntervalSeries s1 = new XIntervalSeries("Series 1");
    s1.add(1.0, 1.0, 1.0, 2.0);
    s1.add(2.0, 2.0, 2.0, 2.0);
    s1.add(3.0, 3.0, 3.0, 3.0);
    assertEquals(3, s1.getItemCount());

    s1.remove(new Double(2.0));
    assertEquals(new Double(3.0), s1.getX(1));

    s1.remove(new Double(1.0));
    assertEquals(new Double(3.0), s1.getX(0));
}

From source file:org.jfree.data.xy.XIntervalSeriesTest.java

/**
 * When items are added with duplicate x-values, we expect them to remain
 * in the order they were added./*from  www  .  jav  a  2s .c om*/
 */
@Test
public void testAdditionOfDuplicateXValues() {
    XIntervalSeries s1 = new XIntervalSeries("Series 1");
    s1.add(1.0, 1.0, 1.0, 1.0);
    s1.add(2.0, 2.0, 2.0, 2.0);
    s1.add(2.0, 3.0, 3.0, 3.0);
    s1.add(2.0, 4.0, 4.0, 4.0);
    s1.add(3.0, 5.0, 5.0, 5.0);
    assertEquals(1.0, s1.getYValue(0), EPSILON);
    assertEquals(2.0, s1.getYValue(1), EPSILON);
    assertEquals(3.0, s1.getYValue(2), EPSILON);
    assertEquals(4.0, s1.getYValue(3), EPSILON);
    assertEquals(5.0, s1.getYValue(4), EPSILON);
}

From source file:org.jfree.data.xy.junit.XIntervalSeriesCollectionTest.java

/**
 * A test for bug report 1170825 (originally affected XYSeriesCollection,
 * this test is just copied over).//from  w w  w  .  jav  a  2 s.  c  o  m
 */
public void test1170825() {
    XIntervalSeries s1 = new XIntervalSeries("Series1");
    XIntervalSeriesCollection dataset = new XIntervalSeriesCollection();
    dataset.addSeries(s1);
    try {
        /* XYSeries s = */ dataset.getSeries(1);
    } catch (IllegalArgumentException e) {
        // correct outcome
    } catch (IndexOutOfBoundsException e) {
        assertTrue(false); // wrong outcome
    }
}

From source file:org.jfree.data.xy.XIntervalSeriesTest.java

/**
 * A simple check that the maximumItemCount attribute is working.
 *///from   ww  w.  j a  va2s.com
@Test
public void testSetMaximumItemCount() {
    XIntervalSeries s1 = new XIntervalSeries("S1");
    assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount());
    s1.setMaximumItemCount(2);
    assertEquals(2, s1.getMaximumItemCount());
    s1.add(1.0, 1.1, 1.1, 1.1);
    s1.add(2.0, 2.2, 2.2, 2.2);
    s1.add(3.0, 3.3, 3.3, 3.3);
    assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON);
    assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON);
}

From source file:org.jfree.data.xy.XIntervalSeriesTest.java

/**
 * Check that the maximum item count can be applied retrospectively.
 *//*from  w  w  w  .j  a  v  a  2  s. c om*/
@Test
public void testSetMaximumItemCount2() {
    XIntervalSeries s1 = new XIntervalSeries("S1");
    s1.add(1.0, 1.1, 1.1, 1.1);
    s1.add(2.0, 2.2, 2.2, 2.2);
    s1.add(3.0, 3.3, 3.3, 3.3);
    s1.setMaximumItemCount(2);
    assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON);
    assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON);
}

From source file:org.jfree.data.xy.XIntervalSeriesTest.java

/**
 * Some checks for the clear() method.//from ww w  . ja  va2  s. com
 */
@Test
public void testClear() {
    XIntervalSeries s1 = new XIntervalSeries("S1");
    s1.addChangeListener(this);
    s1.clear();
    assertNull(this.lastEvent);
    assertTrue(s1.isEmpty());
    s1.add(1.0, 2.0, 3.0, 4.0);
    assertFalse(s1.isEmpty());
    s1.clear();
    assertNotNull(this.lastEvent);
    assertTrue(s1.isEmpty());
}