Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jfree.data.time
Class DynamicTimeSeriesCollection

    java.lang.Object
      org.jfree.data.AbstractDataset
          org.jfree.data.AbstractSeriesDataset
              org.jfree.data.AbstractXYDataset
                  org.jfree.data.AbstractIntervalXYDataset
                      org.jfree.data.time.DynamicTimeSeriesCollection

All Implemented Interfaces:
  java.lang.Cloneable, Dataset, DomainInfo, java.util.EventListener, IntervalXYDataset, java.io.ObjectInputValidation, RangeInfo, java.io.Serializable, SeriesChangeListener, SeriesDataset, XYDataset

public class DynamicTimeSeriesCollection
extends AbstractIntervalXYDataset
implements IntervalXYDataset, DomainInfo, RangeInfo

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.

Author:
  Irv Thomae.
See Also:
  Serialized Form

Nested Class Summary
`protected class` | `DynamicTimeSeriesCollection.ValueSequence` A wrapper for a fixed array of float values.

Field Summary
`static int` | `END` Useful constant for controlling the x-value returned for a time period.
`protected int` | `historyCount` The history count.
`static int` | `MIDDLE` Useful constant for controlling the x-value returned for a time period.
`protected RegularTimePeriod[]` | `pointsInTime` Storage for the x-values.
`static int` | `START` Useful constant for controlling the x-value returned for a time period.
`protected DynamicTimeSeriesCollection.ValueSequence[]` | `valueHistory` An array for storing the objects that represent each series.
`protected java.util.Calendar` | `workingCalendar` A working calendar (to recycle)

Constructor Summary
`DynamicTimeSeriesCollection(int nSeries, int nMoments)` Constructs a dataset with capacity for N series, tied to default timezone.
`DynamicTimeSeriesCollection(int nSeries, int nMoments, RegularTimePeriod timeSample)` Creates a new dataset.
`DynamicTimeSeriesCollection(int nSeries, int nMoments, RegularTimePeriod timeSample, java.util.TimeZone zone)` Creates a new dataset.
`DynamicTimeSeriesCollection(int nSeries, int nMoments, java.util.TimeZone zone)` Constructs an empty dataset, tied to a specific timezone.

