Package org.jfree.data.time
Class DynamicTimeSeriesCollection
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
- All Implemented Interfaces:
ObjectInputValidation,Serializable,Cloneable,EventListener,DomainInfo,Dataset,SeriesChangeListener,SeriesDataset,RangeInfo,IntervalXYDataset,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.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classA wrapper for a fixed array of float values. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intUseful constant for controlling the x-value returned for a time period.protected intThe history count.static final intUseful constant for controlling the x-value returned for a time period.protected RegularTimePeriod[]Storage for the x-values.static final intUseful constant for controlling the x-value returned for a time period.protected DynamicTimeSeriesCollection.ValueSequence[]An array for storing the objects that represent each series.protected CalendarA working calendar (to recycle) -
Constructor Summary
ConstructorsConstructorDescriptionDynamicTimeSeriesCollection(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. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSeries(float[] values, int seriesNumber, Comparable seriesKey) Adds a series to the dataset.voidaddValue(int seriesNumber, int index, float value) Adds a value to a series.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.voidappendData(float[] newData) Appends new data.voidappendData(float[] newData, int insertionIndex, int refresh) Appends data at specified index, for loading up with data from file(s).protected voidFinds the domain limits.protected doubleReturns the maximum value.protected voidSends aSeriesChangeEventto all registered listeners.getDomainBounds(boolean includeInterval) Returns the range of the values in this dataset's domain.doublegetDomainLowerBound(boolean includeInterval) Returns the minimum x-value in the dataset.doublegetDomainUpperBound(boolean includeInterval) Returns the maximum x-value in the dataset.getEndX(int series, int item) Returns the end x-value.getEndY(int series, int item) Returns the end y-value.intgetItemCount(int series) Returns the number of items in a series.intReturns the index of the newest data item.Returns the newest time.intReturns the index of the oldest data item.Returns the oldest time.intReturns the x position type (START, MIDDLE or END).getRangeBounds(boolean includeInterval) Returns the value range.doublegetRangeLowerBound(boolean includeInterval) Returns the minimum range value.doublegetRangeUpperBound(boolean includeInterval) Returns the maximum range value.intReturns the number of series in the collection.getSeriesKey(int series) Returns the key for a series.getStartX(int series, int item) Returns the start x-value.getStartY(int series, int item) Returns the start y-value.getX(int series, int item) Returns the x-value.getY(int series, int item) Returns the y-value.doublegetYValue(int series, int item) Returns the y-value.voidInvalidates the range info.intoffsetFromNewest(int delta) Returns the actual index to a time offset by "delta" from newestAt.intoffsetFromOldest(int delta) ??voidsetPosition(int position) Sets the x position type (START, MIDDLE or END).voidsetSeriesKey(int seriesNumber, Comparable key) Sets the name of a series.longsetTimeBase(RegularTimePeriod start) Fill the pointsInTime with times using TimePeriod.next(): Will silently return if the time array was already populated.protected inttranslateGet(int toFetch) Re-map an index, for use in retrieving data.protected intwrapOffset(int protoIndex) ??Methods inherited from class org.jfree.data.xy.AbstractIntervalXYDataset
getEndXValue, getEndYValue, getStartXValue, getStartYValueMethods inherited from class org.jfree.data.xy.AbstractXYDataset
getDomainOrder, getXValueMethods inherited from class org.jfree.data.general.AbstractSeriesDataset
indexOf, seriesChangedMethods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, canEqual, clone, equals, fireDatasetChanged, getGroup, getNotify, hashCode, hasListener, notifyListeners, removeChangeListener, setGroup, setNotify, validateObjectMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jfree.data.general.Dataset
addChangeListener, getGroup, removeChangeListener, setGroupMethods inherited from interface org.jfree.data.xy.IntervalXYDataset
getEndXValue, getEndYValue, getStartXValue, getStartYValueMethods inherited from interface org.jfree.data.general.SeriesDataset
indexOfMethods inherited from interface org.jfree.data.xy.XYDataset
getDomainOrder, getXValue
-
Field Details
-
START
Useful constant for controlling the x-value returned for a time period.- See Also:
-
MIDDLE
Useful constant for controlling the x-value returned for a time period.- See Also:
-
END
Useful constant for controlling the x-value returned for a time period.- See Also:
-
historyCount
The history count. -
pointsInTime
Storage for the x-values. -
valueHistory
An array for storing the objects that represent each series. -
workingCalendar
A working calendar (to recycle)
-
-
Constructor Details
-
DynamicTimeSeriesCollection
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
Constructs an empty dataset, tied to a specific timezone.- Parameters:
nSeries- the number of series to be accommodatednMoments- the number of TimePeriods to be spannedzone- the timezone.
-
DynamicTimeSeriesCollection
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, 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 Details
-
setTimeBase
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
Finds the domain limits. Note: this doesn't need to be synchronized because it's called from within another method that already is. -
getPosition
Returns the x position type (START, MIDDLE or END).- Returns:
- The x position type.
-
setPosition
Sets the x position type (START, MIDDLE or END).- Parameters:
position- The x position type.
-
addSeries
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.
-
setSeriesKey
Sets the name of a series. If planning to add values individually.- Parameters:
seriesNumber- the series.key- the new key.
-
addValue
Adds a value to a series.- Parameters:
seriesNumber- the series index.index- ??.value- the value.
-
getSeriesCount
Returns the number of series in the collection.- Specified by:
getSeriesCountin interfaceSeriesDataset- Specified by:
getSeriesCountin classAbstractSeriesDataset- Returns:
- The series count.
-
getItemCount
Returns the number of items in a series.For this implementation, all series have the same number of items.
- Specified by:
getItemCountin interfaceXYDataset- Parameters:
series- the series index (zero-based).- Returns:
- The item count.
-
translateGet
Re-map an index, for use in retrieving data.- Parameters:
toFetch- the index.- Returns:
- The translated index.
-
offsetFromNewest
Returns the actual index to a time offset by "delta" from newestAt.- Parameters:
delta- the delta.- Returns:
- The offset.
-
offsetFromOldest
??- Parameters:
delta- ??- Returns:
- The offset.
-
wrapOffset
??- Parameters:
protoIndex- the index.- Returns:
- The offset.
-
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
Invalidates the range info. -
findMaxValue
Returns the maximum value.- Returns:
- The maximum value.
-
getOldestIndex
Returns the index of the oldest data item.- Returns:
- The index.
-
getNewestIndex
Returns the index of the newest data item.- Returns:
- The index.
-
appendData
Appends new data.- Parameters:
newData- the data.
-
appendData
Appends data at specified index, for loading up with data from file(s).- Parameters:
newData- the datainsertionIndex- the index value at which to put itrefresh- value of n in "refresh the display on every nth call" (ignored if <= 0 )
-
getNewestTime
Returns the newest time.- Returns:
- The newest time.
-
getOldestTime
Returns the oldest time.- Returns:
- The oldest time.
-
getX
Returns the x-value. -
getYValue
Returns the y-value.- Specified by:
getYValuein interfaceXYDataset- Overrides:
getYValuein classAbstractXYDataset- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The value.
-
getY
Returns the y-value. -
getStartX
Returns the start x-value.- Specified by:
getStartXin interfaceIntervalXYDataset- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The value.
-
getEndX
Returns the end x-value.- Specified by:
getEndXin interfaceIntervalXYDataset- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The value.
-
getStartY
Returns the start y-value.- Specified by:
getStartYin interfaceIntervalXYDataset- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The value.
-
getEndY
Returns the end y-value.- Specified by:
getEndYin interfaceIntervalXYDataset- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The value.
-
getSeriesKey
Returns the key for a series.- Specified by:
getSeriesKeyin interfaceSeriesDataset- Specified by:
getSeriesKeyin classAbstractSeriesDataset- Parameters:
series- the series index (zero-based).- Returns:
- The key.
-
fireSeriesChanged
Sends aSeriesChangeEventto all registered listeners. -
getDomainLowerBound
Returns the minimum x-value in the dataset.- Specified by:
getDomainLowerBoundin interfaceDomainInfo- Parameters:
includeInterval- a flag that determines whether or not the x-interval is taken into account.- Returns:
- The minimum value.
-
getDomainUpperBound
Returns the maximum x-value in the dataset.- Specified by:
getDomainUpperBoundin interfaceDomainInfo- Parameters:
includeInterval- a flag that determines whether or not the x-interval is taken into account.- Returns:
- The maximum value.
-
getDomainBounds
Returns the range of the values in this dataset's domain.- Specified by:
getDomainBoundsin interfaceDomainInfo- Parameters:
includeInterval- a flag that determines whether or not the x-interval is taken into account.- Returns:
- The range.
-
getRangeLowerBound
Returns the minimum range value.- Specified by:
getRangeLowerBoundin interfaceRangeInfo- Parameters:
includeInterval- a flag that determines whether or not the y-interval is taken into account.- Returns:
- The minimum range value.
-
getRangeUpperBound
Returns the maximum range value.- Specified by:
getRangeUpperBoundin interfaceRangeInfo- Parameters:
includeInterval- a flag that determines whether or not the y-interval is taken into account.- Returns:
- The maximum range value.
-
getRangeBounds
Returns the value range.- Specified by:
getRangeBoundsin interfaceRangeInfo- Parameters:
includeInterval- a flag that determines whether or not the y-interval is taken into account.- Returns:
- The range.
-