Package org.jfree.data.time
Class TimeSeriesCollection
- 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.TimeSeriesCollection
-
- All Implemented Interfaces:
java.beans.VetoableChangeListener
,java.io.ObjectInputValidation
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,DomainInfo
,Dataset
,SeriesChangeListener
,SeriesDataset
,IntervalXYDataset
,XYDataset
,XYDomainInfo
,XYRangeInfo
public class TimeSeriesCollection extends AbstractIntervalXYDataset implements XYDataset, IntervalXYDataset, DomainInfo, XYDomainInfo, XYRangeInfo, java.beans.VetoableChangeListener, java.io.Serializable
A collection of time series objects. This class implements theXYDataset
interface, as well as the extendedIntervalXYDataset
interface. This makes it a convenient dataset for use with theXYPlot
class.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List
data
Storage for the time series.private static long
serialVersionUID
For serialization.private java.util.Calendar
workingCalendar
A working calendar (to recycle)private TimePeriodAnchor
xPosition
The point within each time period that is used for the X value when this collection is used as anXYDataset
.
-
Constructor Summary
Constructors Constructor Description TimeSeriesCollection()
Constructs an empty dataset, tied to the default timezone.TimeSeriesCollection(java.util.TimeZone zone)
Constructs an empty dataset, tied to a specific timezone.TimeSeriesCollection(TimeSeries series)
Constructs a dataset containing a single series (more can be added), tied to the default timezone.TimeSeriesCollection(TimeSeries series, java.util.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 void
addSeries(TimeSeries series)
Adds a series to the collection and sends aDatasetChangeEvent
to all registered listeners.java.lang.Object
clone()
Returns a clone of this time series collection.boolean
equals(java.lang.Object obj)
Tests this time series collection for equality with another object.Range
getDomainBounds(boolean includeInterval)
Returns the range of the values in this dataset's domain.Range
getDomainBounds(java.util.List visibleSeriesKeys, boolean includeInterval)
Returns the bounds of the domain values for the specified series.double
getDomainLowerBound(boolean includeInterval)
Returns the minimum x-value in the dataset.DomainOrder
getDomainOrder()
Returns the order of the domain values in this dataset.double
getDomainUpperBound(boolean includeInterval)
Returns the maximum x-value in the dataset.java.lang.Number
getEndX(int series, int item)
Returns the ending X value for the specified series and item.java.lang.Number
getEndY(int series, int item)
Returns the ending Y value for the specified series and item.int
getItemCount(int series)
Returns the number of items in the specified series.Range
getRangeBounds(boolean includeInterval)
Returns the bounds for the y-values in the dataset.Range
getRangeBounds(java.util.List visibleSeriesKeys, Range xRange, boolean includeInterval)
Returns the bounds for the y-values in the dataset.java.util.List
getSeries()
Returns a list of all the series in the collection.TimeSeries
getSeries(int series)
Returns a series.TimeSeries
getSeries(java.lang.Comparable key)
Returns the series with the specified key, ornull
if there is no such series.int
getSeriesCount()
Returns the number of series in the collection.int
getSeriesIndex(java.lang.Comparable key)
Returns the index of the series with the specified key, or -1 if no series has that key.java.lang.Comparable
getSeriesKey(int series)
Returns the key for a series.java.lang.Number
getStartX(int series, int item)
Returns the starting X value for the specified series and item.java.lang.Number
getStartY(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.java.lang.Number
getX(int series, int item)
Returns the x-value for the specified series and item.protected long
getX(RegularTimePeriod period)
Returns the x-value for a time period.TimePeriodAnchor
getXPosition()
Returns the position within each time period that is used for the X value when the collection is used as anXYDataset
.double
getXValue(int series, int item)
Returns the x-value (as a double primitive) for an item within a series.java.lang.Number
getY(int series, int item)
Returns the y-value for the specified series and item.int
hashCode()
Returns a hash code value for the object.int
indexOf(TimeSeries series)
Returns the index of the specified series, or -1 if that series is not present in the dataset.private void
readObject(java.io.ObjectInputStream stream)
Provides serialization support.void
removeAllSeries()
Removes all the series from the collection and sends aDatasetChangeEvent
to all registered listeners.void
removeSeries(int index)
Removes a series from the collection.void
removeSeries(TimeSeries series)
Removes the specified series from the collection and sends aDatasetChangeEvent
to all registered listeners.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 aDatasetChangeEvent
is sent to all registered listeners.void
vetoableChange(java.beans.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.private void
writeObject(java.io.ObjectOutputStream stream)
Provides serialization support.-
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, canEqual, fireDatasetChanged, getGroup, getNotify, hasListener, notifyListeners, removeChangeListener, setGroup, 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, getGroup, removeChangeListener, setGroup
-
Methods inherited from interface org.jfree.data.xy.IntervalXYDataset
getEndXValue, getEndYValue, getStartXValue, getStartYValue
-
Methods inherited from interface org.jfree.data.general.SeriesDataset
indexOf
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
data
private java.util.List data
Storage for the time series.
-
workingCalendar
private java.util.Calendar workingCalendar
A working calendar (to recycle)
-
xPosition
private TimePeriodAnchor xPosition
The point within each time period that is used for the X value when this collection is used as anXYDataset
. This can be the start, middle or end of the time period.
-
-
Constructor Detail
-
TimeSeriesCollection
public TimeSeriesCollection()
Constructs an empty dataset, tied to the default timezone.
-
TimeSeriesCollection
public TimeSeriesCollection(java.util.TimeZone zone)
Constructs an empty dataset, tied to a specific timezone.- Parameters:
zone
- the timezone (null
permitted, will useTimeZone.getDefault()
in that case).
-
TimeSeriesCollection
public TimeSeriesCollection(TimeSeries series)
Constructs a dataset containing a single series (more can be added), tied to the default timezone.- Parameters:
series
- the series (null
permitted).
-
TimeSeriesCollection
public TimeSeriesCollection(TimeSeries series, java.util.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 (null
permitted).zone
- the timezone (null
permitted, will useTimeZone.getDefault()
in that case).
-
-
Method Detail
-
getDomainOrder
public DomainOrder getDomainOrder()
Returns the order of the domain values in this dataset.- Specified by:
getDomainOrder
in interfaceXYDataset
- Overrides:
getDomainOrder
in 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 aDatasetChangeEvent
is sent to all registered listeners.- Parameters:
anchor
- the anchor position (null
not permitted).
-
getSeries
public java.util.List 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:
getSeriesCount
in interfaceSeriesDataset
- Specified by:
getSeriesCount
in classAbstractSeriesDataset
- Returns:
- The series count.
-
indexOf
public int indexOf(TimeSeries series)
Returns the index of the specified series, or -1 if that series is not present in the dataset.- Parameters:
series
- the series (null
not permitted).- Returns:
- The series index.
-
getSeries
public TimeSeries getSeries(int series)
Returns a series.- Parameters:
series
- the index of the series (zero-based).- Returns:
- The series.
-
getSeries
public TimeSeries getSeries(java.lang.Comparable key)
Returns the series with the specified key, ornull
if there is no such series.- Parameters:
key
- the series key (null
permitted).- Returns:
- The series with the given key.
-
getSeriesKey
public java.lang.Comparable getSeriesKey(int series)
Returns the key for a series.- Specified by:
getSeriesKey
in interfaceSeriesDataset
- Specified by:
getSeriesKey
in classAbstractSeriesDataset
- Parameters:
series
- the index of the series (zero-based).- Returns:
- The key for a series.
-
getSeriesIndex
public int getSeriesIndex(java.lang.Comparable key)
Returns the index of the series with the specified key, or -1 if no series has that key.- Parameters:
key
- the key (null
not permitted).- Returns:
- The index.
-
addSeries
public void addSeries(TimeSeries series)
Adds a series to the collection and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
series
- the series (null
not permitted).
-
removeSeries
public void removeSeries(TimeSeries series)
Removes the specified series from the collection and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
series
- the series (null
not 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 aDatasetChangeEvent
to 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:
getItemCount
in interfaceXYDataset
- 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:
getXValue
in interfaceXYDataset
- Overrides:
getXValue
in classAbstractXYDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The x-value.
-
getX
public java.lang.Number getX(int series, int item)
Returns the x-value for the specified series and item.
-
getX
protected long getX(RegularTimePeriod period)
Returns the x-value for a time period.- Parameters:
period
- the time period (null
not permitted).- Returns:
- The x-value.
-
getStartX
public java.lang.Number getStartX(int series, int item)
Returns the starting X value for the specified series and item.- Specified by:
getStartX
in interfaceIntervalXYDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The value.
-
getEndX
public java.lang.Number getEndX(int series, int item)
Returns the ending X value for the specified series and item.- Specified by:
getEndX
in interfaceIntervalXYDataset
- Parameters:
series
- The series (zero-based index).item
- The item (zero-based index).- Returns:
- The value.
-
getY
public java.lang.Number getY(int series, int item)
Returns the y-value for the specified series and item.
-
getStartY
public java.lang.Number getStartY(int series, int item)
Returns the starting Y value for the specified series and item.- Specified by:
getStartY
in interfaceIntervalXYDataset
- Parameters:
series
- the series (zero-based index).item
- the item (zero-based index).- Returns:
- The value (possibly
null
).
-
getEndY
public java.lang.Number getEndY(int series, int item)
Returns the ending Y value for the specified series and item.- Specified by:
getEndY
in interfaceIntervalXYDataset
- 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:
getDomainLowerBound
in 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:
getDomainUpperBound
in 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:
getDomainBounds
in interfaceDomainInfo
- Parameters:
includeInterval
- a flag that determines whether or not the x-interval is taken into account.- Returns:
- The range.
-
getDomainBounds
public Range getDomainBounds(java.util.List visibleSeriesKeys, boolean includeInterval)
Returns the bounds of the domain values for the specified series.- Specified by:
getDomainBounds
in interfaceXYDomainInfo
- Parameters:
visibleSeriesKeys
- a list of keys for the visible series.includeInterval
- include the x-interval?- Returns:
- A range.
-
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
).
-
getRangeBounds
public Range getRangeBounds(java.util.List visibleSeriesKeys, Range xRange, boolean includeInterval)
Returns the bounds for the y-values in the dataset.- Specified by:
getRangeBounds
in interfaceXYRangeInfo
- Parameters:
visibleSeriesKeys
- the visible series keys.xRange
- the x-range (null
not permitted).includeInterval
- ignored.- Returns:
- The bounds.
-
vetoableChange
public void vetoableChange(java.beans.PropertyChangeEvent e) throws java.beans.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:
vetoableChange
in interfacejava.beans.VetoableChangeListener
- Parameters:
e
- the event.- Throws:
java.beans.PropertyVetoException
-
equals
public boolean equals(java.lang.Object obj)
Tests this time series collection for equality with another object.- Overrides:
equals
in classAbstractDataset
- Parameters:
obj
- the other object.- Returns:
- A boolean.
-
hashCode
public int hashCode()
Returns a hash code value for the object.- Overrides:
hashCode
in classAbstractDataset
- Returns:
- The hashcode
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a clone of this time series collection.- Overrides:
clone
in classAbstractDataset
- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException
- if there is a problem cloning.
-
writeObject
private void writeObject(java.io.ObjectOutputStream stream) throws java.io.IOException
Provides serialization support.- Parameters:
stream
- the output stream.- Throws:
java.io.IOException
- if there is an I/O error.
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
Provides serialization support.- Parameters:
stream
- the input stream.- Throws:
java.io.IOException
- if there is an I/O error.java.lang.ClassNotFoundException
- if there is a classpath problem.
-
-