Package 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:
ObjectInputValidation,Serializable,Cloneable,EventListener,Dataset,DomainInfo,IntervalXYDataset,RangeInfo,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
-
Field Summary
Fields Modifier and Type Field Description static intENDUseful constant for controlling the x-value returned for a time period.static intMIDDLEUseful constant for controlling the x-value returned for a time period.static intSTARTUseful constant for controlling the x-value returned for a time period. -
Constructor Summary
Constructors Constructor Description 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. -
Method Summary
Modifier and Type Method Description voidaddSeries(float[] values, int seriesNumber, String seriesName)Adds a series to the dataset.voidaddValue(int seriesNumber, int index, float value)Adds a value to a series.RegularTimePeriodadvanceTime()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).RangegetDomainRange()Returns the range of values for the domain.NumbergetEndXValue(int series, int item)Returns the end x-value.NumbergetEndYValue(int series, int item)Returns the end y-value.intgetItemCount(int series)Returns the number of items in a series.NumbergetMaximumDomainValue()Returns the maximum value in the dataset (or null if all the values in the domain are null).NumbergetMaximumRangeValue()Returns the maximum range value.NumbergetMinimumDomainValue()Returns the minimum value in the dataset (or null if all the values in the domain are null).NumbergetMinimumRangeValue()Returns the minimum range value.intgetNewestIndex()Returns the index of the newest data item.RegularTimePeriodgetNewestTime()Returns the newest time.intgetOldestIndex()Returns the index of the oldest data item.RegularTimePeriodgetOldestTime()Returns the oldest time.intgetPosition()Returns the x position type (START, MIDDLE or END).intgetSeriesCount()Returns the number of series in the collection.StringgetSeriesName(int series)Returns the name of a series.NumbergetStartXValue(int series, int item)Returns the start x-value.NumbergetStartYValue(int series, int item)Returns the start y-value.RangegetValueRange()Returns the value range.NumbergetXValue(int series, int item)Returns the x-value.doublegetY(int series, int item)Returns the y-value.NumbergetYValue(int series, int item)Returns the y-value.voidinvalidateRangeInfo()Invalidates 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).voidsetSeriesName(int seriesNumber, String newName)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.Methods inherited from class org.jfree.data.AbstractIntervalXYDataset
getEndX, getEndY, getStartX, getStartYMethods inherited from class org.jfree.data.AbstractXYDataset
getXMethods inherited from class org.jfree.data.AbstractSeriesDataset
seriesChangedMethods inherited from class org.jfree.data.AbstractDataset
addChangeListener, clone, getGroup, removeChangeListener, setGroup, validateObjectMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jfree.data.Dataset
addChangeListener, getGroup, removeChangeListener, setGroupMethods inherited from interface org.jfree.data.IntervalXYDataset
getEndX, getEndY, getStartX, getStartY
-
Field Details
-
START
public static final int STARTUseful constant for controlling the x-value returned for a time period.- See Also:
- Constant Field Values
-
MIDDLE
public static final int MIDDLEUseful constant for controlling the x-value returned for a time period.- See Also:
- Constant Field Values
-
END
public static final int ENDUseful constant for controlling the x-value returned for a time period.- See Also:
- Constant Field Values
-
-
Constructor Details
-
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
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:
- ??.
-
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
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
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:
getSeriesCountin interfaceSeriesDataset- Specified by:
getSeriesCountin classAbstractSeriesDataset- 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:
getItemCountin interfaceXYDataset- Parameters:
series- the series index (zero-based).- Returns:
- The item count.
-
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.
-
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. -
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 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.
-
getXValue
Returns the x-value. -
getY
public double getY(int series, int item)Returns the y-value.- Specified by:
getYin interfaceXYDataset- Overrides:
getYin classAbstractXYDataset- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The value.
-
getYValue
Returns the y-value. -
getStartXValue
Returns the start x-value.- Specified by:
getStartXValuein interfaceIntervalXYDataset- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The value.
-
getEndXValue
Returns the end x-value.- Specified by:
getEndXValuein interfaceIntervalXYDataset- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The value.
-
getStartYValue
Returns the start y-value.- Specified by:
getStartYValuein interfaceIntervalXYDataset- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The value.
-
getEndYValue
Returns the end y-value.- Specified by:
getEndYValuein interfaceIntervalXYDataset- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The value.
-
getSeriesName
Returns the name of a series.- Specified by:
getSeriesNamein interfaceSeriesDataset- Specified by:
getSeriesNamein classAbstractSeriesDataset- Parameters:
series- the series index (zero-based).- Returns:
- The name.
-
getDomainRange
Returns the range of values for the domain.- Specified by:
getDomainRangein interfaceDomainInfo- Returns:
- The range.
-
getMinimumDomainValue
Returns the minimum value in the dataset (or null if all the values in the domain are null).- Specified by:
getMinimumDomainValuein interfaceDomainInfo- Returns:
- the minimum value.
-
getMaximumDomainValue
Returns the maximum value in the dataset (or null if all the values in the domain are null).- Specified by:
getMaximumDomainValuein interfaceDomainInfo- Returns:
- the maximum value.
-
getMinimumRangeValue
Returns the minimum range value.- Specified by:
getMinimumRangeValuein interfaceRangeInfo- Returns:
- The minimum range value.
-
getMaximumRangeValue
Returns the maximum range value.- Specified by:
getMaximumRangeValuein interfaceRangeInfo- Returns:
- The maximum range value.
-
getValueRange
Returns the value range.- Specified by:
getValueRangein interfaceRangeInfo- Returns:
- The range.
-