org.jfree.data
Class CombinedDataset

java.lang.Object
  extended byorg.jfree.data.AbstractDataset
      extended byorg.jfree.data.AbstractSeriesDataset
          extended byorg.jfree.data.CombinedDataset
All Implemented Interfaces:
java.lang.Cloneable, CombinationDataset, Dataset, java.util.EventListener, HighLowDataset, IntervalXYDataset, java.io.ObjectInputValidation, java.io.Serializable, SeriesChangeListener, SeriesDataset, XYDataset

public class CombinedDataset
extends AbstractSeriesDataset
implements XYDataset, HighLowDataset, IntervalXYDataset, CombinationDataset

This class can combine instances of XYDataset, HighLowDataset and IntervalXYDataset together exposing the union of all the series under one dataset.

Author:
Bill Kelemen (bill@kelemen-usa.com)
See Also:
Serialized Form

Constructor Summary
CombinedDataset()
          Default constructor for an empty combination.
CombinedDataset(SeriesDataset[] data)
          Creates a CombinedDataset initialized with an array of SeriesDatasets.
 
Method Summary
 void add(SeriesDataset data)
          Adds one SeriesDataset to the combination.
 void add(SeriesDataset[] data)
          Adds an array of SeriesDataset's to the combination.
 void add(SeriesDataset data, int series)
          Adds one series from a SeriesDataset to the combination.
 int getChildPosition(Dataset child)
          Returns the child position.
 java.lang.Number getCloseValue(int series, int item)
          Returns the close-value for the specified series and item.
 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.
 java.lang.Number getHighValue(int series, int item)
          Returns the high-value for the specified series and item.
 int getItemCount(int series)
          Returns the number of items in a series.
 java.lang.Number getLowValue(int series, int item)
          Returns the low-value for the specified series and item.
 int[] getMap()
          Returns a map or indirect indexing form our series into parent's series.
 java.lang.Number getOpenValue(int series, int item)
          Returns the open-value for the specified series and item.
 SeriesDataset getParent()
          Returns the parent Dataset of this combination.
 int getSeriesCount()
          Returns the number of series in the dataset.
 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 getVolumeValue(int series, int item)
          Returns the volume 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.
 
Methods inherited from class org.jfree.data.AbstractSeriesDataset
seriesChanged
 
Methods inherited from class org.jfree.data.AbstractDataset
addChangeListener, clone, fireDatasetChanged, getGroup, notifyListeners, removeChangeListener, setGroup, validateObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jfree.data.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
 

Constructor Detail

CombinedDataset

public CombinedDataset()
Default constructor for an empty combination.


CombinedDataset

public CombinedDataset(SeriesDataset[] data)
Creates a CombinedDataset initialized with an array of SeriesDatasets.

Parameters:
data - array of SeriesDataset that contains the SeriesDatasets to combine.
Method Detail

add

public void add(SeriesDataset data)
Adds one SeriesDataset to the combination. Listeners are notified of the change.

Parameters:
data - the SeriesDataset to add.

add

public void add(SeriesDataset[] data)
Adds an array of SeriesDataset's to the combination. Listeners are notified of the change.

Parameters:
data - array of SeriesDataset to add

add

public void add(SeriesDataset data,
                int series)
Adds one series from a SeriesDataset to the combination. Listeners are notified of the change.

Parameters:
data - the SeriesDataset where series is contained
series - series to add

getSeriesCount

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

Specified by:
getSeriesCount in interface SeriesDataset
Specified by:
getSeriesCount in class AbstractSeriesDataset
Returns:
The number of series in the dataset.

getSeriesName

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

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

getXValue

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

Note: throws ClassCastException if the series is not from a XYDataset.

Specified by:
getXValue in interface XYDataset
Parameters:
series - the index of the series of interest (zero-based).
item - the index of the item of interest (zero-based).
Returns:
the 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.

Note: throws ClassCastException if the series is not from a XYDataset.

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

getItemCount

public int getItemCount(int series)
Returns the number of items in a series.

Note: throws ClassCastException if the series is not from a XYDataset.

Specified by:
getItemCount in interface XYDataset
Parameters:
series - the index of the series of interest (zero-based).
Returns:
the number of items in a series.

getHighValue

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

Note: throws ClassCastException if the series is not from a HighLowDataset.

Specified by:
getHighValue in interface HighLowDataset
Parameters:
series - the index of the series of interest (zero-based).
item - the index of the item of interest (zero-based).
Returns:
the high-value for the specified series and item.

getLowValue

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

Note: throws ClassCastException if the series is not from a HighLowDataset.

Specified by:
getLowValue in interface HighLowDataset
Parameters:
series - the index of the series of interest (zero-based).
item - the index of the item of interest (zero-based).
Returns:
the low-value for the specified series and item.

getOpenValue

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

Note: throws ClassCastException if the series is not from a HighLowDataset.

Specified by:
getOpenValue in interface HighLowDataset
Parameters:
series - the index of the series of interest (zero-based).
item - the index of the item of interest (zero-based).
Returns:
the open-value for the specified series and item.

getCloseValue

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

Note: throws ClassCastException if the series is not from a HighLowDataset.

Specified by:
getCloseValue in interface HighLowDataset
Parameters:
series - the index of the series of interest (zero-based).
item - the index of the item of interest (zero-based).
Returns:
the close-value for the specified series and item.

getVolumeValue

public java.lang.Number getVolumeValue(int series,
                                       int item)
Returns the volume value for the specified series and item.

Note: throws ClassCastException if the series is not from a HighLowDataset.

Specified by:
getVolumeValue in interface HighLowDataset
Parameters:
series - the index of the series of interest (zero-based).
item - the index of the item of interest (zero-based).
Returns:
the volume 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 index of the series of interest (zero-based).
item - the index of the item of interest (zero-based).
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 index of the series of interest (zero-based).
item - the index of the item of interest (zero-based).
Returns:
the ending X 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 index of the series of interest (zero-based).
item - the index of the item of interest (zero-based).
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 index of the series of interest (zero-based).
item - the index of the item of interest (zero-based).
Returns:
the ending Y value for the specified series and item.

getParent

public SeriesDataset getParent()
Returns the parent Dataset of this combination. If there is more than one parent, or a child is found that is not a CombinationDataset, then returns null.

Specified by:
getParent in interface CombinationDataset
Returns:
the parent Dataset of this combination or null.

getMap

public int[] getMap()
Returns a map or indirect indexing form our series into parent's series. Prior to calling this method, the client should check getParent() to make sure the CombinationDataset uses the same parent. If not, the map returned by this method will be invalid or null.

Specified by:
getMap in interface CombinationDataset
Returns:
a map or indirect indexing form our series into parent's series.
See Also:
getParent()

getChildPosition

public int getChildPosition(Dataset child)
Returns the child position.

Parameters:
child - the child dataset.
Returns:
the position.