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 voidaddValue(Number value, Comparable rowKey, Comparable columnKey)Adds a value to the table.voidclear()Clears all the data and associated keys.Objectclone()Returns a clone.booleanequals(Object o)Tests if this object is equal to another.intgetColumnCount()Returns the column count.intgetColumnIndex(Comparable key)Returns the column index for a given key.ComparablegetColumnKey(int column)Returns the key for a given column.ListgetColumnKeys()Returns the column keys.intgetRowCount()Returns the row count.intgetRowIndex(Comparable key)Returns the row index for a given key.ComparablegetRowKey(int row)Returns the key for a given row.ListgetRowKeys()Returns the row keys.NumbergetValue(int row, int column)Returns the value for a given row and column.NumbergetValue(Comparable rowKey, Comparable columnKey)Returns the value for the given row and column keys.inthashCode()Returns a hash code.voidremoveColumn(int columnIndex)Removes a column.voidremoveColumn(Comparable columnKey)Removes a column.voidremoveRow(int rowIndex)Removes a row.voidremoveRow(Comparable rowKey)Removes a row.voidremoveValue(Comparable rowKey, Comparable columnKey)Removes a value.voidsetValue(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:
getRowCountin interfaceValues2D- Returns:
- the row count.
-
getColumnCount
public int getColumnCount()Returns the column count.- Specified by:
getColumnCountin 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:
getRowKeyin interfaceKeyedValues2D- Parameters:
row- the row index (zero based).- Returns:
- the row index.
-
getRowIndex
Returns the row index for a given key.- Specified by:
getRowIndexin interfaceKeyedValues2D- Parameters:
key- the key.- Returns:
- the row index.
-
getRowKeys
Returns the row keys.- Specified by:
getRowKeysin interfaceKeyedValues2D- Returns:
- the row keys.
-
getColumnKey
Returns the key for a given column.- Specified by:
getColumnKeyin interfaceKeyedValues2D- Parameters:
column- the column.- Returns:
- the key.
-
getColumnIndex
Returns the column index for a given key.- Specified by:
getColumnIndexin interfaceKeyedValues2D- Parameters:
key- the key.- Returns:
- the column index.
-
getColumnKeys
Returns the column keys.- Specified by:
getColumnKeysin interfaceKeyedValues2D- Returns:
- the column keys.
-
getValue
Returns the value for the given row and column keys.- Specified by:
getValuein 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.
-