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

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

Introduction

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

Prototype

public int getMaximumItemCount() 

Source Link

Document

Returns the maximum number of items that will be retained in the series.

Usage

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

/**
 * Some checks for the removeAgedItems() method.
 *//*w ww .  ja  va  2  s.co m*/
public void testRemoveAgedItems() {
    TimeSeries series = new TimeSeries("Test Series");
    series.addChangeListener(this);
    assertEquals(Long.MAX_VALUE, series.getMaximumItemAge());
    assertEquals(Integer.MAX_VALUE, series.getMaximumItemCount());
    this.gotSeriesChangeEvent = false;

    // test empty series
    series.removeAgedItems(true);
    assertEquals(0, series.getItemCount());
    assertFalse(this.gotSeriesChangeEvent);

    // test series with one item
    series.add(new Year(1999), 1.0);
    series.setMaximumItemAge(0);
    this.gotSeriesChangeEvent = false;
    series.removeAgedItems(true);
    assertEquals(1, series.getItemCount());
    assertFalse(this.gotSeriesChangeEvent);

    // test series with two items
    series.setMaximumItemAge(10);
    series.add(new Year(2001), 2.0);
    this.gotSeriesChangeEvent = false;
    series.setMaximumItemAge(2);
    assertEquals(2, series.getItemCount());
    assertEquals(0, series.getIndex(new Year(1999)));
    assertFalse(this.gotSeriesChangeEvent);
    series.setMaximumItemAge(1);
    assertEquals(1, series.getItemCount());
    assertEquals(0, series.getIndex(new Year(2001)));
    assertTrue(this.gotSeriesChangeEvent);
}

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

/**
 * Some checks for the removeAgedItems(long, boolean) method.
 *//*from  w w  w  .j a  v a2 s  .  c  o m*/
public void testRemoveAgedItems2() {
    long y2006 = 1157087372534L; // milliseconds somewhere in 2006
    TimeSeries series = new TimeSeries("Test Series");
    series.addChangeListener(this);
    assertEquals(Long.MAX_VALUE, series.getMaximumItemAge());
    assertEquals(Integer.MAX_VALUE, series.getMaximumItemCount());
    this.gotSeriesChangeEvent = false;

    // test empty series
    series.removeAgedItems(y2006, true);
    assertEquals(0, series.getItemCount());
    assertFalse(this.gotSeriesChangeEvent);

    // test a series with 1 item
    series.add(new Year(2004), 1.0);
    series.setMaximumItemAge(1);
    this.gotSeriesChangeEvent = false;
    series.removeAgedItems(new Year(2005).getMiddleMillisecond(), true);
    assertEquals(1, series.getItemCount());
    assertFalse(this.gotSeriesChangeEvent);
    series.removeAgedItems(y2006, true);
    assertEquals(0, series.getItemCount());
    assertTrue(this.gotSeriesChangeEvent);

    // test a series with two items
    series.setMaximumItemAge(2);
    series.add(new Year(2003), 1.0);
    series.add(new Year(2005), 2.0);
    assertEquals(2, series.getItemCount());
    this.gotSeriesChangeEvent = false;
    assertEquals(2, series.getItemCount());

    series.removeAgedItems(new Year(2005).getMiddleMillisecond(), true);
    assertEquals(2, series.getItemCount());
    assertFalse(this.gotSeriesChangeEvent);
    series.removeAgedItems(y2006, true);
    assertEquals(1, series.getItemCount());
    assertTrue(this.gotSeriesChangeEvent);
}

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

/**
 * Some checks for the removeAgedItems() method.
 *//*from  ww w . j a v a2  s. c o  m*/
