Class DefaultPieDataset<K extends Comparable<K>>

java.lang.Object
org.jfree.data.general.AbstractDataset
org.jfree.data.general.DefaultPieDataset<K>
Type Parameters:
K - Key type for PieDataset
All Implemented Interfaces:
ObjectInputValidation, Serializable, Cloneable, PublicCloneable, Dataset, PieDataset<K>, KeyedValues<K>, Values
Direct Known Subclasses:
DefaultKeyedValuesDataset, JDBCPieDataset

A default implementation of the PieDataset interface.
See Also:
  • Constructor Details

  • Method Details

    • getItemCount

      public int getItemCount()
      Returns the number of items in the dataset.
      Specified by:
      getItemCount in interface Values
      Returns:
      The item count.
    • getKeys

      public List<K> getKeys()
      Returns the categories in the dataset. The returned list is unmodifiable.
      Specified by:
      getKeys in interface KeyedValues<K extends Comparable<K>>
      Returns:
      The categories in the dataset.
    • getKey

      public K getKey(int item)
      Returns the key for the specified item, or null.
      Specified by:
      getKey in interface KeyedValues<K extends Comparable<K>>
      Parameters:
      item - the item index (in the range 0 to getItemCount() - 1).
      Returns:
      The key, or null.
      Throws:
      IndexOutOfBoundsException - if item is not in the specified range.
    • getIndex

      public int getIndex(K key)
      Returns the index for a key, or -1 if the key is not recognised.
      Specified by:
      getIndex in interface KeyedValues<K extends Comparable<K>>
      Parameters:
      key - the key (null not permitted).
      Returns:
      The index, or -1 if the key is unrecognised.
      Throws:
      IllegalArgumentException - if key is null.
    • getValue

      public Number getValue(int item)
      Returns a value.
      Specified by:
      getValue in interface Values
      Parameters:
      item - the value index.
      Returns:
      The value (possibly null).
    • getValue

      public Number getValue(K key)
      Returns the data value associated with a key.
      Specified by:
      getValue in interface KeyedValues<K extends Comparable<K>>
      Parameters:
      key - the key (null not permitted).
      Returns:
      The value (possibly null).
      Throws:
      UnknownKeyException - if the key is not recognised.
    • setValue

      public void setValue(K key, Number value)
      Sets the data value for a key and sends a DatasetChangeEvent to all registered listeners.
      Parameters:
      key - the key (null not permitted).
      value - the value.
      Throws:
      IllegalArgumentException - if key is null.
    • setValue

      public void setValue(K key, double value)
      Sets the data value for a key and sends a DatasetChangeEvent to all registered listeners.
      Parameters:
      key - the key (null not permitted).
      value - the value.
      Throws:
      IllegalArgumentException - if key is null.
    • insertValue

      public void insertValue(int position, K key, double value)
      Inserts a new value at the specified position in the dataset or, if there is an existing item with the specified key, updates the value for that item and moves it to the specified position. After the change is made, this methods sends a DatasetChangeEvent to all registered listeners.
      Parameters:
      position - the position (in the range 0 to getItemCount()).
      key - the key (null not permitted).
      value - the value (null permitted).
    • insertValue

      public void insertValue(int position, K key, Number value)
      Inserts a new value at the specified position in the dataset or, if there is an existing item with the specified key, updates the value for that item and moves it to the specified position. After the change is made, this methods sends a DatasetChangeEvent to all registered listeners.
      Parameters:
      position - the position (in the range 0 to getItemCount()).
      key - the key (null not permitted).
      value - the value (null permitted).
    • remove

      public void remove(K key)
      Removes an item from the dataset and sends a DatasetChangeEvent to all registered listeners.
      Parameters:
      key - the key (null not permitted).
      Throws:
      IllegalArgumentException - if key is null.
    • clear

      public void clear()
      Clears all data from this dataset and sends a DatasetChangeEvent to all registered listeners (unless the dataset was already empty).
    • sortByKeys

      public void sortByKeys(SortOrder order)
      Sorts the dataset's items by key and sends a DatasetChangeEvent to all registered listeners.
      Parameters:
      order - the sort order (null not permitted).
    • sortByValues

      public void sortByValues(SortOrder order)
      Sorts the dataset's items by value and sends a DatasetChangeEvent to all registered listeners.
      Parameters:
      order - the sort order (null not permitted).
    • equals

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

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

      Returns a clone of the dataset.
      Specified by:
      clone in interface PublicCloneable
      Overrides:
      clone in class AbstractDataset
      Returns:
      A clone.
      Throws:
      CloneNotSupportedException - This class will not throw this exception, but subclasses (if any) might.