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

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

Introduction

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

Prototype

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

Source Link

Document

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

Usage

From source file:org.jfree.chart.demo.XYErrorRendererDemo1.java

private static IntervalXYDataset createDataset() {
    XYIntervalSeriesCollection xyintervalseriescollection = new XYIntervalSeriesCollection();
    XYIntervalSeries xyintervalseries = new XYIntervalSeries("Series 1");
    xyintervalseries.add(1.0D, 0.5D, 1.5D, 10D, 9D, 11D);
    xyintervalseries.add(10D, 8.6999999999999993D, 11.210000000000001D, 6.0999999999999996D,
            4.3399999999999999D, 7.54D);
    xyintervalseries.add(17.800000000000001D, 16D, 18.899999999999999D, 4.5D, 3.1000000000000001D,
            5.7999999999999998D);/*from ww  w  . j ava 2s  .c  o m*/
    XYIntervalSeries xyintervalseries1 = new XYIntervalSeries("Series 2");
    xyintervalseries1.add(3D, 2.5D, 3.5D, 7D, 6D, 8D);
    xyintervalseries1.add(13D, 11.5D, 14.5D, 13D, 11.5D, 14.5D);
    xyintervalseries1.add(24D, 22.699999999999999D, 25.210000000000001D, 16.100000000000001D, 14.34D,
            17.539999999999999D);
    xyintervalseriescollection.addSeries(xyintervalseries);
    xyintervalseriescollection.addSeries(xyintervalseries1);
    return xyintervalseriescollection;
}

From source file:org.jfree.chart.demo.XYBarChartDemo7.java

private static void addItem(XYIntervalSeries xyintervalseries, RegularTimePeriod regulartimeperiod,
        RegularTimePeriod regulartimeperiod1, int i) {
    xyintervalseries.add(regulartimeperiod.getFirstMillisecond(), regulartimeperiod.getFirstMillisecond(),
            regulartimeperiod1.getLastMillisecond(), i, (double) i - 0.45000000000000001D,
            (double) i + 0.45000000000000001D);
}

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

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

    // check independence
    c1.addSeries(new XYIntervalSeries("Empty"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new XYIntervalSeries("Empty"));
    assertTrue(c1.equals(c2));
}

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

/**
 * Confirm that cloning works./* w  ww .  j ava2s. c o m*/
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    XYIntervalSeriesCollection c1 = new XYIntervalSeriesCollection();
    XYIntervalSeries s1 = new XYIntervalSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5);
    XYIntervalSeriesCollection c2 = (XYIntervalSeriesCollection) c1.clone();
    assertTrue(c1 != c2);
    assertTrue(c1.getClass() == c2.getClass());
    assertTrue(c1.equals(c2));

    // check independence
    c1.addSeries(new XYIntervalSeries("Empty"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new XYIntervalSeries("Empty"));
    assertTrue(c1.equals(c2));
}

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

/**
 * Confirm that the equals method can distinguish all the required fields.
 *///from   w  w w.j ava2 s  . c  o  m
@Test
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));
}

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

/**
 * Confirm that cloning works./*from   w  w w .  ja  v a  2 s.c  o  m*/
 */
public void testCloning() {
    XYIntervalSeriesCollection c1 = new XYIntervalSeriesCollection();
    XYIntervalSeries s1 = new XYIntervalSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5);
    XYIntervalSeriesCollection c2 = null;
    try {
        c2 = (XYIntervalSeriesCollection) c1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(c1 != c2);
    assertTrue(c1.getClass() == c2.getClass());
    assertTrue(c1.equals(c2));

    // check independence
    c1.addSeries(new XYIntervalSeries("Empty"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new XYIntervalSeries("Empty"));
    assertTrue(c1.equals(c2));
}

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

/**
 * Confirm that the equals method can distinguish all the required fields.
 *//*  ww w.  jav  a 2s .c o m*/
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));
}

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

/**
 * Serialize an instance, restore it, and check for equality.
 *///from w  ww.j av  a 2  s.  c  o m
public void testSerialization() {
    XYIntervalSeriesCollection c1 = new XYIntervalSeriesCollection();
    XYIntervalSeries s1 = new XYIntervalSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5);
    XYIntervalSeriesCollection 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 = (XYIntervalSeriesCollection) in.readObject();
        in.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(c1, c2);

    // check independence
    c1.addSeries(new XYIntervalSeries("Empty"));
    assertFalse(c1.equals(c2));
    c2.addSeries(new XYIntervalSeries("Empty"));
    assertTrue(c1.equals(c2));
}

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

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

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

/**
 * Confirm that cloning works./*from  w  w w  .j  a va 2  s  .co m*/
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    XYIntervalSeries s1 = new XYIntervalSeries("s1");
    s1.add(1.0, 0.5, 1.5, 2.0, 1.9, 2.01);
    XYIntervalSeries s2 = (XYIntervalSeries) s1.clone();
    assertTrue(s1 != s2);
    assertTrue(s1.getClass() == s2.getClass());
    assertTrue(s1.equals(s2));
}