@Test
public void testRemoveAgedItems() {
    TimeSeries series = new TimeSeries("Test Series", Year.class);
    series.addChangeListener(this);
    assertEquals(Long.MAX_VALUE, series.getMaximumItemAge());
    assertEquals(Integer.MAX_VALUE, series.getMaximumItemCount());
    this.gotSeriesChangeEvent = false;

    // test empty series
    series.removeAgedItems(true);
    assertEquals(0, series.getItemCount());
    assertFalse(this.gotSeriesChangeEvent);

    // test series with one item
    series.add(new Year(1999), 1.0);
    series.setMaximumItemAge(0);
    this.gotSeriesChangeEvent = false;
    series.removeAgedItems(true);
    assertEquals(1, series.getItemCount());
    assertFalse(this.gotSeriesChangeEvent);

    // test series with two items
    series.setMaximumItemAge(10);
    series.add(new Year(2001), 2.0);
    this.gotSeriesChangeEvent = false;
    series.setMaximumItemAge(2);
    assertEquals(2, series.getItemCount());
    assertEquals(0, series.getIndex(new Year(1999)));
    assertFalse(this.gotSeriesChangeEvent);
    series.setMaximumItemAge(1);
    assertEquals(1, series.getItemCount());
    assertEquals(0, series.getIndex(new Year(2001)));
    assertTrue(this.gotSeriesChangeEvent);
}

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

/**
 * Some checks for the removeAgedItems(long, boolean) method.
 *///from  w ww.  j a v  a2  s.c  o  m
@Test
public void testRemoveAgedItems2() {
    long y2006 = 1157087372534L; // milliseconds somewhere in 2006
    TimeSeries series = new TimeSeries("Test Series", Year.class);
    series.addChangeListener(this);
    assertEquals(Long.MAX_VALUE, series.getMaximumItemAge());
    assertEquals(Integer.MAX_VALUE, series.getMaximumItemCount());
    this.gotSeriesChangeEvent = false;

    // test empty series
    series.removeAgedItems(y2006, true);
    assertEquals(0, series.getItemCount());
    assertFalse(this.gotSeriesChangeEvent);

    // test a series with 1 item
    series.add(new Year(2004), 1.0);
    series.setMaximumItemAge(1);
    this.gotSeriesChangeEvent = false;
    series.removeAgedItems(new Year(2005).getMiddleMillisecond(), true);
    assertEquals(1, series.getItemCount());
    assertFalse(this.gotSeriesChangeEvent);
    series.removeAgedItems(y2006, true);
    assertEquals(0, series.getItemCount());
    assertTrue(this.gotSeriesChangeEvent);

    // test a series with two items
    series.setMaximumItemAge(2);
    series.add(new Year(2003), 1.0);
    series.add(new Year(2005), 2.0);
    assertEquals(2, series.getItemCount());
    this.gotSeriesChangeEvent = false;
    assertEquals(2, series.getItemCount());

    series.removeAgedItems(new Year(2005).getMiddleMillisecond(), true);
    assertEquals(2, series.getItemCount());
    assertFalse(this.gotSeriesChangeEvent);
    series.removeAgedItems(y2006, true);
    assertEquals(1, series.getItemCount());
    assertTrue(this.gotSeriesChangeEvent);
}

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

/**
 * Tests the series for equality with an arbitrary object.
 *
 * @param obj  the object to test against (<code>null</code> permitted).
 *
 * @return A boolean.// w w w .  jav  a 2s  .c om
 */
@Override
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }
    if (!(obj instanceof TimeSeries)) {
        return false;
    }
    TimeSeries that = (TimeSeries) obj;
    if (!ObjectUtilities.equal(getDomainDescription(), that.getDomainDescription())) {
        return false;
    }
    if (!ObjectUtilities.equal(getRangeDescription(), that.getRangeDescription())) {
        return false;
    }
    if (!ObjectUtilities.equal(this.timePeriodClass, that.timePeriodClass)) {
        return false;
    }
    if (getMaximumItemAge() != that.getMaximumItemAge()) {
        return false;
    }
    if (getMaximumItemCount() != that.getMaximumItemCount()) {
        return false;
    }
    int count = getItemCount();
    if (count != that.getItemCount()) {
        return false;
    }
    if (!ObjectUtilities.equal(this.data, that.data)) {
        return false;
    }
    return super.equals(obj);
}