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

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

Introduction

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

Prototype

public void delete(int start, int end) 

Source Link

Document

Deletes data from start until end index (end inclusive).

Usage

From source file:org.activequant.util.charting.Chart.java

/**
 * Deletes data points that are older than given time stamp from <em>all datasets</em>.
 * This allows to keep sliding window of the data with the given width.
 * /*from   ww  w  .  j ava  2s.co m*/
 * @param datasetIndex index of the dataset to truncate.
 * 
 * @param timeStamp truncation threshold.
 */
public void deleteBefore(TimeStamp timeStamp) {
    for (TimeSeries ts : datasets) {
        int index = ts.getIndex(new Millisecond(timeStamp.getDate()));
        if (index >= 0) {
            ts.delete(0, index);
        }
    }
}

From source file:org.activequant.util.charting.Chart.java

/**
 * Deletes data points from a given dataset which are older than the time stamp.
 * This allows to keep sliding window of the data with the given width.
 * //from  ww w  .ja  v a2 s  .  co  m
 * @param datasetIndex index of the dataset to truncate.
 * 
 * @param timeStamp truncation threshold.
 */
public void deleteBefore(int datasetIndex, TimeStamp timeStamp) {
    if (datasetIndex >= datasets.size()) {
        throw new IllegalArgumentException(
                "wrong dataset index: size=" + datasets.size() + ", index=" + datasetIndex);
    }
    TimeSeries ts = datasets.get(datasetIndex);
    int index = ts.getIndex(new Millisecond(timeStamp.getDate()));
    if (index >= 0) {
        ts.delete(0, index);
    }
}

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

/**
 * Some checks for the delete(int, int) method.
 *///from w  w  w  .  java  2s .  co m
public void testDelete3() {
    TimeSeries s1 = new TimeSeries("S1");
    s1.add(new Year(2011), 1.1);
    s1.add(new Year(2012), 2.2);
    s1.add(new Year(2013), 3.3);
    s1.add(new Year(2014), 4.4);
    s1.add(new Year(2015), 5.5);
    s1.add(new Year(2016), 6.6);
    s1.delete(2, 5);
    assertEquals(2, s1.getItemCount());
    assertEquals(new Year(2011), s1.getTimePeriod(0));
    assertEquals(new Year(2012), s1.getTimePeriod(1));
    assertEquals(1.1, s1.getMinY(), EPSILON);
    assertEquals(2.2, s1.getMaxY(), EPSILON);
}

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

/**
 * Some checks for the delete(int, int) method.
 *///from   w w w. j av a2s . c om
@Test
public void testDelete3() {
    TimeSeries s1 = new TimeSeries("S1");
    s1.add(new Year(2011), 1.1);
    s1.add(new Year(2012), 2.2);
    s1.add(new Year(2013), 3.3);
    s1.add(new Year(2014), 4.4);
    s1.add(new Year(2015), 5.5);
    s1.add(new Year(2016), 6.6);
    s1.delete(2, 5);
    assertEquals(2, s1.getItemCount());
    assertEquals(new Year(2011), s1.getTimePeriod(0));
    assertEquals(new Year(2012), s1.getTimePeriod(1));
    assertEquals(1.1, s1.getMinY(), EPSILON);
    assertEquals(2.2, s1.getMaxY(), EPSILON);
}