Module org.jfree.chart
Package org.jfree.data.time
Class TimeSeriesCollection<S extends Comparable<S>>
- java.lang.Object
-
- org.jfree.data.general.AbstractDataset
-
- org.jfree.data.general.AbstractSeriesDataset<S>
-
- org.jfree.data.xy.AbstractXYDataset<S>
-
- org.jfree.data.xy.AbstractIntervalXYDataset
-
- org.jfree.data.time.TimeSeriesCollection<S>
-
- All Implemented Interfaces:
VetoableChangeListener,ObjectInputValidation,Serializable,Cloneable,EventListener,DomainInfo,Dataset,SeriesChangeListener,SeriesDataset,IntervalXYDataset,XYDataset,XYDomainInfo,XYRangeInfo
public class TimeSeriesCollection<S extends Comparable<S>> extends AbstractIntervalXYDataset implements XYDataset, IntervalXYDataset, DomainInfo, XYDomainInfo, XYRangeInfo, VetoableChangeListener, Serializable
A collection of time series objects. This class implements theXYDatasetinterface, as well as the extendedIntervalXYDatasetinterface. This makes it a convenient dataset for use with theXYPlotclass.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description TimeSeriesCollection()Constructs an empty dataset, tied to the default timezone.TimeSeriesCollection(TimeZone zone)Constructs an empty dataset, tied to a specific timezone.TimeSeriesCollection(TimeSeries<S> series)Constructs a dataset containing a single series (more can be added), tied to the default timezone.TimeSeriesCollection(TimeSeries<S> series, TimeZone zone)Constructs a dataset containing a single series (more can be added), tied to a specific timezone.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSeries(TimeSeries<S> series)Adds a series to the collection and sends aDatasetChangeEventto all registered listeners.Objectclone()Returns a clone of this time series collection.booleanequals(Object obj)Tests this time series collection for equality with another object.RangegetDomainBounds(boolean includeInterval)Returns the range of the values in this dataset's domain.RangegetDomainBounds(List visibleSeriesKeys, boolean includeInterval)Returns the bounds of the domain values for the specified series.doublegetDomainLowerBound(boolean includeInterval)Returns the minimum x-value in the dataset.DomainOrdergetDomainOrder()Returns the order of the domain values in this dataset.doublegetDomainUpperBound(boolean includeInterval)Returns the maximum x-value in the dataset.NumbergetEndX(int series, int item)Returns the ending X value for the specified series and item.NumbergetEndY(int series, int item)Returns the ending Y value for the specified series and item.intgetItemCount(int series)Returns the number of items in the specified series.RangegetRangeBounds(boolean includeInterval)Returns the bounds for the y-values in the dataset.RangegetRangeBounds(List visibleSeriesKeys, Range xRange, boolean includeInterval)Returns the bounds for the y-values in the dataset.List<TimeSeries<S>>getSeries()Returns a list of all the series in the collection.TimeSeries<S>getSeries(int series)Returns a series.TimeSeries<S>getSeries(S key)Returns the series with the specified key, ornullif there is no such series.intgetSeriesCount()Returns the number of series in the collection.intgetSeriesIndex(Comparable key)Returns the index of the series with the specified key, or -1 if no series has that key.ComparablegetSeriesKey(int series)Returns the key for a series.NumbergetStartX(int series, int item)Returns the starting X value for the specified series and item.NumbergetStartY(int series, int item)Returns the starting Y value for the specified series and item.int[]getSurroundingItems(int series, long milliseconds)Returns the indices of the two data items surrounding a particular millisecond value.NumbergetX(int series, int item)Returns the x-value for the specified series and item.protected longgetX(RegularTimePeriod period)Returns the x-value for a time period.TimePeriodAnchorgetXPosition()Returns the position within each time period that is used for the X value when the collection is used as anXYDataset.doublegetXValue(int series, int item)Returns the x-value (as a double primitive) for an item within a series.NumbergetY(int series, int item)Returns the y-value for the specified series and item.inthashCode()Returns a hash code value for the object.intindexOf(TimeSeries<S> series)Returns the index of the specified series, or -1 if that series is not present in the dataset.voidremoveAllSeries()Removes all the series from the collection and sends aDatasetChangeEventto all registered listeners.voidremoveSeries(int index)Removes a series from the collection.voidremoveSeries(TimeSeries<S> series)Removes the specified series from the collection and sends aDatasetChangeEventto all registered listeners.voidsetXPosition(TimePeriodAnchor anchor)Sets the position within each time period that is used for the X values when the collection is used as anXYDataset, then sends aDatasetChangeEventis sent to all registered listeners.voidvetoableChange(PropertyChangeEvent e)Receives notification that the key for one of the series in the collection has changed, and vetos it if the key is already present in the collection.-
Methods inherited from class org.jfree.data.xy.AbstractIntervalXYDataset
getEndXValue, getEndYValue, getStartXValue, getStartYValue
-
Methods inherited from class org.jfree.data.xy.AbstractXYDataset
getYValue
-
Methods inherited from class org.jfree.data.general.AbstractSeriesDataset
indexOf, seriesChanged
-
Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, fireDatasetChanged, getNotify, hasListener, notifyListeners, removeChangeListener, setNotify, validateObject
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jfree.data.general.Dataset
addChangeListener, removeChangeListener
-
Methods inherited from interface org.jfree.data.xy.IntervalXYDataset
getEndXValue, getEndYValue, getStartXValue, getStartYValue
-
Methods inherited from interface org.jfree.data.general.SeriesDataset
indexOf
-
-
-
-
Constructor Detail
-
TimeSeriesCollection
public TimeSeriesCollection()
Constructs an empty dataset, tied to the default timezone.
-
TimeSeriesCollection
public TimeSeriesCollection(TimeZone zone)
Constructs an empty dataset, tied to a specific timezone.- Parameters:
zone- the timezone (nullpermitted, will useTimeZone.getDefault()in that case).
-
TimeSeriesCollection
public TimeSeriesCollection(TimeSeries<S> series)
Constructs a dataset containing a single series (more can be added), tied to the default timezone.- Parameters:
series- the series (nullpermitted).
-
TimeSeriesCollection
public TimeSeriesCollection(TimeSeries<S> series, TimeZone zone)
Constructs a dataset containing a single series (more can be added), tied to a specific timezone.- Parameters:
series- a series to add to the collection (nullpermitted).zone- the timezone (nullpermitted, will useTimeZone.getDefault()in that case).
-
-
Method Detail
-
getDomainOrder
public DomainOrder getDomainOrder()
Returns the order of the domain values in this dataset.- Specified by:
getDomainOrderin interfaceXYDataset<S extends Comparable<S>>- Overrides:
getDomainOrderin classAbstractXYDataset- Returns:
DomainOrder.ASCENDING
-
getXPosition
public TimePeriodAnchor getXPosition()
Returns the position within each time period that is used for the X value when the collection is used as anXYDataset.- Returns:
- The anchor position (never
null).
-
setXPosition
public void setXPosition(TimePeriodAnchor anchor)
Sets the position within each time period that is used for the X values when the collection is used as anXYDataset, then sends aDatasetChangeEventis sent to all registered listeners.- Parameters:
anchor- the anchor position (nullnot permitted).
-
getSeries
public List<TimeSeries<S>> getSeries()
Returns a list of all the series in the collection.- Returns:
- The list (which is unmodifiable).
-
getSeriesCount
public int getSeriesCount()
Returns the number of series in the collection.- Specified by:
getSeriesCountin interfaceSeriesDataset<S extends Comparable<S>>- Specified by:
getSeriesCountin classAbstractSeriesDataset- Returns:
- The series count.
-
indexOf
public int indexOf(TimeSeries<S> series)
Returns the index of the specified series, or -1 if that series is not present in the dataset.- Parameters:
series- the series (nullnot permitted).- Returns:
- The series index.
- Since:
- 1.0.6
-
getSeries
public TimeSeries<S> getSeries(int series)
Returns a series.- Parameters:
series- the index of the series (zero-based).- Returns:
- The series.
-
getSeries
public TimeSeries<S> getSeries(S key)
Returns the series with the specified key, ornullif there is no such series.- Parameters:
key- the series key (nullpermitted).- Returns:
- The series with the given key.
-
getSeriesKey
public Comparable getSeriesKey(int series)
Returns the key for a series.- Specified by:
getSeriesKeyin interfaceSeriesDataset<S extends Comparable<S>>- Specified by:
getSeriesKeyin classAbstractSeriesDataset- Parameters:
series- the index of the series (zero-based).- Returns:
- The key for a series.
-
getSeriesIndex
public int getSeriesIndex(Comparable key)
Returns the index of the series with the specified key, or -1 if no series has that key.- Parameters:
key- the key (nullnot permitted).- Returns:
- The index.
- Since:
- 1.0.17
-
addSeries
public void addSeries(TimeSeries<S> series)
Adds a series to the collection and sends aDatasetChangeEventto all registered listeners.- Parameters:
series- the series (nullnot permitted).
-
removeSeries
public void removeSeries(TimeSeries<S> series)
Removes the specified series from the collection and sends aDatasetChangeEventto all registered listeners.- Parameters:
series- the series (nullnot permitted).
-
removeSeries
public void removeSeries(int index)
Removes a series from the collection.- Parameters:
index- the series index (zero-based).
-
removeAllSeries
public void removeAllSeries()
Removes all the series from the collection and sends aDatasetChangeEventto all registered listeners.
-
getItemCount
public int getItemCount(int series)
Returns the number of items in the specified series. This method is provided for convenience.- Specified by:
getItemCountin interfaceXYDataset<S extends Comparable<S>>- Parameters:
series- the series index (zero-based).- Returns:
- The item count.
-
getXValue
public double getXValue(int series, int item)
Returns the x-value (as a double primitive) for an item within a series.- Specified by:
getXValuein interfaceXYDataset<S extends Comparable<S>>- Overrides:
getXValuein classAbstractXYDataset- Parameters:
series- the series (zero-based index).item- the item (zero-based index).- Returns:
- The x-value.
-
getX
public Number getX(int series, int item)
Returns the x-value for the specified series and item.- Specified by:
getXin interfaceXYDataset<S extends Comparable<S>>- Parameters:
series- the series (zero-based index).item- the item (zero-based index).- Returns:
- The value.
-
getX
protected long getX(RegularTimePeriod period)
Returns the x-value for a time period.- Parameters:
period- the time period (nullnot permitted).- Returns:
- The x-value.
-
getStartX
public Number getStartX(int series, int item)
Returns the starting X value for the specified series and item.- Specified by:
getStartXin interfaceIntervalXYDataset<S extends Comparable<S>>- Parameters:
series- the series (zero-based index).item- the item (zero-based index).- Returns:
- The value.
-
getEndX
public Number getEndX(int series, int item)
Returns the ending X value for the specified series and item.- Specified by:
getEndXin interfaceIntervalXYDataset<S extends Comparable<S>>- Parameters:
series- The series (zero-based index).item- The item (zero-based index).- Returns:
- The value.
-
getY
public Number getY(int series, int item)
Returns the y-value for the specified series and item.- Specified by:
getYin interfaceXYDataset<S extends Comparable<S>>- Parameters:
series- the series (zero-based index).item- the item (zero-based index).- Returns:
- The value (possibly
null).
-
getStartY
public Number getStartY(int series, int item)
Returns the starting Y value for the specified series and item.- Specified by:
getStartYin interfaceIntervalXYDataset<S extends Comparable<S>>- Parameters:
series- the series (zero-based index).item- the item (zero-based index).- Returns:
- The value (possibly
null).
-
getEndY
public Number getEndY(int series, int item)
Returns the ending Y value for the specified series and item.- Specified by:
getEndYin interfaceIntervalXYDataset<S extends Comparable<S>>- Parameters:
series- te series (zero-based index).item- the item (zero-based index).- Returns:
- The value (possibly
null).
-
getSurroundingItems
public int[] getSurroundingItems(int series, long milliseconds)
Returns the indices of the two data items surrounding a particular millisecond value.- Parameters:
series- the series index.milliseconds- the time.- Returns:
- An array containing the (two) indices of the items surrounding the time.
-
getDomainLowerBound
public double getDomainLowerBound(boolean includeInterval)
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
public double getDomainUpperBound(boolean includeInterval)
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
public Range getDomainBounds(boolean includeInterval)
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.
-
getDomainBounds
public Range getDomainBounds(List visibleSeriesKeys, boolean includeInterval)
Returns the bounds of the domain values for the specified series.- Specified by:
getDomainBoundsin interfaceXYDomainInfo<S extends Comparable<S>>- Parameters:
visibleSeriesKeys- a list of keys for the visible series.includeInterval- include the x-interval?- Returns:
- A range.
- Since:
- 1.0.13
-
getRangeBounds
public Range getRangeBounds(boolean includeInterval)
Returns the bounds for the y-values in the dataset.- Parameters:
includeInterval- ignored for this dataset.- Returns:
- The range of value in the dataset (possibly
null). - Since:
- 1.0.15
-
getRangeBounds
public Range getRangeBounds(List visibleSeriesKeys, Range xRange, boolean includeInterval)
Returns the bounds for the y-values in the dataset.- Specified by:
getRangeBoundsin interfaceXYRangeInfo- Parameters:
visibleSeriesKeys- the visible series keys.xRange- the x-range (nullnot permitted).includeInterval- ignored.- Returns:
- The bounds.
- Since:
- 1.0.14
-
vetoableChange
public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException
Receives notification that the key for one of the series in the collection has changed, and vetos it if the key is already present in the collection.- Specified by:
vetoableChangein interfaceVetoableChangeListener- Parameters:
e- the event.- Throws:
PropertyVetoException- Since:
- 1.0.17
-
equals
public boolean equals(Object obj)
Tests this time series collection for equality with another object.
-
hashCode
public int hashCode()
Returns a hash code value for the object.
-
clone
public Object clone() throws CloneNotSupportedException
Returns a clone of this time series collection.- Overrides:
clonein classAbstractDataset- Returns:
- A clone.
- Throws:
CloneNotSupportedException- if there is a problem cloning.
-
-