public class

DynamicTimeSeriesCollection

extends AbstractIntervalXYDataset
implements DomainInfo RangeInfo IntervalXYDataset
java.lang.Object
   ↳ org.jfree.data.general.AbstractDataset
     ↳ org.jfree.data.general.AbstractSeriesDataset
       ↳ org.jfree.data.xy.AbstractXYDataset
         ↳ org.jfree.data.xy.AbstractIntervalXYDataset
           ↳ org.jfree.data.time.DynamicTimeSeriesCollection

Class Overview

A dynamic dataset.

Like FastTimeSeriesCollection, this class is a functional replacement for JFreeChart's TimeSeriesCollection _and_ TimeSeries classes. FastTimeSeriesCollection is appropriate for a fixed time range; for real-time applications this subclass adds the ability to append new data and discard the oldest. In this class, the arrays used in FastTimeSeriesCollection become FIFO's. NOTE:As presented here, all data is assumed >= 0, an assumption which is embodied only in methods associated with interface RangeInfo.

Summary

Nested Classes
class DynamicTimeSeriesCollection.ValueSequence A wrapper for a fixed array of float values. 
Constants
int END Useful constant for controlling the x-value returned for a time period.
int MIDDLE Useful constant for controlling the x-value returned for a time period.
int START Useful constant for controlling the x-value returned for a time period.
Fields
protected int historyCount The history count.
protected RegularTimePeriod[] pointsInTime Storage for the x-values.
protected ValueSequence[] valueHistory An array for storing the objects that represent each series.
protected Calendar workingCalendar A working calendar (to recycle)
Public Constructors
DynamicTimeSeriesCollection(int nSeries, int nMoments)
Constructs a dataset with capacity for N series, tied to default timezone.
DynamicTimeSeriesCollection(int nSeries, int nMoments, TimeZone zone)
Constructs an empty dataset, tied to a specific timezone.
DynamicTimeSeriesCollection(int nSeries, int nMoments, RegularTimePeriod timeSample)
Creates a new dataset.
DynamicTimeSeriesCollection(int nSeries, int nMoments, RegularTimePeriod timeSample, TimeZone zone)
Creates a new dataset.
Public Methods
void addSeries(float[] values, int seriesNumber, Comparable seriesKey)
Adds a series to the dataset.
void addValue(int seriesNumber, int index, float value)
Adds a value to a series.
synchronized RegularTimePeriod advanceTime()
Adjust the array offset as needed when a new time-period is added: Increments the indices "oldestAt" and "newestAt", mod(array length), zeroes the series values at newestAt, returns the new TimePeriod.
void appendData(float[] newData, int insertionIndex, int refresh)
Appends data at specified index, for loading up with data from file(s).
void appendData(float[] newData)
Appends new data.
Range getDomainBounds(boolean includeInterval)
Returns the range of the values in this dataset's domain.
double getDomainLowerBound(boolean includeInterval)
Returns the minimum x-value in the dataset.
double getDomainUpperBound(boolean includeInterval)
Returns the maximum x-value in the dataset.
Number getEndX(int series, int item)
Returns the end x-value.
Number getEndY(int series, int item)
Returns the end y-value.
int getItemCount(int series)
Returns the number of items in a series.
int getNewestIndex()
Returns the index of the newest data item.
RegularTimePeriod getNewestTime()
Returns the newest time.
int getOldestIndex()
Returns the index of the oldest data item.
RegularTimePeriod getOldestTime()
Returns the oldest time.
int getPosition()
Returns the x position type (START, MIDDLE or END).
Range getRangeBounds(boolean includeInterval)
Returns the value range.
double getRangeLowerBound(boolean includeInterval)
Returns the minimum range value.
double getRangeUpperBound(boolean includeInterval)
Returns the maximum range value.
int getSeriesCount()
Returns the number of series in the collection.
Comparable getSeriesKey(int series)
Returns the key for a series.
Number getStartX(int series, int item)
Returns the start x-value.
Number getStartY(int series, int item)
Returns the start y-value.
Number getX(int series, int item)
Returns the x-value.
Number getY(int series, int item)
Returns the y-value.
double getYValue(int series, int item)
Returns the y-value.
void invalidateRangeInfo()
Invalidates the range info.
int offsetFromNewest(int delta)
Returns the actual index to a time offset by "delta" from newestAt.
int offsetFromOldest(int delta)
??
void setPosition(int position)
Sets the x position type (START, MIDDLE or END).
void setSeriesKey(int seriesNumber, Comparable key)
Sets the name of a series.
synchronized long setTimeBase(RegularTimePeriod start)
Fill the pointsInTime with times using TimePeriod.next(): Will silently return if the time array was already populated.
Protected Methods
void findDomainLimits()
Finds the domain limits.
double findMaxValue()
Returns the maximum value.
void fireSeriesChanged()
Sends a SeriesChangeEvent to all registered listeners.
int translateGet(int toFetch)
Re-map an index, for use in retrieving data.
int wrapOffset(int protoIndex)
??
[Expand]
Inherited Methods
From class org.jfree.data.xy.AbstractIntervalXYDataset
From class org.jfree.data.xy.AbstractXYDataset
From class org.jfree.data.general.AbstractSeriesDataset
From class org.jfree.data.general.AbstractDataset
From class java.lang.Object
From interface java.io.ObjectInputValidation
From interface org.jfree.data.DomainInfo
From interface org.jfree.data.RangeInfo
From interface org.jfree.data.general.Dataset
From interface org.jfree.data.general.SeriesChangeListener
From interface org.jfree.data.general.SeriesDataset
From interface org.jfree.data.xy.IntervalXYDataset
From interface org.jfree.data.xy.XYDataset

