org.jfree.data
Class DefaultPieDataset

java.lang.Object
  |
  +--org.jfree.data.AbstractDataset
        |
        +--org.jfree.data.DefaultPieDataset
All Implemented Interfaces:
Dataset, KeyedValues, PieDataset, java.io.Serializable, Values
Direct Known Subclasses:
DefaultKeyedValuesDataset, JDBCPieDataset

public class DefaultPieDataset
extends AbstractDataset
implements PieDataset, java.io.Serializable

A default implementation of the PieDataset interface.

Author:
David Gilbert
See Also:
Serialized Form

Constructor Summary
DefaultPieDataset()
          Constructs a new dataset, initially empty.
DefaultPieDataset(KeyedValues data)
          Creates a new dataset that uses the data from a KeyedValues instance.
 
Method Summary
 boolean equals(java.lang.Object o)
          Tests if this object is equal to another.
 int getIndex(java.lang.Comparable key)
          Returns the index for a key.
 int getItemCount()
          Returns the number of items in the dataset.
 java.lang.Comparable getKey(int item)
          Returns the key for an item.
 java.util.List getKeys()
          Returns the categories in the dataset.
 java.lang.Number getValue(java.lang.Comparable key)
          Returns the data value associated with a key.
 java.lang.Number getValue(int item)
          Returns a value.
 void setValue(java.lang.Comparable key, double value)
          Sets the data value for a key.
 void setValue(java.lang.Comparable key, java.lang.Number value)
          Sets the data value for a key.
 
Methods inherited from class org.jfree.data.AbstractDataset
addChangeListener, fireDatasetChanged, getGroup, notifyListeners, removeChangeListener, setGroup
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jfree.data.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
 

Constructor Detail

DefaultPieDataset

public DefaultPieDataset()
Constructs a new dataset, initially empty.


DefaultPieDataset

public DefaultPieDataset(KeyedValues data)
Creates a new dataset that uses the data from a KeyedValues instance.

Parameters:
data - the data.
Method Detail

getItemCount

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

Specified by:
getItemCount in interface Values
Returns:
the item count.

getKeys

public java.util.List getKeys()
Returns the categories in the dataset.

Specified by:
getKeys in interface KeyedValues
Returns:
the categories in the dataset.

getKey

public java.lang.Comparable getKey(int item)
Returns the key for an item.

Specified by:
getKey in interface KeyedValues
Parameters:
item - the item index (zero-based).
Returns:
the category.

getIndex

public int getIndex(java.lang.Comparable key)
Returns the index for a key.

Specified by:
getIndex in interface KeyedValues
Parameters:
key - the key.
Returns:
the key index.

getValue

public java.lang.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 java.lang.Number getValue(java.lang.Comparable key)
Returns the data value associated with a key.

Specified by:
getValue in interface KeyedValues
Parameters:
key - the key.
Returns:
The value (possibly null).

setValue

public void setValue(java.lang.Comparable key,
                     java.lang.Number value)
Sets the data value for a key.

Parameters:
key - the key.
value - the value.

setValue

public void setValue(java.lang.Comparable key,
                     double value)
Sets the data value for a key.

Parameters:
key - the key.
value - the value.

equals

public boolean equals(java.lang.Object o)
Tests if this object is equal to another.

Overrides:
equals in class java.lang.Object
Parameters:
o - the other object.
Returns:
A boolean.