org.jfree.data.xy

Class DefaultXYDataset

public class DefaultXYDataset extends AbstractXYDataset implements XYDataset, PublicCloneable

A default implementation of the XYDataset interface that stores data values in arrays of double primitives.

Since: 1.0.2

Constructor Summary
DefaultXYDataset()
Creates a new DefaultXYDataset instance, initially containing no data.
Method Summary
voidaddSeries(Comparable seriesKey, double[][] data)
Adds a series or if a series with the same key already exists replaces the data for that series, then sends a DatasetChangeEvent to all registered listeners.
Objectclone()
Creates an independent copy of this dataset.
booleanequals(Object obj)
Tests this DefaultXYDataset instance for equality with an arbitrary object.
DomainOrdergetDomainOrder()
Returns the order of the domain (x-) values in the dataset.
intgetItemCount(int series)
Returns the number of items in the specified series.
intgetSeriesCount()
Returns the number of series in the dataset.
ComparablegetSeriesKey(int series)
Returns the key for a series.
NumbergetX(int series, int item)
Returns the x-value for an item within a series.
doublegetXValue(int series, int item)
Returns the x-value for an item within a series.
NumbergetY(int series, int item)
Returns the y-value for an item within a series.
doublegetYValue(int series, int item)
Returns the y-value for an item within a series.
inthashCode()
Returns a hash code for this instance.
intindexOf(Comparable seriesKey)
Returns the index of the series with the specified key, or -1 if there is no such series in the dataset.
voidremoveSeries(Comparable seriesKey)
Removes a series from the dataset, then sends a DatasetChangeEvent to all registered listeners.

Constructor Detail

DefaultXYDataset

public DefaultXYDataset()
Creates a new DefaultXYDataset instance, initially containing no data.

Method Detail

addSeries

public void addSeries(Comparable seriesKey, double[][] data)
Adds a series or if a series with the same key already exists replaces the data for that series, then sends a DatasetChangeEvent to all registered listeners.

Parameters: seriesKey the series key (null not permitted). data the data (must be an array with length 2, containing two arrays of equal length, the first containing the x-values and the second containing the y-values).

clone

public Object clone()
Creates an independent copy of this dataset.

Returns: The cloned dataset.

Throws: CloneNotSupportedException if there is a problem cloning the dataset (for instance, if a non-cloneable object is used for a series key).

equals

public boolean equals(Object obj)
Tests this DefaultXYDataset instance for equality with an arbitrary object. This method returns true if and only if:

Parameters: obj the object (null permitted).

Returns: A boolean.

getDomainOrder

public DomainOrder getDomainOrder()
Returns the order of the domain (x-) values in the dataset. In this implementation, we cannot guarantee that the x-values are ordered, so this method returns DomainOrder.NONE.

Returns: DomainOrder.NONE.

getItemCount

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

Parameters: series the series index (in the range 0 to getSeriesCount() - 1).

Returns: The item count.

Throws: IllegalArgumentException if series is not in the specified range.

getSeriesCount

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

Returns: The series count.

getSeriesKey

public Comparable getSeriesKey(int series)
Returns the key for a series.

Parameters: series the series index (in the range 0 to getSeriesCount() - 1).

Returns: The key for the series.

Throws: IllegalArgumentException if series is not in the specified range.

getX

public Number getX(int series, int item)
Returns the x-value for an item within a series.

Parameters: series the series index (in the range 0 to getSeriesCount() - 1). item the item index (in the range 0 to getItemCount(series)).

Returns: The x-value.

Throws: ArrayIndexOutOfBoundsException if series is not within the specified range. ArrayIndexOutOfBoundsException if item is not within the specified range.

See Also: DefaultXYDataset

getXValue

public double getXValue(int series, int item)
Returns the x-value for an item within a series.

Parameters: series the series index (in the range 0 to getSeriesCount() - 1). item the item index (in the range 0 to getItemCount(series)).

Returns: The x-value.

Throws: ArrayIndexOutOfBoundsException if series is not within the specified range. ArrayIndexOutOfBoundsException if item is not within the specified range.

See Also: DefaultXYDataset

getY

public Number getY(int series, int item)
Returns the y-value for an item within a series.

Parameters: series the series index (in the range 0 to getSeriesCount() - 1). item the item index (in the range 0 to getItemCount(series)).

Returns: The y-value.

Throws: ArrayIndexOutOfBoundsException if series is not within the specified range. ArrayIndexOutOfBoundsException if item is not within the specified range.

See Also: DefaultXYDataset

getYValue

public double getYValue(int series, int item)
Returns the y-value for an item within a series.

Parameters: series the series index (in the range 0 to getSeriesCount() - 1). item the item index (in the range 0 to getItemCount(series)).

Returns: The y-value.

Throws: ArrayIndexOutOfBoundsException if series is not within the specified range. ArrayIndexOutOfBoundsException if item is not within the specified range.

See Also: DefaultXYDataset

hashCode

public int hashCode()
Returns a hash code for this instance.

Returns: A hash code.

indexOf

public int indexOf(Comparable seriesKey)
Returns the index of the series with the specified key, or -1 if there is no such series in the dataset.

Parameters: seriesKey the series key (null permitted).

Returns: The index, or -1.

removeSeries

public void removeSeries(Comparable seriesKey)
Removes a series from the dataset, then sends a DatasetChangeEvent to all registered listeners.

Parameters: seriesKey the series key (null not permitted).

Copyright © 2000-2009 by Object Refinery Limited. All Rights Reserved.