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

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

Introduction

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

Prototype

public void removeAgedItems(boolean notify) 

Source Link

Document

Age items in the series.

Usage

From source file:com.bdb.weather.display.stripchart.StripChart.java

/**
 * Add an item to a series./* w  ww.  j av a2  s.  c  o m*/
 * 
 * @param seriesName The name of the series to which the data is to be added
 * @param time The time of the data
 * @param value The value of the data
 */
public void addItem(String seriesName, LocalDateTime time, double value) {
    TimeSeries timeSeries = series.get(seriesName);
    Instant instant = Instant.from(time.atZone(ZoneId.systemDefault()));
    Date res = Date.from(instant);

    if (timeSeries != null) {
        timeSeries.removeAgedItems(false);
        timeSeries.addOrUpdate(new Second(res), value);
        Calendar c = Calendar.getInstance();
        c.setTime(res);
        adjustDateAxis(c);
    }
}

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

/**
 * Some checks for the removeAgedItems() method.
 *//* w  w w . ja v  a2s  .  c  o  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.TimeSeriesTest.java

/**
 * Some checks for the removeAgedItems() method.
 *///from w ww. j av a2 s. com
@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);
}