Package org.jfree.data.time
Class TimeSeriesCollection
java.lang.Object
org.jfree.data.AbstractDataset
org.jfree.data.AbstractSeriesDataset
org.jfree.data.AbstractXYDataset
org.jfree.data.AbstractIntervalXYDataset
org.jfree.data.time.TimeSeriesCollection
- All Implemented Interfaces:
ObjectInputValidation,Serializable,Cloneable,EventListener,Dataset,DomainInfo,IntervalXYDataset,SeriesChangeListener,SeriesDataset,XYDataset
public class TimeSeriesCollection extends AbstractIntervalXYDataset implements IntervalXYDataset, DomainInfo, Serializable
A collection of time series objects.
This class implements the XYDataset interface, as well
as the extended IntervalXYDataset interface. This makes it a
convenient dataset for use with the XYPlot
class.
- 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 TimeSeriesCollection()Constructs an empty dataset, tied to the default timezone.TimeSeriesCollection(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, TimeZone zone)Constructs a dataset containing a single series (more can be added), tied to a specific timezone. -
Method Summary
Modifier and Type Method Description voidaddSeries(TimeSeries series)Adds a series to the collection.booleanequals(Object obj)Tests this time series collection for equality with another object.booleangetDomainIsPointsInTime()Returns a flag that controls whether the domain is treated as 'points in time'.RangegetDomainRange()Returns the range of the values in the series domain.NumbergetEndXValue(int series, int item)Returns the ending X value for the specified series and item.NumbergetEndYValue(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.NumbergetMaximumDomainValue()Returns the maximum value in the dataset (or null if all the values in the domain are null).NumbergetMinimumDomainValue()Returns the minimum value in the dataset (or null if all the values in the domain are null).intgetPosition()Deprecated.Use getXPosition().ListgetSeries()Returns a list of all the series in the collection.TimeSeriesgetSeries(int series)Returns a series.TimeSeriesgetSeries(String name)Returns the series with the specified name, ornullif there is no such series.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 starting X value for the specified series and item.NumbergetStartYValue(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.TimePeriodAnchorgetXPosition()Returns the position within each time period that is used for the X value when the collection is used as anXYDataset.NumbergetXValue(int series, int item)Returns the x-value for the specified series and item.NumbergetYValue(int series, int item)Returns the y-value for the specified series and item.inthashCode()Returns a hash code value for the object.voidremoveAllSeries()Removes all the series from the collection.voidremoveSeries(int index)Removes a series from the collection.voidremoveSeries(TimeSeries series)Removes the specified series from the collection.voidsetDomainIsPointsInTime(boolean flag)Sets a flag that controls whether the domain is treated as 'points in time', or time periods.voidsetPosition(int position)Deprecated.Use setXPosition(...).voidsetXPosition(TimePeriodAnchor anchor)Sets the position within each time period that is used for the X values when the collection is used as anXYDataset.Methods inherited from class org.jfree.data.AbstractIntervalXYDataset
getEndX, getEndY, getStartX, getStartYMethods inherited from class org.jfree.data.AbstractXYDataset
getX, getYMethods 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
getClass, 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
-
TimeSeriesCollection
public TimeSeriesCollection()Constructs an empty dataset, tied to the default timezone. -
TimeSeriesCollection
Constructs an empty dataset, tied to a specific timezone.- Parameters:
zone- the timezone.
-
TimeSeriesCollection
Constructs a dataset containing a single series (more can be added), tied to the default timezone.- Parameters:
series- the series.
-
TimeSeriesCollection
Constructs a dataset containing a single series (more can be added), tied to a specific timezone.- Parameters:
series- the series.zone- the timezone.
-
-
Method Details
-
getPosition
public int getPosition()Deprecated.Use getXPosition().Returns the position of the x-value returned for a time period (START, MIDDLE, or END).- Returns:
- The position.
-
setPosition
public void setPosition(int position)Deprecated.Use setXPosition(...).Sets the position - this controls the x-value that is returned for a particular time period.Use the constants
START,MIDDLEandEND.- Parameters:
position- the position.
-
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.
-
setXPosition
Sets the position within each time period that is used for the X values when the collection is used as anXYDataset. ADatasetChangeEventis sent to all registered listeners.- Parameters:
anchor- the anchor position.
-
getDomainIsPointsInTime
public boolean getDomainIsPointsInTime()Returns a flag that controls whether the domain is treated as 'points in time'.This flag is used when determining the max and min values for the domain. If true, then only the x-values are considered for the max and min values. If false, then the start and end x-values will also be taken into consideration
- Returns:
- the flag.
-
setDomainIsPointsInTime
public void setDomainIsPointsInTime(boolean flag)Sets a flag that controls whether the domain is treated as 'points in time', or time periods.- Parameters:
flag- The new value of the flag.
-
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- Specified by:
getSeriesCountin classAbstractSeriesDataset- Returns:
- the series count.
-
getSeries
Returns a series.- Parameters:
series- The index of the series (zero-based).- Returns:
- the series.
-
getSeries
Returns the series with the specified name, ornullif there is no such series.- Parameters:
name- the series name.- Returns:
- The series with the given name.
-
getSeriesName
Returns the name of a series.This method is provided for convenience.
- Specified by:
getSeriesNamein interfaceSeriesDataset- Specified by:
getSeriesNamein classAbstractSeriesDataset- Parameters:
series- The index of the series (zero-based).- Returns:
- the name of a series.
-
addSeries
Adds a series to the collection.Notifies all registered listeners that the dataset has changed.
- Parameters:
series- the time series.
-
removeSeries
Removes the specified series from the collection.- Parameters:
series- the series to remove.
-
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. ADatasetChangeEventis sent 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:
getItemCountin interfaceXYDataset- Parameters:
series- The index of the series of interest (zero-based).- Returns:
- the number of items in the specified series.
-
getXValue
Returns the x-value for the specified series and item. -
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.
-
getStartXValue
Returns the starting X value for the specified series and item.- Specified by:
getStartXValuein interfaceIntervalXYDataset- Parameters:
series- The series (zero-based index).item- The item (zero-based index).- Returns:
- the starting X value for the specified series and item.
-
getEndXValue
Returns the ending X value for the specified series and item.- Specified by:
getEndXValuein interfaceIntervalXYDataset- Parameters:
series- The series (zero-based index).item- The item (zero-based index).- Returns:
- the ending X value for the specified series and item.
-
getYValue
Returns the y-value for the specified series and item. -
getStartYValue
Returns the starting Y value for the specified series and item.- Specified by:
getStartYValuein interfaceIntervalXYDataset- Parameters:
series- The series (zero-based index).item- The item (zero-based index).- Returns:
- the starting Y value for the specified series and item.
-
getEndYValue
Returns the ending Y value for the specified series and item.- Specified by:
getEndYValuein interfaceIntervalXYDataset- Parameters:
series- The series (zero-based index).item- The item (zero-based index).- Returns:
- the ending Y value for the specified series and item.
-
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.
-
getDomainRange
Returns the range of the values in the series domain.- Specified by:
getDomainRangein interfaceDomainInfo- Returns:
- The range (possibly
null).
-
equals
Tests this time series collection for equality with another object. -
hashCode
public int hashCode()Returns a hash code value for the object.
-