Example usage for org.jfree.data.time TimeSeries equals

List of usage examples for org.jfree.data.time TimeSeries equals

Introduction

In this page you can find the example usage for org.jfree.data.time TimeSeries equals.

Prototype

@Override
public boolean equals(Object obj) 

Source Link

Document

Tests the series for equality with an arbitrary object.

Usage

From source file:de.citec.csra.allocation.vis.MovingChart.java

/**
 * Generates an random entry for a particular call made by time for every
 * 1/4th of a second./*from  w  w w  .  j a  v a  2 s .  co  m*/
 *
 * @param e the action event.
 */
@Override
public void actionPerformed(final ActionEvent e) {

    this.plustime.addOrUpdate(new Millisecond(new Date(System.currentTimeMillis() + this.future)), 0);
    List<TimeSeries> ts = this.dataset.getSeries();
    List<TimeSeries> del = new LinkedList<>();
    long now = System.currentTimeMillis();
    marker.setValue(now);
    int active = 0;
    for (TimeSeries t : ts) {
        if (!t.equals(this.plustime)) {
            List<TimeSeriesDataItem> its = t.getItems();
            long last = 0;
            for (TimeSeriesDataItem it : its) {
                long end = it.getPeriod().getLastMillisecond();
                if (end > last) {
                    last = end;
                }
            }
            if (now - last > this.past) {
                del.add(t);
            } else {
                active++;
            }
        }
    }

    synchronized (this.dataset) {
        if (active == 0) {
            for (TimeSeries d : del) {
                this.dataset.removeSeries(d);
            }
            if (del.size() > 0) {
                this.chart.getXYPlot().setRenderer(new XYLineAndShapeRenderer(true, false));
                XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) this.chart.getXYPlot()
                        .getRendererForDataset(dataset);
                r.setSeriesPaint(0, Color.BLACK);
            }
        }
    }
}

From source file:org.jfree.data.time.TimeSeriesCollectionTest.java

/**
 * Tests the remove series method.//  w  w  w .  j  av a 2s  .c o  m
 */
@Test
public void testRemoveSeries() {
    TimeSeriesCollection c1 = new TimeSeriesCollection();

    TimeSeries s1 = new TimeSeries("Series 1");
    TimeSeries s2 = new TimeSeries("Series 2");
    TimeSeries s3 = new TimeSeries("Series 3");
    TimeSeries s4 = new TimeSeries("Series 4");

    c1.addSeries(s1);
    c1.addSeries(s2);
    c1.addSeries(s3);
    c1.addSeries(s4);

    c1.removeSeries(s3);

    TimeSeries s = c1.getSeries(2);
    boolean b1 = s.equals(s4);
    assertTrue(b1);
}

From source file:org.jfree.data.time.junit.TimeSeriesTest.java

/**
 * Tests a specific bug report where null arguments in the constructor
 * cause the equals() method to fail.  Fixed for 0.9.21.
 *//*from   w ww.  j  a v a  2 s .co  m*/
public void testEquals2() {
    TimeSeries s1 = new TimeSeries("Series", null, null);
    TimeSeries s2 = new TimeSeries("Series", null, null);
    assertTrue(s1.equals(s2));
}

From source file:org.jfree.data.time.junit.TimeSeriesTest.java

/**
 * Tests the equals method.//from  w  w w  .  j  a  v  a  2 s.c  o m
 */
public void testEquals() {
    TimeSeries s1 = new TimeSeries("Time Series 1");
    TimeSeries s2 = new TimeSeries("Time Series 2");
    boolean b1 = s1.equals(s2);
    assertFalse("b1", b1);

    s2.setKey("Time Series 1");
    boolean b2 = s1.equals(s2);
    assertTrue("b2", b2);

    RegularTimePeriod p1 = new Day();
    RegularTimePeriod p2 = p1.next();
    s1.add(p1, 100.0);
    s1.add(p2, 200.0);
    boolean b3 = s1.equals(s2);
    assertFalse("b3", b3);

    s2.add(p1, 100.0);
    s2.add(p2, 200.0);
    boolean b4 = s1.equals(s2);
    assertTrue("b4", b4);

    s1.setMaximumItemCount(100);
    boolean b5 = s1.equals(s2);
    assertFalse("b5", b5);

    s2.setMaximumItemCount(100);
    boolean b6 = s1.equals(s2);
    assertTrue("b6", b6);

    s1.setMaximumItemAge(100);
    boolean b7 = s1.equals(s2);
    assertFalse("b7", b7);

    s2.setMaximumItemAge(100);
    boolean b8 = s1.equals(s2);
    assertTrue("b8", b8);
}

