com.orsoncharts.data

## Class StandardPieDataset3D

- java.lang.Object
- - com.orsoncharts.data.AbstractDataset3D
  - - com.orsoncharts.data.StandardPieDataset3D

- All Implemented Interfaces:
    Dataset3D, KeyedValues<java.lang.Number>, PieDataset3D, Values<java.lang.Number>, java.io.Serializable

      public final class StandardPieDataset3D
      extends AbstractDataset3D
      implements PieDataset3D, java.io.Serializable

  A dataset that can be used with a `PiePlot3D`. This class represents an ordered list of (key, value) items. The keys can be any instance of `Comparable` (`String` is commonly used) and the values can be any `Number` instance (bearing in mind that the downstream code will use the `toDouble()` method to read values) or `null`.
  This class provides an implementation of `KeyedValues&lt;Number&gt;`, so the following useful utility methods can be used:
  `DataUtils.total(com.orsoncharts.data.Values)` `JSONUtils.writeKeyedValues(com.orsoncharts.data.KeyedValues)`
  NOTE: This class is serializable, but the serialization format is subject to change in future releases and should not be relied upon for persisting instances of this class.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StandardPieDataset3D()` Creates a new (empty) dataset.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(java.lang.Comparable<?> key, double value)` Adds a value to the dataset (if there is already a value with the given key, the value is overwritten) and sends a `Dataset3DChangeEvent` to all registered listeners.
    `void` | `add(java.lang.Comparable<?> key, java.lang.Number value)` Adds a value to the dataset (if there is already a value with the given key, the value is overwritten) and sends a `Dataset3DChangeEvent` to all registered listeners.
    `boolean` | `equals(java.lang.Object obj)` Tests this dataset for equality with an arbitrary object.
    `double` | `getDoubleValue(int item)` Returns the value for the specified item as a double primitive.
    `int` | `getIndex(java.lang.Comparable<?> key)` Returns the index for the specified key, or `-1` if the key is not present in the list.
    `int` | `getItemCount()` Returns the number of items in the dataset.
    `java.lang.Comparable<?>` | `getKey(int item)` Returns the key for the specified item in the list.
    `java.util.List<java.lang.Comparable<?>>` | `getKeys()` Returns a list of all the keys in the dataset.
    `java.lang.Number` | `getValue(java.lang.Comparable<?> key)` Returns the value associated with the specified key, or `null`.
    `java.lang.Number` | `getValue(int item)` Returns the value for the specified item.
    `java.lang.String` | `toString()` Returns a string representation of this instance, primarily for debugging purposes.

    - ### Methods inherited from class com.orsoncharts.data.AbstractDataset3D

      `addChangeListener, fireChangeEvent, fireDatasetChanged, hasListener, isNotify, notifyListeners, removeChangeListener, setNotify`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface com.orsoncharts.data.Dataset3D

      `addChangeListener, hasListener, removeChangeListener`

- - ### Constructor Detail

    - #### StandardPieDataset3D

          public StandardPieDataset3D()

      Creates a new (empty) dataset.

  - ### Method Detail

    - #### getItemCount

          public int getItemCount()

      Returns the number of items in the dataset.
      Specified by:
        `getItemCount` in interface `Values<java.lang.Number>`
      Returns:
        The number of items in the dataset.

    - #### getKey

          public java.lang.Comparable<?> getKey(int item)

      Returns the key for the specified item in the list.
      Specified by:
        `getKey` in interface `KeyedValues<java.lang.Number>`
      Parameters:
        `item` - the item index.
      Returns:
        The key.

    - #### getIndex

          public int getIndex(java.lang.Comparable<?> key)

      Returns the index for the specified key, or `-1` if the key is not present in the list.
      Specified by:
        `getIndex` in interface `KeyedValues<java.lang.Number>`
      Parameters:
        `key` - the key (`null` not permitted).
      Returns:
        The item index, or `-1`.

    - #### getValue

          public java.lang.Number getValue(int item)

      Returns the value for the specified item.
      Specified by:
        `getValue` in interface `Values<java.lang.Number>`
      Parameters:
        `item` - the item index.
      Returns:
        The value for the specified item (possibly `null`).

    - #### getValue

          public java.lang.Number getValue(java.lang.Comparable<?> key)

      Returns the value associated with the specified key, or `null`.
      Specified by:
        `getValue` in interface `KeyedValues<java.lang.Number>`
      Parameters:
        `key` - the key (`null` not permitted).
      Returns:
        The value (possibly `null`).

    - #### add

          public void add(java.lang.Comparable<?> key,
                          double value)

      Adds a value to the dataset (if there is already a value with the given key, the value is overwritten) and sends a `Dataset3DChangeEvent` to all registered listeners.
      Parameters:
        `key` - the key (`null` not permitted).
        `value` - the value.

    - #### add

          public void add(java.lang.Comparable<?> key,
                          java.lang.Number value)

      Adds a value to the dataset (if there is already a value with the given key, the value is overwritten) and sends a `Dataset3DChangeEvent` to all registered listeners.
      Parameters:
        `key` - the key (`null` not permitted).
        `value` - the value (`null` permitted).

    - #### getKeys

          public java.util.List<java.lang.Comparable<?>> getKeys()

      Returns a list of all the keys in the dataset. Note that the list will be a copy, so modifying it will not impact this dataset.
      Specified by:
        `getKeys` in interface `KeyedValues<java.lang.Number>`
      Returns:
        A list of keys (possibly empty, but never `null`).

    - #### getDoubleValue

          public double getDoubleValue(int item)

      Returns the value for the specified item as a double primitive. Where the `getValue(int)` method returns `null`, this method returns `Double.NaN`.
      Specified by:
        `getDoubleValue` in interface `Values<java.lang.Number>`
      Parameters:
        `item` - the item index.
      Returns:
        The value for the specified item.

    - #### equals

          public boolean equals(java.lang.Object obj)

      Tests this dataset for equality with an arbitrary object.
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `obj` - the object (`null` not permitted).
      Returns:
        A boolean.

    - #### toString

          public java.lang.String toString()

      Returns a string representation of this instance, primarily for debugging purposes.
      Implementation note: the current implementation (which is subject to change) writes the dataset in JSON format using `JSONUtils.writeKeyedValues(com.orsoncharts.data.KeyedValues)`.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        A string.