Method Summary
`void` | `addSeries(float[] values, int seriesNumber, java.lang.String seriesName)` Adds a series to the dataset.
`void` | `addValue(int seriesNumber, int index, float value)` Adds a value to a series.
`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)` Appends new data.
`void` | `appendData(float[] newData, int insertionIndex, int refresh)` Appends data at specified index, for loading up with data from file(s).
`protected void` | `findDomainLimits()` Finds the domain limits.
`protected double` | `findMaxValue()` Returns the maximum value.
`protected void` | `fireSeriesChanged()` Sends a `SeriesChangeEvent` to all registered listeners.
`Range` | `getDomainRange()` Returns the range of values for the domain.
`java.lang.Number` | `getEndXValue(int series, int item)` Returns the end x-value.
`java.lang.Number` | `getEndYValue(int series, int item)` Returns the end y-value.
`int` | `getItemCount(int series)` Returns the number of items in a series.
`java.lang.Number` | `getMaximumDomainValue()` Returns the maximum value in the dataset (or null if all the values in the domain are null).
`java.lang.Number` | `getMaximumRangeValue()` Returns the maximum range value.
`java.lang.Number` | `getMinimumDomainValue()` Returns the minimum value in the dataset (or null if all the values in the domain are null).
`java.lang.Number` | `getMinimumRangeValue()` Returns the minimum range value.
`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).
`int` | `getSeriesCount()` Returns the number of series in the collection.
`java.lang.String` | `getSeriesName(int series)` Returns the name of a series.
`java.lang.Number` | `getStartXValue(int series, int item)` Returns the start x-value.
`java.lang.Number` | `getStartYValue(int series, int item)` Returns the start y-value.
`Range` | `getValueRange()` Returns the value range.
`java.lang.Number` | `getXValue(int series, int item)` Returns the x-value.
`double` | `getY(int series, int item)` Returns the y-value.
`java.lang.Number` | `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` | `setSeriesName(int seriesNumber, java.lang.String newName)` Sets the name of a series.
`long` | `setTimeBase(RegularTimePeriod start)` Fill the pointsInTime with times using TimePeriod.next(): Will silently return if the time array was already populated.
`protected int` | `translateGet(int toFetch)` Re-map an index, for use in retrieving data.
`protected int` | `wrapOffset(int protoIndex)` ??

Methods inherited from class org.jfree.data.AbstractIntervalXYDataset
`getEndX, getEndY, getStartX, getStartY`

Methods inherited from class org.jfree.data.AbstractXYDataset
`getX`

Methods inherited from class org.jfree.data.AbstractSeriesDataset
`seriesChanged`

Methods inherited from class org.jfree.data.AbstractDataset
`addChangeListener, clone, fireDatasetChanged, getGroup, notifyListeners, removeChangeListener, setGroup, validateObject`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.jfree.data.IntervalXYDataset
`getEndX, getEndY, getStartX, getStartY`

Methods inherited from interface org.jfree.data.XYDataset
`getX`

Methods inherited from interface org.jfree.data.Dataset
`addChangeListener, getGroup, removeChangeListener, setGroup`

Field Detail

### START

    public static final int START

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

  See Also:
    Constant Field Values

### MIDDLE

    public static final int MIDDLE

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

  See Also:
    Constant Field Values

### END

    public static final int END

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

  See Also:
    Constant Field Values

### historyCount

    protected int historyCount

  The history count.

### pointsInTime

    protected RegularTimePeriod[] pointsInTime

  Storage for the x-values.

### valueHistory

    protected DynamicTimeSeriesCollection.ValueSequence[] valueHistory

  An array for storing the objects that represent each series.

### workingCalendar

    protected java.util.Calendar workingCalendar

  A working calendar (to recycle)

Constructor Detail

### DynamicTimeSeriesCollection

    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.

### DynamicTimeSeriesCollection

    public DynamicTimeSeriesCollection(int nSeries,
                                       int nMoments,
                                       java.util.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.

### DynamicTimeSeriesCollection

    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.

### DynamicTimeSeriesCollection

    public DynamicTimeSeriesCollection(int nSeries,
                                       int nMoments,
                                       RegularTimePeriod timeSample,
                                       java.util.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.

Method Detail

### setTimeBase

    public 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:
    ??.

### findDomainLimits

    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.

### getPosition

    public int getPosition()

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

  Returns:
    The x position type.

### setPosition

    public void setPosition(int position)

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

  Parameters:
    `position` - The x position type.

### addSeries

    public void addSeries(float[] values,
                          int seriesNumber,
                          java.lang.String seriesName)

  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).
    `seriesName` - the seriesName. Use this as-is during setup only, or add the synchronized keyword around the copy loop.

### setSeriesName

    public void setSeriesName(int seriesNumber,
                              java.lang.String newName)

  Sets the name of a series.

  If planning to add values individually.

  Parameters:
    `seriesNumber` - the series.
    `newName` - the new name.

### addValue

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

  Adds a value to a series.

  Parameters:
    `seriesNumber` - the series index.
    `index` - ??.
    `value` - the value.

### getSeriesCount

    public int getSeriesCount()

  Returns the number of series in the collection.

  Specified by:
    `getSeriesCount` in interface `SeriesDataset`
  Specified by:
    `getSeriesCount` in class `AbstractSeriesDataset`
  Returns:
    the series count.

### getItemCount

    public int getItemCount(int series)

  Returns the number of items in a series.

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

  Specified by:
    `getItemCount` in interface `XYDataset`
  Parameters:
    `series` - the series index (zero-based).
  Returns:
    The item count.

### translateGet

    protected int translateGet(int toFetch)

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

  Parameters:
    `toFetch` - the index.
  Returns:
    The translated index.

### offsetFromNewest

    public int offsetFromNewest(int delta)

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

  Parameters:
    `delta` - the delta.
  Returns:
    The offset.

### offsetFromOldest

    public int offsetFromOldest(int delta)

  ??

  Parameters:
    `delta` - ??
  Returns:
    The offset.

### wrapOffset

    protected int wrapOffset(int protoIndex)

  ??

  Parameters:
    `protoIndex` - the index.
  Returns:
    The offset.

### advanceTime

    public 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.

### invalidateRangeInfo

    public void invalidateRangeInfo()

  Invalidates the range info.

### findMaxValue

    protected double findMaxValue()

  Returns the maximum value.

  Returns:
    The maximum value.

### getOldestIndex

    public int getOldestIndex()

  Returns the index of the oldest data item.

  Returns:
    The index.

### getNewestIndex

    public int getNewestIndex()

  Returns the index of the newest data item.

  Returns:
    The index.

### appendData

    public void appendData(float[] newData)

  Appends new data.

  Parameters:
    `newData` - the data.

### appendData

    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 )

### getNewestTime

    public RegularTimePeriod getNewestTime()

  Returns the newest time.

  Returns:
    The newest time.

### getOldestTime

    public RegularTimePeriod getOldestTime()

  Returns the oldest time.

  Returns:
    The oldest time.

### getXValue

    public java.lang.Number getXValue(int series,
                                      int item)

  Returns the x-value.

  Specified by:
    `getXValue` in interface `XYDataset`
  Parameters:
    `series` - the series index (zero-based).
    `item` - the item index (zero-based).
  Returns:
    The value.

### getY

    public double getY(int series,
                       int item)

  Returns the y-value.

  Specified by:
    `getY` in interface `XYDataset`
  Overrides:
    `getY` in class `AbstractXYDataset`
  Parameters:
    `series` - the series index (zero-based).
    `item` - the item index (zero-based).
  Returns:
    The value.

### getYValue

    public java.lang.Number getYValue(int series,
                                      int item)

  Returns the y-value.

  Specified by:
    `getYValue` in interface `XYDataset`
  Parameters:
    `series` - the series index (zero-based).
    `item` - the item index (zero-based).
  Returns:
    The value.

### getStartXValue

    public java.lang.Number getStartXValue(int series,
                                           int item)

  Returns the start x-value.

  Specified by:
    `getStartXValue` in interface `IntervalXYDataset`
  Parameters:
    `series` - the series index (zero-based).
    `item` - the item index (zero-based).
  Returns:
    The value.

### getEndXValue

    public java.lang.Number getEndXValue(int series,
                                         int item)

  Returns the end x-value.

  Specified by:
    `getEndXValue` in interface `IntervalXYDataset`
  Parameters:
    `series` - the series index (zero-based).
    `item` - the item index (zero-based).
  Returns:
    The value.

### getStartYValue

    public java.lang.Number getStartYValue(int series,
                                           int item)

  Returns the start y-value.

  Specified by:
    `getStartYValue` in interface `IntervalXYDataset`
  Parameters:
    `series` - the series index (zero-based).
    `item` - the item index (zero-based).
  Returns:
    The value.

### getEndYValue

    public java.lang.Number getEndYValue(int series,
                                         int item)

  Returns the end y-value.

  Specified by:
    `getEndYValue` in interface `IntervalXYDataset`
  Parameters:
    `series` - the series index (zero-based).
    `item` - the item index (zero-based).
  Returns:
    The value.

### getSeriesName

    public java.lang.String getSeriesName(int series)

  Returns the name of a series.

  Specified by:
    `getSeriesName` in interface `SeriesDataset`
  Specified by:
    `getSeriesName` in class `AbstractSeriesDataset`
  Parameters:
    `series` - the series index (zero-based).
  Returns:
    The name.

### fireSeriesChanged

    protected void fireSeriesChanged()

  Sends a `SeriesChangeEvent` to all registered listeners.

### getDomainRange

    public Range getDomainRange()

  Returns the range of values for the domain.

  Specified by:
    `getDomainRange` in interface `DomainInfo`
  Returns:
    The range.

### getMinimumDomainValue

    public java.lang.Number getMinimumDomainValue()

  Returns the minimum value in the dataset (or null if all the values in the domain are null).

  Specified by:
    `getMinimumDomainValue` in interface `DomainInfo`
  Returns:
    the minimum value.

### getMaximumDomainValue

    public java.lang.Number getMaximumDomainValue()

  Returns the maximum value in the dataset (or null if all the values in the domain are null).

  Specified by:
    `getMaximumDomainValue` in interface `DomainInfo`
  Returns:
    the maximum value.

### getMinimumRangeValue

    public java.lang.Number getMinimumRangeValue()

  Returns the minimum range value.

  Specified by:
    `getMinimumRangeValue` in interface `RangeInfo`
  Returns:
    The minimum range value.

### getMaximumRangeValue

    public java.lang.Number getMaximumRangeValue()

  Returns the maximum range value.

  Specified by:
    `getMaximumRangeValue` in interface `RangeInfo`
  Returns:
    The maximum range value.

### getValueRange

    public Range getValueRange()

  Returns the value range.

  Specified by:
    `getValueRange` in interface `RangeInfo`
  Returns:
    The range.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD