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 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 interface Values2D
      Returns:
      the row count.
    • getColumnCount

      public int getColumnCount()
      Returns the column count.
      Specified by:
      getColumnCount in interface Values2D
      Returns:
      the column count.
    • getValue

      public Number getValue​(int row, int column)
      Returns the value for a given row and column.
      Specified by:
      getValue in interface Values2D
      Parameters:
      row - the row index.
      column - the column index.
      Returns:
      the value.
    • getRowKey

      public Comparable getRowKey​(int row)
      Returns the key for a given row.
      Specified by:
      getRowKey in interface KeyedValues2D
      Parameters:
      row - the row index (zero based).
      Returns:
      the row index.
    • getRowIndex

      public int getRowIndex​(Comparable key)
      Returns the row index for a given key.
      Specified by:
      getRowIndex in interface KeyedValues2D
      Parameters:
      key - the key.
      Returns:
      the row index.
    • getRowKeys

      public List getRowKeys()
      Returns the row keys.
      Specified by:
      getRowKeys in interface KeyedValues2D
      Returns:
      the row keys.
    • getColumnKey

      public Comparable getColumnKey​(int column)
      Returns the key for a given column.
      Specified by:
      getColumnKey in interface KeyedValues2D
      Parameters:
      column - the column.
      Returns:
      the key.
    • getColumnIndex

      public int getColumnIndex​(Comparable key)
      Returns the column index for a given key.
      Specified by:
      getColumnIndex in interface KeyedValues2D
      Parameters:
      key - the key.
      Returns:
      the column index.
    • getColumnKeys

      public List getColumnKeys()
      Returns the column keys.
      Specified by:
      getColumnKeys in interface KeyedValues2D
      Returns:
      the column keys.
    • getValue

      public Number getValue​(Comparable rowKey, Comparable columnKey)
      Returns the value for the given row and column keys.
      Specified by:
      getValue in interface KeyedValues2D
      Parameters:
      rowKey - the row key.
      columnKey - the column key.
      Returns:
      the value.
    • 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.
    • setValue

      public void setValue​(Number value, Comparable rowKey, Comparable columnKey)
      Adds or updates a value.
      Parameters:
      value - the value.
      rowKey - the row key.
      columnKey - the column key.
    • removeValue

      public void removeValue​(Comparable rowKey, Comparable columnKey)
      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

      public void removeRow​(Comparable rowKey)
      Removes a row.
      Parameters:
      rowKey - the row key.
    • removeColumn

      public void removeColumn​(int columnIndex)
      Removes a column.
      Parameters:
      columnIndex - the column index.
    • removeColumn

      public void removeColumn​(Comparable columnKey)
      Removes a column.
      Parameters:
      columnKey - the column key.
    • clear

      public void clear()
      Clears all the data and associated keys.
    • equals

      public boolean equals​(Object o)
      Tests if this object is equal to another.
      Overrides:
      equals in class Object
      Parameters:
      o - the other object.
      Returns:
      A boolean.
    • hashCode

      public int hashCode()
      Returns a hash code.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code.
    • clone

      public Object clone() throws CloneNotSupportedException
      Returns a clone.
      Returns:
      A clone.
      Throws:
      CloneNotSupportedException - this class will not throw this exception, but subclasses (if any) might.