org.jfree.data.time
Class TimeSeriesCollection

java.lang.Object
  |
  +--org.jfree.data.AbstractDataset
        |
        +--org.jfree.data.AbstractSeriesDataset
              |
              +--org.jfree.data.time.TimeSeriesCollection
All Implemented Interfaces:
Dataset, DomainInfo, IntervalXYDataset, java.io.Serializable, SeriesChangeListener, SeriesDataset, XYDataset

public class TimeSeriesCollection
extends AbstractSeriesDataset
implements IntervalXYDataset, DomainInfo, java.io.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.

Author:
David Gilbert
See Also:
Serialized Form

Field Summary
static int END
          Useful constant for controlling the x-value returned for a time period.
static int MIDDLE
          Useful constant for controlling the x-value returned for a time period.
static int START
          Useful constant for controlling the x-value returned for a time period.
 
Constructor Summary
TimeSeriesCollection()
          Constructs an empty dataset, tied to the default 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.
TimeSeriesCollection(java.util.TimeZone zone)
          Constructs an empty dataset, tied to a specific timezone.
 
Method Summary
 void addSeries(TimeSeries series)
          Adds a series to the collection.
 boolean equals(java.lang.Object obj)
          Tests this time series collection for equality with another object.
 boolean getDomainIsPointsInTime()
          Returns a flag that controls whether the domain is treated as 'points in time'.
 Range getDomainRange()
          Returns the range of the values in the series domain.
 java.lang.Number getEndXValue(int series, int item)
          Returns the ending X value for the specified series and item.
 java.lang.Number getEndYValue(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.
 java.lang.Number getMaximumDomainValue()
          Returns the maximum value in the dataset (or null if all the values in the domain are null).
 java.lang.Number getMinimumDomainValue()
          Returns the minimum value in the dataset (or null if all the values in the domain are null).
 int getPosition()
          Returns the position of the x-value returned for a time period (START, MIDDLE, or END).
 TimeSeries getSeries(int series)
          Returns a series.
 int getSeriesCount()
          Returns the number of series in the collection.
 java.lang.String getSeriesName(int series)
          Returns the name of a series.
 java.lang.Number getStartXValue(int series, int item)
          Returns the starting X value for the specified series and item.
 java.lang.Number getStartYValue(int series, int item)
          Returns the starting Y value for the specified series and item.
 java.lang.Number getXValue(int series, int item)
          Returns the x-value for the specified series and item.
 java.lang.Number getYValue(int series, int item)
          Returns the y-value for the specified series and item.
 void removeSeries(int index)
          Removes a series from the collection.
 void removeSeries(TimeSeries series)
          Removes the specified series from the collection.
 void setDomainIsPointsInTime(boolean flag)
          Sets a flag that controls whether the domain is treated as 'points in time', or time periods.
 void setPosition(int position)
          Sets the position - this controls the x-value that is returned for a particular time period.
 
Methods inherited from class org.jfree.data.AbstractSeriesDataset
seriesChanged
 
Methods inherited from class org.jfree.data.AbstractDataset
addChangeListener, fireDatasetChanged, getGroup, notifyListeners, removeChangeListener, setGroup
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jfree.data.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
 

Field Detail

START

public static final int START
Useful constant for controlling the x-value returned for a time period.

See Also:
Constant Field Values

MIDDLE

public static final int MIDDLE
Useful constant for controlling the x-value returned for a time period.

See Also:
Constant Field Values

END

public static final int END
Useful constant for controlling the x-value returned for a time period.

See Also:
Constant Field Values
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.

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.

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 - the series.
zone - the timezone.
Method Detail

getPosition

public int getPosition()
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)
Sets the position - this controls the x-value that is returned for a particular time period.

Use the constants START, MIDDLE and END.

Parameters:
position - the 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.

getSeriesCount

public int getSeriesCount()
Returns the number of series in the collection.

Specified by:
getSeriesCount in interface SeriesDataset
Specified by:
getSeriesCount in class AbstractSeriesDataset
Returns:
the series count.

getSeries

public TimeSeries getSeries(int series)
Returns a series.

Parameters:
series - The index of the series (zero-based).
Returns:
the series.

getSeriesName

public java.lang.String getSeriesName(int series)
Returns the name of a series.

This method is provided for convenience.

Specified by:
getSeriesName in interface SeriesDataset
Specified by:
getSeriesName in class AbstractSeriesDataset
Parameters:
series - The index of the series (zero-based).
Returns:
the name of a series.

addSeries

public void addSeries(TimeSeries series)
Adds a series to the collection.

Notifies all registered listeners that the dataset has changed.

Parameters:
series - the time series.

removeSeries

public void removeSeries(TimeSeries series)
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).

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 interface XYDataset
Parameters:
series - The index of the series of interest (zero-based).
Returns:
the number of items in the specified series.

getXValue

public java.lang.Number getXValue(int series,
                                  int item)
Returns the x-value for the specified series and item.

Specified by:
getXValue in interface XYDataset
Parameters:
series - The series (zero-based index).
item - The item (zero-based index).
Returns:
the x-value for the specified series and item.

getStartXValue

public java.lang.Number getStartXValue(int series,
                                       int item)
Returns the starting X value for the specified series and item.

Specified by:
getStartXValue in interface IntervalXYDataset
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

public java.lang.Number getEndXValue(int series,
                                     int item)
Returns the ending X value for the specified series and item.

Specified by:
getEndXValue in interface IntervalXYDataset
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

public java.lang.Number getYValue(int series,
                                  int item)
Returns the y-value for the specified series and item.

Specified by:
getYValue in interface XYDataset
Parameters:
series - The series (zero-based index).
item - The item (zero-based index).
Returns:
the y-value for the specified series and item.

getStartYValue

public java.lang.Number getStartYValue(int series,
                                       int item)
Returns the starting Y value for the specified series and item.

Specified by:
getStartYValue in interface IntervalXYDataset
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

public java.lang.Number getEndYValue(int series,
                                     int item)
Returns the ending Y value for the specified series and item.

Specified by:
getEndYValue in interface IntervalXYDataset
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

public java.lang.Number getMinimumDomainValue()
Returns the minimum value in the dataset (or null if all the values in the domain are null).

Specified by:
getMinimumDomainValue in interface DomainInfo
Returns:
the minimum value.

getMaximumDomainValue

public java.lang.Number getMaximumDomainValue()
Returns the maximum value in the dataset (or null if all the values in the domain are null).

Specified by:
getMaximumDomainValue in interface DomainInfo
Returns:
the maximum value.

getDomainRange

public Range getDomainRange()
Returns the range of the values in the series domain.

Specified by:
getDomainRange in interface DomainInfo
Returns:
the range.

equals

public boolean equals(java.lang.Object obj)
Tests this time series collection for equality with another object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the other object.
Returns:
A boolean.