Package org.jfree.data.category
Class DefaultCategoryDataset
java.lang.Object
org.jfree.data.general.AbstractDataset
org.jfree.data.category.DefaultCategoryDataset
- All Implemented Interfaces:
ObjectInputValidation
,Serializable
,Cloneable
,PublicCloneable
,CategoryDataset
,Dataset
,KeyedValues2D
,Values2D
- Direct Known Subclasses:
DefaultKeyedValues2DDataset
,JDBCCategoryDataset
public class DefaultCategoryDataset
extends AbstractDataset
implements CategoryDataset, PublicCloneable, Serializable
A default implementation of the
CategoryDataset
interface.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addValue
(double value, Comparable rowKey, Comparable columnKey) Adds a value to the table.void
addValue
(Number value, Comparable rowKey, Comparable columnKey) Adds a value to the table.void
clear()
Clears all data from the dataset and sends aDatasetChangeEvent
to all registered listeners.clone()
Returns a clone of the dataset.boolean
Tests this dataset for equality with an arbitrary object.int
Returns the number of columns in the table.int
getColumnIndex
(Comparable key) Returns the column index for a given key.getColumnKey
(int column) Returns a column key.Returns the column keys.int
Returns the number of rows in the table.int
getRowIndex
(Comparable key) Returns the row index for a given key.getRowKey
(int row) Returns the key for the specified row.Returns the row keys.getValue
(int row, int column) Returns a value from the table.getValue
(Comparable rowKey, Comparable columnKey) Returns the value for a pair of keys.int
hashCode()
Returns a hash code for the dataset.void
incrementValue
(double value, Comparable rowKey, Comparable columnKey) Adds the specified value to an existing value in the dataset (if the existing value isnull
, it is treated as if it were 0.0).void
removeColumn
(int columnIndex) Removes a column from the dataset and sends aDatasetChangeEvent
to all registered listeners.void
removeColumn
(Comparable columnKey) Removes a column from the dataset and sends aDatasetChangeEvent
to all registered listeners.void
removeRow
(int rowIndex) Removes a row from the dataset and sends aDatasetChangeEvent
to all registered listeners.void
removeRow
(Comparable rowKey) Removes a row from the dataset and sends aDatasetChangeEvent
to all registered listeners.void
removeValue
(Comparable rowKey, Comparable columnKey) Removes a value from the dataset and sends aDatasetChangeEvent
to all registered listeners.void
setValue
(double value, Comparable rowKey, Comparable columnKey) Adds or updates a value in the table and sends aDatasetChangeEvent
to all registered listeners.void
setValue
(Number value, Comparable rowKey, Comparable columnKey) Adds or updates a value in the table and sends aDatasetChangeEvent
to all registered listeners.Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, canEqual, fireDatasetChanged, getGroup, getNotify, hasListener, notifyListeners, removeChangeListener, setGroup, setNotify, validateObject
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jfree.data.general.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
-
Constructor Details
-
DefaultCategoryDataset
public DefaultCategoryDataset()Creates a new (empty) dataset.
-
-
Method Details
-
getRowCount
Returns the number of rows in the table.- Specified by:
getRowCount
in interfaceValues2D
- Returns:
- The row count.
- See Also:
-
getColumnCount
Returns the number of columns in the table.- Specified by:
getColumnCount
in interfaceValues2D
- Returns:
- The column count.
- See Also:
-
getValue
Returns a value from the table. -
getRowKey
Returns the key for the specified row.- Specified by:
getRowKey
in interfaceKeyedValues2D
- Parameters:
row
- the row index (zero-based).- Returns:
- The row key.
- See Also:
-
getRowIndex
Returns the row index for a given key.- Specified by:
getRowIndex
in interfaceKeyedValues2D
- Parameters:
key
- the row key (null
not permitted).- Returns:
- The row index.
- See Also:
-
getRowKeys
Returns the row keys.- Specified by:
getRowKeys
in interfaceKeyedValues2D
- Returns:
- The keys.
- See Also:
-
getColumnKey
Returns a column key.- Specified by:
getColumnKey
in interfaceKeyedValues2D
- Parameters:
column
- the column index (zero-based).- Returns:
- The column key.
- See Also:
-
getColumnIndex
Returns the column index for a given key.- Specified by:
getColumnIndex
in interfaceKeyedValues2D
- Parameters:
key
- the column key (null
not permitted).- Returns:
- The column index.
- See Also:
-
getColumnKeys
Returns the column keys.- Specified by:
getColumnKeys
in interfaceKeyedValues2D
- Returns:
- The keys.
- See Also:
-
getValue
Returns the value for a pair of keys.- Specified by:
getValue
in interfaceKeyedValues2D
- 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:
-
addValue
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:
-
addValue
Adds a value to the table.- Parameters:
value
- the value.rowKey
- the row key.columnKey
- the column key.- See Also:
-
setValue
Adds or updates a value in the table and sends aDatasetChangeEvent
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:
-
setValue
Adds or updates a value in the table and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
value
- the value.rowKey
- the row key (null
not permitted).columnKey
- the column key (null
not permitted).- See Also:
-
incrementValue
Adds the specified value to an existing value in the dataset (if the existing value isnull
, 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.
-
removeValue
Removes a value from the dataset and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
rowKey
- the row key.columnKey
- the column key.- See Also:
-
removeRow
Removes a row from the dataset and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
rowIndex
- the row index.- See Also:
-
removeRow
Removes a row from the dataset and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
rowKey
- the row key.- See Also:
-
removeColumn
Removes a column from the dataset and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
columnIndex
- the column index.- See Also:
-
removeColumn
Removes a column from the dataset and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
columnKey
- the column key (null
not permitted).- Throws:
UnknownKeyException
- ifcolumnKey
is not defined in the dataset.- See Also:
-
clear
Clears all data from the dataset and sends aDatasetChangeEvent
to all registered listeners. -
equals
Tests this dataset for equality with an arbitrary object.- Overrides:
equals
in classAbstractDataset
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
hashCode
Returns a hash code for the dataset.- Overrides:
hashCode
in classAbstractDataset
- Returns:
- A hash code.
-
clone
Returns a clone of the dataset.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classAbstractDataset
- Returns:
- A clone.
- Throws:
CloneNotSupportedException
- if there is a problem cloning the dataset.
-