com.jrefinery.data
Class TimeSeriesCollection

java.lang.Object
  extended by com.jrefinery.data.AbstractDataset
      extended by com.jrefinery.data.AbstractSeriesDataset
          extended by com.jrefinery.data.TimeSeriesCollection
All Implemented Interfaces:
Dataset, IntervalXYDataset, SeriesChangeListener, SeriesDataset, XYDataset

public class TimeSeriesCollection
extends AbstractSeriesDataset
implements IntervalXYDataset

A collection of time series objects.

This class implements the IntervalXYDataset interface. One consequence of this is that this class can be used quite easily to supply data to JFreeChart.


Field Summary
protected  java.util.List data
          Storage for the time series.
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.
protected  int position
           
static int START
          Useful constant for controlling the x-value returned for a time period.
protected  java.util.Calendar workingCalendar
          A working calendar (to recycle)
 
Fields inherited from class com.jrefinery.data.AbstractDataset
listeners
 
Constructor Summary
TimeSeriesCollection()
          Constructs an empty dataset, tied to the default timezone.
TimeSeriesCollection(BasicTimeSeries series)
          Constructs a dataset containing a single series (more can be added), tied to the default timezone.
TimeSeriesCollection(BasicTimeSeries 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(BasicTimeSeries series)
          Adds a series to the collection.
 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.
 int getPosition()
          Returns the position of the x-value returned for a time period (START, MIDDLE, or END).
 BasicTimeSeries 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 setPosition(int position)
          Sets the position - this controls the x-value that is returned for a particular time period.
 
Methods inherited from class com.jrefinery.data.AbstractSeriesDataset
getLegendItemCount, getLegendItemLabels, seriesChanged
 
Methods inherited from class com.jrefinery.data.AbstractDataset
addChangeListener, fireDatasetChanged, notifyListeners, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jrefinery.data.Dataset
addChangeListener, removeChangeListener
 

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

data

protected java.util.List data
Storage for the time series.


workingCalendar

protected java.util.Calendar workingCalendar
A working calendar (to recycle)


position

protected int position
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(BasicTimeSeries series)
Constructs a dataset containing a single series (more can be added), tied to the default timezone.

Parameters:
series - The series.

TimeSeriesCollection

public TimeSeriesCollection(BasicTimeSeries 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.

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 BasicTimeSeries 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(BasicTimeSeries series)
Adds a series to the collection.

Notifies all registered listeners that the dataset has changed.

Parameters:
series - The time series.

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 within a 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 an item within a series.

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).

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).

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 an item within a series.

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).

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).


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.