org.jfree.data.category

Class DefaultCategoryDataset

public class DefaultCategoryDataset extends AbstractDataset implements CategoryDataset, PublicCloneable, Serializable

A default implementation of the CategoryDataset interface.
Constructor Summary
DefaultCategoryDataset()
Creates a new (empty) dataset.
Method Summary
voidaddValue(Number value, Comparable rowKey, Comparable columnKey)
Adds a value to the table.
voidaddValue(double value, Comparable rowKey, Comparable columnKey)
Adds a value to the table.
voidclear()
Clears all data from the dataset and sends a DatasetChangeEvent to all registered listeners.
Objectclone()
Returns a clone of the dataset.
booleanequals(Object obj)
Tests this dataset for equality with an arbitrary object.
intgetColumnCount()
Returns the number of columns in the table.
intgetColumnIndex(Comparable key)
Returns the column index for a given key.
ComparablegetColumnKey(int column)
Returns a column key.
ListgetColumnKeys()
Returns the column keys.
intgetRowCount()
Returns the number of rows in the table.
intgetRowIndex(Comparable key)
Returns the row index for a given key.
ComparablegetRowKey(int row)
Returns the key for the specified row.
ListgetRowKeys()
Returns the row keys.
NumbergetValue(int row, int column)
Returns a value from the table.
NumbergetValue(Comparable rowKey, Comparable columnKey)
Returns the value for a pair of keys.
inthashCode()
Returns a hash code for the dataset.
voidincrementValue(double value, Comparable rowKey, Comparable columnKey)
Adds the specified value to an existing value in the dataset (if the existing value is null, it is treated as if it were 0.0).
voidremoveColumn(int columnIndex)
Removes a column from the dataset and sends a DatasetChangeEvent to all registered listeners.
voidremoveColumn(Comparable columnKey)
Removes a column from the dataset and sends a DatasetChangeEvent to all registered listeners.
voidremoveRow(int rowIndex)
Removes a row from the dataset and sends a DatasetChangeEvent to all registered listeners.
voidremoveRow(Comparable rowKey)
Removes a row from the dataset and sends a DatasetChangeEvent to all registered listeners.
voidremoveValue(Comparable rowKey, Comparable columnKey)
Removes a value from the dataset and sends a DatasetChangeEvent to all registered listeners.
voidsetValue(Number value, Comparable rowKey, Comparable columnKey)
Adds or updates a value in the table and sends a DatasetChangeEvent to all registered listeners.
voidsetValue(double value, Comparable rowKey, Comparable columnKey)
Adds or updates a value in the table and sends a DatasetChangeEvent to all registered listeners.

Constructor Detail

DefaultCategoryDataset

public DefaultCategoryDataset()
Creates a new (empty) dataset.

Method Detail

addValue

public void addValue(Number value, Comparable rowKey, Comparable columnKey)
Adds a value to the table. Performs the same function as setValue().

Parameters: value the value. rowKey the row key. columnKey the column key.

See Also: DefaultCategoryDataset DefaultCategoryDataset

addValue

public void addValue(double value, Comparable rowKey, Comparable columnKey)
Adds a value to the table.

Parameters: value the value. rowKey the row key. columnKey the column key.

See Also: DefaultCategoryDataset

clear

public void clear()
Clears all data from the dataset and sends a DatasetChangeEvent to all registered listeners.

clone

public Object clone()
Returns a clone of the dataset.

Returns: A clone.

Throws: CloneNotSupportedException if there is a problem cloning the dataset.

equals

public boolean equals(Object obj)
Tests this dataset for equality with an arbitrary object.

Parameters: obj the object (null permitted).

Returns: A boolean.

getColumnCount

public int getColumnCount()
Returns the number of columns in the table.

Returns: The column count.

See Also: getRowCount

getColumnIndex

public int getColumnIndex(Comparable key)
Returns the column index for a given key.

Parameters: key the column key (null not permitted).

Returns: The column index.

See Also: DefaultCategoryDataset

getColumnKey

public Comparable getColumnKey(int column)
Returns a column key.

Parameters: column the column index (zero-based).

Returns: The column key.

See Also: getColumnIndex

getColumnKeys

public List getColumnKeys()
Returns the column keys.

Returns: The keys.

See Also: DefaultCategoryDataset

getRowCount

public int getRowCount()
Returns the number of rows in the table.

Returns: The row count.

See Also: getColumnCount

getRowIndex

public int getRowIndex(Comparable key)
Returns the row index for a given key.

Parameters: key the row key (null not permitted).

Returns: The row index.

See Also: DefaultCategoryDataset

getRowKey

public Comparable getRowKey(int row)
Returns the key for the specified row.

Parameters: row the row index (zero-based).

Returns: The row key.

See Also: getRowIndex getRowKeys DefaultCategoryDataset

getRowKeys

public List getRowKeys()
Returns the row keys.

Returns: The keys.

See Also: DefaultCategoryDataset

getValue

public Number getValue(int row, int column)
Returns a value from the table.

Parameters: row the row index (zero-based). column the column index (zero-based).

Returns: The value (possibly null).

See Also: DefaultCategoryDataset DefaultCategoryDataset

getValue

public Number getValue(Comparable rowKey, Comparable columnKey)
Returns the value for a pair of keys.

Parameters: rowKey the row key (null not permitted). columnKey the column key (null not permitted).

Returns: The value (possibly null).

Throws: UnknownKeyException if either key is not defined in the dataset.

See Also: DefaultCategoryDataset

hashCode

public int hashCode()
Returns a hash code for the dataset.

Returns: A hash code.

incrementValue

public void incrementValue(double value, Comparable rowKey, Comparable columnKey)
Adds the specified value to an existing value in the dataset (if the existing value is null, it is treated as if it were 0.0).

Parameters: value the value. rowKey the row key (null not permitted). columnKey the column key (null not permitted).

Throws: UnknownKeyException if either key is not defined in the dataset.

removeColumn

public void removeColumn(int columnIndex)
Removes a column from the dataset and sends a DatasetChangeEvent to all registered listeners.

Parameters: columnIndex the column index.

See Also: DefaultCategoryDataset

removeColumn

public void removeColumn(Comparable columnKey)
Removes a column from the dataset and sends a DatasetChangeEvent to all registered listeners.

Parameters: columnKey the column key (null not permitted).

Throws: UnknownKeyException if columnKey is not defined in the dataset.

See Also:

removeRow

public void removeRow(int rowIndex)
Removes a row from the dataset and sends a DatasetChangeEvent to all registered listeners.

Parameters: rowIndex the row index.

See Also: DefaultCategoryDataset

removeRow

public void removeRow(Comparable rowKey)
Removes a row from the dataset and sends a DatasetChangeEvent to all registered listeners.

Parameters: rowKey the row key.

See Also: removeColumn

removeValue

public void removeValue(Comparable rowKey, Comparable columnKey)
Removes a value from the dataset and sends a DatasetChangeEvent to all registered listeners.

Parameters: rowKey the row key. columnKey the column key.

See Also: DefaultCategoryDataset

setValue

public void setValue(Number value, Comparable rowKey, Comparable columnKey)
Adds or updates a value in the table and sends a DatasetChangeEvent to all registered listeners.

Parameters: value the value (null permitted). rowKey the row key (null not permitted). columnKey the column key (null not permitted).

See Also: DefaultCategoryDataset

setValue

public void setValue(double value, Comparable rowKey, Comparable columnKey)
Adds or updates a value in the table and sends a DatasetChangeEvent to all registered listeners.

Parameters: value the value. rowKey the row key (null not permitted). columnKey the column key (null not permitted).

See Also: DefaultCategoryDataset