Class KeyedListsTable

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.jfree.data.KeyedValues2D, org.jfree.data.Values2D

    public class KeyedListsTable
    extends java.lang.Object
    implements org.jfree.data.KeyedValues2D, java.lang.Cloneable, java.io.Serializable
    A data structure that stores lists, where each list is associated with two keys (a 'row' key and a 'column' key).
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      KeyedListsTable()
      Creates a new table.
      KeyedListsTable​(boolean sortRowKeys)
      Creates a new table.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addToList​(java.lang.Object element, java.lang.Comparable rowKey, java.lang.Comparable columnKey)
      Adds a element to a list.
      void clear()
      Clears all the data and associated keys.
      int getColumnCount()
      Returns the column count.
      int getColumnIndex​(java.lang.Comparable key)
      Returns the column index for a given key.
      java.lang.Comparable getColumnKey​(int column)
      Returns the key for a given column.
      java.util.List getColumnKeys()
      Returns the column keys in an unmodifiable list.
      java.util.List getList​(java.lang.Comparable rowKey, java.lang.Comparable columnKey)
      Returns the List for the given row and column keys.
      int getRowCount()
      Returns the row count.
      int getRowIndex​(java.lang.Comparable key)
      Returns the row index for a given key.
      java.lang.Comparable getRowKey​(int row)
      Returns the key for a given row.
      java.util.List getRowKeys()
      Returns the row keys in an unmodifiable list.
      java.lang.Number getValue​(int row, int column)
      Returns the value for a given row and column.
      java.lang.Number getValue​(java.lang.Comparable rowKey, java.lang.Comparable columnKey)
      Returns the value for the given row and column keys.
      void removeColumn​(int columnIndex)
      Removes a column.
      void removeColumn​(java.lang.Comparable columnKey)
      Removes a column.
      void removeFromList​(java.lang.Object element, java.lang.Comparable rowKey, java.lang.Comparable columnKey)
      Removes an element from the table.
      void removeList​(java.lang.Comparable rowKey, java.lang.Comparable columnKey)
      Removes a value from the table by setting it to null.
      void removeRow​(int rowIndex)
      Removes a row.
      void removeRow​(java.lang.Comparable rowKey)
      Removes a row.
      void setList​(java.util.List list, java.lang.Comparable rowKey, java.lang.Comparable columnKey)
      Adds or updates a list.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • KeyedListsTable

        public KeyedListsTable()
        Creates a new table.
      • KeyedListsTable

        public KeyedListsTable​(boolean sortRowKeys)
        Creates a new table.
        Parameters:
        sortRowKeys - if the row keys should be sorted.
    • Method Detail

      • getList

        public java.util.List getList​(java.lang.Comparable rowKey,
                                      java.lang.Comparable columnKey)
        Returns the List for the given row and column keys.
        Parameters:
        rowKey - the row key (null not permitted).
        columnKey - the column key (null not permitted).
        Returns:
        The List (possibly null).
      • setList

        public void setList​(java.util.List list,
                            java.lang.Comparable rowKey,
                            java.lang.Comparable columnKey)
        Adds or updates a list.
        Parameters:
        list - the list (null permitted).
        rowKey - the row key (null not permitted).
        columnKey - the column key (null not permitted).
      • addToList

        public void addToList​(java.lang.Object element,
                              java.lang.Comparable rowKey,
                              java.lang.Comparable columnKey)
        Adds a element to a list.
        Parameters:
        element - the element to add (null permitted).
        rowKey - the row key (null not permitted).
        columnKey - the column key (null not permitted).
      • removeList

        public void removeList​(java.lang.Comparable rowKey,
                               java.lang.Comparable columnKey)
        Removes a value from the table by setting it to null. If all the values in the specified row and/or column are now null, the row and/or column is removed from the table.
        Parameters:
        rowKey - the row key (null not permitted).
        columnKey - the column key (null not permitted).
      • removeFromList

        public void removeFromList​(java.lang.Object element,
                                   java.lang.Comparable rowKey,
                                   java.lang.Comparable columnKey)
        Removes an element from the table. If the list is empty, it is set to null. If all the values in the specified row and/or column are now null, the row and/or column is removed from the table.
        Parameters:
        rowKey - the row key (null not permitted).
        columnKey - the column key (null not permitted).
      • removeRow

        public void removeRow​(int rowIndex)
        Removes a row.
        Parameters:
        rowIndex - the row index.
      • removeRow

        public void removeRow​(java.lang.Comparable rowKey)
        Removes a row. If all values of any column are null, the column(s) is/are removed.
        Parameters:
        rowKey - the row key (null not permitted).
      • removeColumn

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

        public void removeColumn​(java.lang.Comparable columnKey)
        Removes a column.
        Parameters:
        columnKey - the column key (null not permitted).
      • clear

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

        public int getRowCount()
        Returns the row count.
        Specified by:
        getRowCount in interface org.jfree.data.Values2D
        Returns:
        The row count.
      • getColumnCount

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

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

        public java.lang.Number getValue​(java.lang.Comparable rowKey,
                                         java.lang.Comparable columnKey)
        Returns the value for the given row and column keys.
        Specified by:
        getValue in interface org.jfree.data.KeyedValues2D
        Parameters:
        rowKey - the row key (null not permitted).
        columnKey - the column key (null not permitted).
        Returns:
        The value (possibly null).
      • getRowKey

        public java.lang.Comparable getRowKey​(int row)
        Returns the key for a given row.
        Specified by:
        getRowKey in interface org.jfree.data.KeyedValues2D
        Parameters:
        row - the row index (in the range 0 to getRowCount() - 1).
        Returns:
        The row key.
      • getRowIndex

        public int getRowIndex​(java.lang.Comparable key)
        Returns the row index for a given key.
        Specified by:
        getRowIndex in interface org.jfree.data.KeyedValues2D
        Parameters:
        key - the key (null not permitted).
        Returns:
        The row index.
      • getRowKeys

        public java.util.List getRowKeys()
        Returns the row keys in an unmodifiable list.
        Specified by:
        getRowKeys in interface org.jfree.data.KeyedValues2D
        Returns:
        The row keys.
      • getColumnKey

        public java.lang.Comparable getColumnKey​(int column)
        Returns the key for a given column.
        Specified by:
        getColumnKey in interface org.jfree.data.KeyedValues2D
        Parameters:
        column - the column (in the range 0 to getColumnCount() - 1).
        Returns:
        The key.
      • getColumnIndex

        public int getColumnIndex​(java.lang.Comparable key)
        Returns the column index for a given key.
        Specified by:
        getColumnIndex in interface org.jfree.data.KeyedValues2D
        Parameters:
        key - the key (null not permitted).
        Returns:
        The column index.
      • getColumnKeys

        public java.util.List getColumnKeys()
        Returns the column keys in an unmodifiable list.
        Specified by:
        getColumnKeys in interface org.jfree.data.KeyedValues2D
        Returns:
        The column keys.