com.jrefinery.data
Class DefaultXYDataset

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

public class DefaultXYDataset
extends AbstractSeriesDataset
implements XYDataset

A convenience class that provides a default implementation of the XYDataset interface. The standard constructor accepts data in a two dimensional array where the first dimension is the series, and the second dimension is the category.


Field Summary
protected  java.util.List allSeriesData
          A list of Lists containing the data for each series.
protected  java.util.List seriesNames
          A list of series names.
 
Fields inherited from class com.jrefinery.data.AbstractDataset
listeners
 
Constructor Summary
DefaultXYDataset()
          Constructs a new dataset, initially empty.
DefaultXYDataset(java.util.List seriesNames, java.lang.Object[][][] data)
          Constructs a new dataset with the given data.
DefaultXYDataset(java.lang.Object[][][] data)
          Constructs a new dataset, and populates it with the given data.
DefaultXYDataset(java.lang.String[] seriesNames, java.lang.Object[][][] data)
          Constructs a new dataset with the given data.
 
Method Summary
 void addXYData(int series, java.lang.Object xObject, java.lang.Object yObject)
          The following method adds to the list
 int getItemCount(int series)
          Returns the number of items in the specified series.
 int getSeriesCount()
          Returns the number of series.
 java.lang.String getSeriesName(int series)
          Returns the name of the specified series.
 java.lang.Number getXValue(int series, int item)
          Returns the x value for the specified series and index (zero-based indices).
 java.lang.Number getYValue(int series, int item)
          Returns the y value for the specified series and index (zero-based indices).
static java.util.List seriesNameListFromDataArray(java.lang.Object[][] data)
          Returns a List of String objects that can be used as series names.
 void setSeriesNames(java.lang.String[] seriesNames)
          Sets the names of the series in the data source.
 
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

seriesNames

protected java.util.List seriesNames
A list of series names.


allSeriesData

protected java.util.List allSeriesData
A list of Lists containing the data for each series.

Constructor Detail

DefaultXYDataset

public DefaultXYDataset()
Constructs a new dataset, initially empty.


DefaultXYDataset

public DefaultXYDataset(java.lang.Object[][][] data)
Constructs a new dataset, and populates it with the given data.

The dimensions of the data array are [series][item][x=0, y=1]. The x-values should be Number or Date objects, the y-values should be Number objects. Any other types are interpreted as zero. The data will be sorted so that the x-values are ascending.


DefaultXYDataset

public DefaultXYDataset(java.lang.String[] seriesNames,
                        java.lang.Object[][][] data)
Constructs a new dataset with the given data.


DefaultXYDataset

public DefaultXYDataset(java.util.List seriesNames,
                        java.lang.Object[][][] data)
Constructs a new dataset with the given data.

Method Detail

addXYData

public void addXYData(int series,
                      java.lang.Object xObject,
                      java.lang.Object yObject)
The following method adds to the list


getSeriesCount

public int getSeriesCount()
Returns the number of series.

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

getItemCount

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

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

getSeriesName

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

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

setSeriesNames

public void setSeriesNames(java.lang.String[] seriesNames)
Sets the names of the series in the data source.

Parameters:
seriesNames - The names of the series in the data source.

getXValue

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

Specified by:
getXValue in interface XYDataset
Parameters:
series - The index of the series (zero-based);
item - The index of the item (zero-based).
Returns:
The x-value for an item within a series.

getYValue

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

Specified by:
getYValue in interface XYDataset
Parameters:
series - The index of the series (zero-based);
item - The index of the item (zero-based).
Returns:
The y-value for an item within a series.

seriesNameListFromDataArray

public static java.util.List seriesNameListFromDataArray(java.lang.Object[][] data)
Returns a List of String objects that can be used as series names.

Parameters:
data - An array containing the data for the data source.


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.