From source file:org.jfree.data.time.TimeSeriesTest.java

/**
 * Two classes with different period classes are NOT the same.
 *//*from w w w .  j av a2 s  .c om*/
@Test
public void testEquals3() {
    TimeSeries s1 = new TimeSeries("Series", Day.class);
    TimeSeries s2 = new TimeSeries("Series", Month.class);
    assertFalse(s1.equals(s2));
}

From source file:org.jfree.data.time.TimeSeriesTest.java

/**
 * Tests a specific bug report where null arguments in the constructor
 * cause the equals() method to fail.  Fixed for 0.9.21.
 */// w w  w . j  av  a  2  s . c  o m
@Test
public void testEquals2() {
    TimeSeries s1 = new TimeSeries("Series", null, null, Day.class);
    TimeSeries s2 = new TimeSeries("Series", null, null, Day.class);
    assertTrue(s1.equals(s2));
}

From source file:org.jfree.data.time.TimeSeriesTest.java

/**
 * Tests the equals method./*from w ww .ja  v a  2 s  .c  o m*/
 */
@Test
public void testEquals() {
    TimeSeries s1 = new TimeSeries("Time Series 1");
    TimeSeries s2 = new TimeSeries("Time Series 2");
    boolean b1 = s1.equals(s2);
    assertFalse("b1", b1);

    s2.setKey("Time Series 1");
    boolean b2 = s1.equals(s2);
    assertTrue("b2", b2);

    RegularTimePeriod p1 = new Day();
    RegularTimePeriod p2 = p1.next();
    s1.add(p1, 100.0);
    s1.add(p2, 200.0);
    boolean b3 = s1.equals(s2);
    assertFalse("b3", b3);

    s2.add(p1, 100.0);
    s2.add(p2, 200.0);
    boolean b4 = s1.equals(s2);
    assertTrue("b4", b4);

    s1.setMaximumItemCount(100);
    boolean b5 = s1.equals(s2);
    assertFalse("b5", b5);

    s2.setMaximumItemCount(100);
    boolean b6 = s1.equals(s2);
    assertTrue("b6", b6);

    s1.setMaximumItemAge(100);
    boolean b7 = s1.equals(s2);
    assertFalse("b7", b7);

    s2.setMaximumItemAge(100);
    boolean b8 = s1.equals(s2);
    assertTrue("b8", b8);
}

From source file:org.jfree.data.time.TimeSeriesTest.java

/**
 * A test for bug 1832432.//from w ww  .j ava 2s  .c o m
 */
@Test
public void testBug1832432() throws CloneNotSupportedException {
    TimeSeries s1 = new TimeSeries("Series");
    TimeSeries s2 = (TimeSeries) s1.clone();
    assertTrue(s1 != s2);
    assertTrue(s1.getClass() == s2.getClass());
    assertTrue(s1.equals(s2));

    // test independence
    s1.add(new Day(1, 1, 2007), 100.0);
    assertFalse(s1.equals(s2));
}

From source file:org.jfree.data.time.TimeSeriesTest.java

/**
 * Another test of the clone() method./*from  w w  w.ja v  a  2  s . c  o  m*/
 */
@Test
public void testClone2() throws CloneNotSupportedException {
    TimeSeries s1 = new TimeSeries("S1", Year.class);
    s1.add(new Year(2007), 100.0);
    s1.add(new Year(2008), null);
    s1.add(new Year(2009), 200.0);
    TimeSeries s2 = (TimeSeries) s1.clone();
    assertTrue(s1.equals(s2));

    // check independence
    s2.addOrUpdate(new Year(2009), 300.0);
    assertFalse(s1.equals(s2));
    s1.addOrUpdate(new Year(2009), 300.0);
    assertTrue(s1.equals(s2));
}

From source file:org.jfree.data.time.junit.TimeSeriesTest.java

/**
 * A test for bug 1832432.//from   w  w  w.j a  v a2s  .  co m
 */
public void testBug1832432() {
    TimeSeries s1 = new TimeSeries("Series");
    TimeSeries s2 = null;
    try {
        s2 = (TimeSeries) s1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(s1 != s2);
    assertTrue(s1.getClass() == s2.getClass());
    assertTrue(s1.equals(s2));

    // test independence
    s1.add(new Day(1, 1, 2007), 100.0);
    assertFalse(s1.equals(s2));
}