Module org.jfree.chart3d
Package org.jfree.chart3d.data

# Class StandardPieDataset3D<K extends Comparable<K>>

java.lang.Object
org.jfree.chart3d.data.AbstractDataset3D
org.jfree.chart3d.data.StandardPieDataset3D<K>

Type Parameters:
  `K` - the key type.

All Implemented Interfaces:
  `Serializable`, `Dataset3D`, `KeyedValues<K,Number>`, `PieDataset3D<K>`, `Values<Number>`

public final class StandardPieDataset3D<K extends Comparable<K>> extends AbstractDataset3D implements PieDataset3D<K>, 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(org.jfree.chart3d.data.Values)` `JSONUtils.writeKeyedValues(org.jfree.chart3d.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
Description
`StandardPieDataset3D()`
Creates a new (empty) dataset.

## Method Summary

Modifier and Type
Method
Description
`void`
`add(K 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(K key, 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(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(K 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.
`K`
`getKey(int item)`
Returns the key for the specified item in the list.
`List<K>`
`getKeys()`
Returns a list of all the keys in the dataset.
`Number`
`getValue(int item)`
Returns the value for the specified item.
`Number`
`getValue(K key)`
Returns the value associated with the specified key, or `null`.
`String`
`toString()`
Returns a string representation of this instance, primarily for debugging purposes.

### Methods inherited from class org.jfree.chart3d.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 org.jfree.chart3d.data.Dataset3D

`addChangeListener, hasListener, removeChangeListener`

## Constructor Details

### StandardPieDataset3D

public StandardPieDataset3D()
Creates a new (empty) dataset.

## Method Details

### getItemCount

public int getItemCount()
Returns the number of items in the dataset.

Specified by:
  `getItemCount` in interface `Values<K extends Comparable<K>>`
Returns:
  The number of items in the dataset.

### getKey

public K getKey(int item)
Returns the key for the specified item in the list.

Specified by:
  `getKey` in interface `KeyedValues<K extends Comparable<K>,Number>`
Parameters:
  `item` - the item index.
Returns:
  The key.

### getIndex

public int getIndex(K 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<K extends Comparable<K>,Number>`
Parameters:
  `key` - the key (`null` not permitted).
Returns:
  The item index, or `-1`.

### getValue

public Number getValue(int item)
Returns the value for the specified item.

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

### getValue

public Number getValue(K key)
Returns the value associated with the specified key, or `null`.

Specified by:
  `getValue` in interface `KeyedValues<K extends Comparable<K>,Number>`
Parameters:
  `key` - the key (`null` not permitted).
Returns:
  The value (possibly `null`).

### add

public void add(K 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(K key, 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 List<K> 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<K extends Comparable<K>,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<K extends Comparable<K>>`
Parameters:
  `item` - the item index.
Returns:
  The value for the specified item.

### equals

public boolean equals(Object obj)
Tests this dataset for equality with an arbitrary object.

Overrides:
  `equals` in class `Object`
Parameters:
  `obj` - the object (`null` not permitted).
Returns:
  A boolean.

### toString

public 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(org.jfree.chart3d.data.KeyedValues)`.

Overrides:
  `toString` in class `Object`
Returns:
  A string.