Package org.jfree.data
Class DefaultCategoryDataset
java.lang.Object
org.jfree.data.AbstractDataset
org.jfree.data.DefaultCategoryDataset
- All Implemented Interfaces:
ObjectInputValidation
,Serializable
,Cloneable
,CategoryDataset
,Dataset
,KeyedValues2D
,Values2D
- Direct Known Subclasses:
DefaultKeyedValues2DDataset
,JDBCCategoryDataset
public class DefaultCategoryDataset extends AbstractDataset implements CategoryDataset, Serializable
A default implementation of the
CategoryDataset
interface.- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description DefaultCategoryDataset()
Creates a new (empty) dataset. -
Method Summary
Modifier and Type Method Description void
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.boolean
equals(Object o)
Tests if this object is equal to another.int
getColumnCount()
Returns the number of columns in the table.int
getColumnIndex(Comparable key)
Returns the column index for a given key.Comparable
getColumnKey(int column)
Returns a column key.List
getColumnKeys()
Returns the column keys.int
getRowCount()
Returns the number of rows in the table.int
getRowIndex(Comparable key)
Returns the row index for a given key.Comparable
getRowKey(int row)
Returns a row key.List
getRowKeys()
Returns the row keys.Number
getValue(int row, int column)
Returns a value from the table.Number
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.void
removeColumn(Comparable columnKey)
Removes a column from the dataset.void
removeRow(int rowIndex)
Removes a row from the dataset.void
removeRow(Comparable rowKey)
Removes a row from the dataset.void
removeValue(Comparable rowKey, Comparable columnKey)
Removes a value from the dataset.void
setValue(double value, Comparable rowKey, Comparable columnKey)
Adds or updates a value in the table.void
setValue(Number value, Comparable rowKey, Comparable columnKey)
Adds or updates a value in the table.Methods inherited from class org.jfree.data.AbstractDataset
addChangeListener, clone, getGroup, removeChangeListener, setGroup, validateObject
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jfree.data.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
-
Constructor Details
-
DefaultCategoryDataset
public DefaultCategoryDataset()Creates a new (empty) dataset.
-
-
Method Details
-
getRowCount
public int getRowCount()Returns the number of rows in the table.- Specified by:
getRowCount
in interfaceValues2D
- Returns:
- the row count.
-
getColumnCount
public int getColumnCount()Returns the number of columns in the table.- Specified by:
getColumnCount
in interfaceValues2D
- Returns:
- the column count.
-
getValue
Returns a value from the table. -
getRowKey
Returns a row key.- Specified by:
getRowKey
in interfaceKeyedValues2D
- Parameters:
row
- the row index (zero-based).- Returns:
- the row key.
-
getRowIndex
Returns the row index for a given key.- Specified by:
getRowIndex
in interfaceKeyedValues2D
- Parameters:
key
- the row key.- Returns:
- the row index.
-
getRowKeys
Returns the row keys.- Specified by:
getRowKeys
in interfaceKeyedValues2D
- Returns:
- the keys.
-
getColumnKey
Returns a column key.- Specified by:
getColumnKey
in interfaceKeyedValues2D
- Parameters:
column
- the column index (zero-based).- Returns:
- the column key.
-
getColumnIndex
Returns the column index for a given key.- Specified by:
getColumnIndex
in interfaceKeyedValues2D
- Parameters:
key
- the column key.- Returns:
- the column index.
-
getColumnKeys
Returns the column keys.- Specified by:
getColumnKeys
in interfaceKeyedValues2D
- Returns:
- the keys.
-
getValue
Returns the value for a pair of keys.This method should return
null
if either of the keys is not found.- Specified by:
getValue
in interfaceKeyedValues2D
- Parameters:
rowKey
- the row key.columnKey
- the column key.- Returns:
- the value.
-
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.
-
addValue
Adds a value to the table.- Parameters:
value
- the value.rowKey
- the row key.columnKey
- the column key.
-
setValue
Adds or updates a value in the table.- Parameters:
value
- the value.rowKey
- the row key.columnKey
- the column key.
-
setValue
Adds or updates a value in the table.- Parameters:
value
- the value.rowKey
- the row key.columnKey
- the column key.
-
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.columnKey
- the column key.
-
removeValue
Removes a value from the dataset.- Parameters:
rowKey
- the row key.columnKey
- the column key.
-
removeRow
public void removeRow(int rowIndex)Removes a row from the dataset.- Parameters:
rowIndex
- the row index.
-
removeRow
Removes a row from the dataset.- Parameters:
rowKey
- the row key.
-
removeColumn
public void removeColumn(int columnIndex)Removes a column from the dataset.- Parameters:
columnIndex
- the column index.
-
removeColumn
Removes a column from the dataset.- Parameters:
columnKey
- the column key.
-
clear
public void clear()Clears all data from the dataset and sends aDatasetChangeEvent
to all registered listeners. -
equals
Tests if this object is equal to another. -
hashCode
public int hashCode()Returns a hash code for the dataset.
-