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

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

Introduction

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

Prototype

public void add(double x, double xLow, double xHigh, double y) 

Source Link

Document

Adds a data item to the series and sends a SeriesChangeEvent to all registered listeners.

Usage

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

/**
 * Serialize an instance, restore it, and check for equality.
 *//*from  ww  w.j a  v a2  s  . c  o m*/
@Test
public void testSerialization() {
    XIntervalSeriesCollection c1 = new XIntervalSeriesCollection();
    XIntervalSeries s1 = new XIntervalSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3);
    XIntervalSeriesCollection c2 = (XIntervalSeriesCollection) TestUtilities.serialised(c1);
    assertEquals(c1, c2);
}

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

/**
 * Confirm that cloning works./*ww  w  .j  a  v a2 s  . c  o  m*/
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    XIntervalSeriesCollection c1 = new XIntervalSeriesCollection();
    XIntervalSeries s1 = new XIntervalSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3);
    c1.addSeries(s1);
    XIntervalSeriesCollection c2 = (XIntervalSeriesCollection) c1.clone();
    assertTrue(c1 != c2);
    assertTrue(c1.getClass() == c2.getClass());
    assertTrue(c1.equals(c2));

    // check independence
    s1.setDescription("XYZ");
    assertFalse(c1.equals(c2));
}

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

/**
 * Confirm that the equals method can distinguish all the required fields.
 */// w  ww  . j av a 2 s .c o  m
@Test
public void testEquals() {
    XIntervalSeriesCollection c1 = new XIntervalSeriesCollection();
    XIntervalSeriesCollection c2 = new XIntervalSeriesCollection();
    assertEquals(c1, c2);

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

    // add an empty series
    c1.addSeries(new XIntervalSeries("Empty Series"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new XIntervalSeries("Empty Series"));
    assertTrue(c1.equals(c2));
}

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

/**
 * Confirm that cloning works./*from ww w .ja  va 2  s.  com*/
 */
public void testCloning() {
    XIntervalSeriesCollection c1 = new XIntervalSeriesCollection();
    XIntervalSeries s1 = new XIntervalSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3);
    c1.addSeries(s1);
    XIntervalSeriesCollection c2 = null;
    try {
        c2 = (XIntervalSeriesCollection) c1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(c1 != c2);
    assertTrue(c1.getClass() == c2.getClass());
    assertTrue(c1.equals(c2));

    // check independence
    s1.setDescription("XYZ");
    assertFalse(c1.equals(c2));
}

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

/**
 * Serialize an instance, restore it, and check for equality.
 *//*from w  w w  . ja v a  2 s  .c o  m*/
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.junit.XIntervalSeriesCollectionTest.java

/**
 * Confirm that the equals method can distinguish all the required fields.
 *//*w  w w. j  a  v  a2 s. com*/
public void testEquals() {
    XIntervalSeriesCollection c1 = new XIntervalSeriesCollection();
    XIntervalSeriesCollection c2 = new XIntervalSeriesCollection();
    assertEquals(c1, c2);

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

    // add an empty series
    c1.addSeries(new XIntervalSeries("Empty Series"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new XIntervalSeries("Empty Series"));
    assertTrue(c1.equals(c2));
}

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

/**
 * Serialize an instance, restore it, and check for equality.
 *//*from   w w w.j av  a  2 s .com*/
@Test
public void testSerialization() {
    XIntervalSeries s1 = new XIntervalSeries("s1");
    s1.add(1.0, 0.5, 1.5, 2.0);
    XIntervalSeries s2 = (XIntervalSeries) TestUtilities.serialised(s1);
    assertEquals(s1, s2);
}

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

/**
 * A simple check for getXLowValue().//www .j av a  2 s  . c  o  m
 */
@Test
public void testGetXLowValue() {
    XIntervalSeries s1 = new XIntervalSeries("S1");
    s1.add(1.0, 2.0, 3.0, 4.0);
    assertEquals(2.0, s1.getXLowValue(0), EPSILON);
    s1.add(2.0, 1.0, 4.0, 2.5);
    assertEquals(1.0, s1.getXLowValue(1), EPSILON);
}

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

/**
 * A simple check for getXHighValue()./*from  w  ww  . jav  a  2  s .  co m*/
 */
@Test
public void testGetXHighValue() {
    XIntervalSeries s1 = new XIntervalSeries("S1");
    s1.add(1.0, 2.0, 3.0, 4.0);
    assertEquals(3.0, s1.getXHighValue(0), EPSILON);
    s1.add(2.0, 1.0, 4.0, 2.5);
    assertEquals(4.0, s1.getXHighValue(1), EPSILON);
}

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

/**
 * Confirm that cloning works./*from   www  . j  a  v a2s. com*/
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    XIntervalSeries s1 = new XIntervalSeries("s1");
    s1.add(1.0, 0.5, 1.5, 2.0);
    XIntervalSeries s2 = (XIntervalSeries) s1.clone();
    assertTrue(s1 != s2);
    assertTrue(s1.getClass() == s2.getClass());
    assertTrue(s1.equals(s2));
}