Constants

public static final int END

Useful constant for controlling the x-value returned for a time period.

Constant Value: 2 (0x00000002)

public static final int MIDDLE

Useful constant for controlling the x-value returned for a time period.

Constant Value: 1 (0x00000001)

public static final int START

Useful constant for controlling the x-value returned for a time period.

Constant Value: 0 (0x00000000)

Fields

protected int historyCount

The history count.

protected RegularTimePeriod[] pointsInTime

Storage for the x-values.

protected ValueSequence[] valueHistory

An array for storing the objects that represent each series.

protected Calendar workingCalendar

A working calendar (to recycle)

Public Constructors

public DynamicTimeSeriesCollection (int nSeries, int nMoments)

Constructs a dataset with capacity for N series, tied to default timezone.

Parameters
nSeries the number of series to be accommodated.
nMoments the number of TimePeriods to be spanned.

public DynamicTimeSeriesCollection (int nSeries, int nMoments, TimeZone zone)

Constructs an empty dataset, tied to a specific timezone.

Parameters
nSeries the number of series to be accommodated
nMoments the number of TimePeriods to be spanned
zone the timezone.

public DynamicTimeSeriesCollection (int nSeries, int nMoments, RegularTimePeriod timeSample)

Creates a new dataset.

Parameters
nSeries the number of series.
nMoments the number of items per series.
timeSample a time period sample.

public DynamicTimeSeriesCollection (int nSeries, int nMoments, RegularTimePeriod timeSample, TimeZone zone)

Creates a new dataset.

Parameters
nSeries the number of series.
nMoments the number of items per series.
timeSample a time period sample.
zone the time zone.

Public Methods

public void addSeries (float[] values, int seriesNumber, Comparable seriesKey)

Adds a series to the dataset. Only the y-values are supplied, the x-values are specified elsewhere.

Parameters
values the y-values.
seriesNumber the series index (zero-based).
seriesKey the series key. Use this as-is during setup only, or add the synchronized keyword around the copy loop.

public void addValue (int seriesNumber, int index, float value)

Adds a value to a series.

Parameters
seriesNumber the series index.
index ??.
value the value.

public synchronized RegularTimePeriod advanceTime ()

Adjust the array offset as needed when a new time-period is added: Increments the indices "oldestAt" and "newestAt", mod(array length), zeroes the series values at newestAt, returns the new TimePeriod.

Returns
  • The new time period.

public void appendData (float[] newData, int insertionIndex, int refresh)

Appends data at specified index, for loading up with data from file(s).

Parameters
newData the data
insertionIndex the index value at which to put it
refresh value of n in "refresh the display on every nth call" (ignored if <= 0 )

public void appendData (float[] newData)

Appends new data.

Parameters
newData the data.

public Range getDomainBounds (boolean includeInterval)

Returns the range of the values in this dataset's domain.

Parameters
includeInterval a flag that determines whether or not the x-interval is taken into account.
Returns
  • The range.

public double getDomainLowerBound (boolean includeInterval)

