Package org.jfree.data
Class DefaultKeyedValues2D
java.lang.Object
org.jfree.data.DefaultKeyedValues2D
- All Implemented Interfaces:
Serializable
,Cloneable
,KeyedValues2D
,Values2D
public class DefaultKeyedValues2D extends Object implements KeyedValues2D, Cloneable, Serializable
A data structure that stores zero, one or many values, where each value is
associated with two keys (a 'row' key and a 'column' key).
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description DefaultKeyedValues2D()
Creates a new instance (initially empty).DefaultKeyedValues2D(boolean sortRowKeys)
Creates a new instance (initially empty). -
Method Summary
Modifier and Type Method Description void
addValue(Number value, Comparable rowKey, Comparable columnKey)
Adds a value to the table.void
clear()
Clears all the data and associated keys.Object
clone()
Returns a clone.boolean
equals(Object o)
Tests if this object is equal to another.int
getColumnCount()
Returns the column count.int
getColumnIndex(Comparable key)
Returns the column index for a given key.Comparable
getColumnKey(int column)
Returns the key for a given column.List
getColumnKeys()
Returns the column keys.int
getRowCount()
Returns the row count.int
getRowIndex(Comparable key)
Returns the row index for a given key.Comparable
getRowKey(int row)
Returns the key for a given row.List
getRowKeys()
Returns the row keys.Number
getValue(int row, int column)
Returns the value for a given row and column.Number
getValue(Comparable rowKey, Comparable columnKey)
Returns the value for the given row and column keys.int
hashCode()
Returns a hash code.void
removeColumn(int columnIndex)
Removes a column.void
removeColumn(Comparable columnKey)
Removes a column.void
removeRow(int rowIndex)
Removes a row.void
removeRow(Comparable rowKey)
Removes a row.void
removeValue(Comparable rowKey, Comparable columnKey)
Removes a value.void
setValue(Number value, Comparable rowKey, Comparable columnKey)
Adds or updates a value.
-
Constructor Details
-
DefaultKeyedValues2D
public DefaultKeyedValues2D()Creates a new instance (initially empty). -
DefaultKeyedValues2D
public DefaultKeyedValues2D(boolean sortRowKeys)Creates a new instance (initially empty).- Parameters:
sortRowKeys
- if the row keys should be sorted.
-
-
Method Details
-
getRowCount
public int getRowCount()Returns the row count.- Specified by:
getRowCount
in interfaceValues2D
- Returns:
- the row count.
-
getColumnCount
public int getColumnCount()Returns the column count.- Specified by:
getColumnCount
in interfaceValues2D
- Returns:
- the column count.
-
getValue
Returns the value for a given row and column. -
getRowKey
Returns the key for a given row.- Specified by:
getRowKey
in interfaceKeyedValues2D
- Parameters:
row
- the row index (zero based).- Returns:
- the row index.
-
getRowIndex
Returns the row index for a given key.- Specified by:
getRowIndex
in interfaceKeyedValues2D
- Parameters:
key
- the key.- Returns:
- the row index.
-
getRowKeys
Returns the row keys.- Specified by:
getRowKeys
in interfaceKeyedValues2D
- Returns:
- the row keys.
-
getColumnKey
Returns the key for a given column.- Specified by:
getColumnKey
in interfaceKeyedValues2D
- Parameters:
column
- the column.- Returns:
- the key.
-
getColumnIndex
Returns the column index for a given key.- Specified by:
getColumnIndex
in interfaceKeyedValues2D
- Parameters:
key
- the key.- Returns:
- the column index.
-
getColumnKeys
Returns the column keys.- Specified by:
getColumnKeys
in interfaceKeyedValues2D
- Returns:
- the column keys.
-
getValue
Returns the value for the given row and column keys.- 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.
-
setValue
Adds or updates a value.- Parameters:
value
- the value.rowKey
- the row key.columnKey
- the column key.
-
removeValue
Removes a value.- Parameters:
rowKey
- the row key.columnKey
- the column key.
-
removeRow
public void removeRow(int rowIndex)Removes a row.- Parameters:
rowIndex
- the row index.
-
removeRow
Removes a row.- Parameters:
rowKey
- the row key.
-
removeColumn
public void removeColumn(int columnIndex)Removes a column.- Parameters:
columnIndex
- the column index.
-
removeColumn
Removes a column.- Parameters:
columnKey
- the column key.
-
clear
public void clear()Clears all the data and associated keys. -
equals
Tests if this object is equal to another. -
hashCode
public int hashCode()Returns a hash code. -
clone
Returns a clone.- Returns:
- A clone.
- Throws:
CloneNotSupportedException
- this class will not throw this exception, but subclasses (if any) might.
-