com.jrefinery.data
Class DefaultXYDataset

java.lang.Object
  |
  +--com.jrefinery.data.AbstractDataset
        |
        +--com.jrefinery.data.AbstractSeriesDataset
              |
              +--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.

Author:
DG

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
 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, getGroup, notifyListeners, removeChangeListener, setGroup
 
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, getGroup, removeChangeListener, setGroup
 

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.

Parameters:
data - the dataset.

DefaultXYDataset

public DefaultXYDataset(java.lang.String[] seriesNames,
                        java.lang.Object[][][] data)
Constructs a new dataset with the given data.
Parameters:
seriesNames - the names of the series.
data - the dataset.

DefaultXYDataset

public DefaultXYDataset(java.util.List seriesNames,
                        java.lang.Object[][][] data)
Constructs a new dataset with the given data.
Parameters:
seriesNames - the names of the series.
data - the dataset.
Method Detail

getSeriesCount

public int getSeriesCount()
Returns the number of series.
Specified by:
getSeriesCount in interface SeriesDataset
Overrides:
getSeriesCount in class AbstractSeriesDataset
Returns:
the number of series.

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 in the specified series.

getSeriesName

public java.lang.String getSeriesName(int series)
Returns the name of the specified series.
Specified by:
getSeriesName in interface SeriesDataset
Overrides:
getSeriesName in class AbstractSeriesDataset
Parameters:
series - the index of the required series (zero-based).
Returns:
the name of the specified series.

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 the specified series and index.

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 the specified series and index

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.
Returns:
a List of String objects that can be used as series names.