Returns the minimum x-value in the dataset.

Parameters
includeInterval a flag that determines whether or not the x-interval is taken into account.
Returns
  • The minimum value.

public double getDomainUpperBound (boolean includeInterval)

Returns the maximum x-value in the dataset.

Parameters
includeInterval a flag that determines whether or not the x-interval is taken into account.
Returns
  • The maximum value.

public Number getEndX (int series, int item)

Returns the end x-value.

Parameters
series the series index (zero-based).
item the item index (zero-based).
Returns
  • The value.

public Number getEndY (int series, int item)

Returns the end y-value.

Parameters
series the series index (zero-based).
item the item index (zero-based).
Returns
  • The value.

public int getItemCount (int series)

Returns the number of items in a series.

For this implementation, all series have the same number of items.

Parameters
series the series index (zero-based).
Returns
  • The item count.

public int getNewestIndex ()

Returns the index of the newest data item.

Returns
  • The index.

public RegularTimePeriod getNewestTime ()

Returns the newest time.

Returns
  • The newest time.

public int getOldestIndex ()

Returns the index of the oldest data item.

Returns
  • The index.

public RegularTimePeriod getOldestTime ()

Returns the oldest time.

Returns
  • The oldest time.

public int getPosition ()

Returns the x position type (START, MIDDLE or END).

Returns
  • The x position type.

public Range getRangeBounds (boolean includeInterval)

Returns the value range.

Parameters
includeInterval a flag that determines whether or not the y-interval is taken into account.
Returns
  • The range.

public double getRangeLowerBound (boolean includeInterval)

Returns the minimum range value.

Parameters
includeInterval a flag that determines whether or not the y-interval is taken into account.
Returns
  • The minimum range value.

public double getRangeUpperBound (boolean includeInterval)

Returns the maximum range value.

Parameters
includeInterval a flag that determines whether or not the y-interval is taken into account.
Returns
  • The maximum range value.

public int getSeriesCount ()

Returns the number of series in the collection.

Returns
  • The series count.

public Comparable getSeriesKey (int series)

Returns the key for a series.

Parameters
series the series index (zero-based).
Returns
  • The key.

public Number getStartX (int series, int item)

Returns the start x-value.

Parameters
series the series index (zero-based).
item the item index (zero-based).
Returns
  • The value.

public Number getStartY (int series, int item)

Returns the start y-value.

Parameters
series the series index (zero-based).
item the item index (zero-based).
Returns
  • The value.

public Number getX (int series, int item)

Returns the x-value.

Parameters
series the series index (zero-based).
item the item index (zero-based).
Returns
  • The value.

public Number getY (int series, int item)

Returns the y-value.

Parameters
series the series index (zero-based).
item the item index (zero-based).
Returns
  • The value.

public double getYValue (int series, int item)

Returns the y-value.

Parameters
series the series index (zero-based).
item the item index (zero-based).
Returns
  • The value.

public void invalidateRangeInfo ()

Invalidates the range info.

public int offsetFromNewest (int delta)

Returns the actual index to a time offset by "delta" from newestAt.

Parameters
delta the delta.
Returns
  • The offset.

public int offsetFromOldest (int delta)

??

Parameters
delta ??
Returns
  • The offset.

public void setPosition (int position)

Sets the x position type (START, MIDDLE or END).

Parameters
position The x position type.

public void setSeriesKey (int seriesNumber, Comparable key)

Sets the name of a series. If planning to add values individually.

Parameters
seriesNumber the series.
key the new key.

public synchronized long setTimeBase (RegularTimePeriod start)

Fill the pointsInTime with times using TimePeriod.next(): Will silently return if the time array was already populated. Also computes the data cached for later use by methods implementing the DomainInfo interface:

Parameters
start the start.
Returns
  • ??.

Protected Methods

protected void findDomainLimits ()

Finds the domain limits. Note: this doesn't need to be synchronized because it's called from within another method that already is.

protected double findMaxValue ()

Returns the maximum value.

Returns
  • The maximum value.

protected void fireSeriesChanged ()

Sends a SeriesChangeEvent to all registered listeners.

protected int translateGet (int toFetch)

Re-map an index, for use in retrieving data.

Parameters
toFetch the index.
Returns
  • The translated index.

protected int wrapOffset (int protoIndex)

??

Parameters
protoIndex the index.
Returns
  • The offset.