org.jfree.data.general

Class DefaultPieDataset

Implemented Interfaces:
Cloneable, Dataset, KeyedValues, ObjectInputValidation, PieDataset, PublicCloneable, Serializable, Values
Known Direct Subclasses:
DefaultKeyedValuesDataset, JDBCPieDataset

public class DefaultPieDataset
extends AbstractDataset
implements PieDataset, Cloneable, PublicCloneable, Serializable

A default implementation of the PieDataset interface.

Constructor Summary

DefaultPieDataset()
Constructs a new dataset, initially empty.
DefaultPieDataset(KeyedValues data)
Creates a new dataset by copying data from a KeyedValues instance.

Method Summary

void
clear()
Clears all data from this dataset and sends a DatasetChangeEvent to all registered listeners (unless the dataset was already empty).
Object
clone()
Returns a clone of the dataset.
boolean
equals(Object obj)
Tests if this object is equal to another.
int
getIndex(Comparable key)
Returns the index for a key, or -1 if the key is not recognised.
int
getItemCount()
Returns the number of items in the dataset.
Comparable
getKey(int item)
Returns the key for the specified item, or null.
List
getKeys()
Returns the categories in the dataset.
Number
getValue(Comparable key)
Returns the data value associated with a key.
Number
getValue(int item)
Returns a value.
int
hashCode()
Returns a hash code.
void
remove(Comparable key)
Removes an item from the dataset and sends a DatasetChangeEvent to all registered listeners.
void
setValue(Comparable key, Number value)
Sets the data value for a key and sends a DatasetChangeEvent to all registered listeners.
void
setValue(Comparable key, double value)
Sets the data value for a key and sends a DatasetChangeEvent to all registered listeners.
void
sortByKeys(SortOrder order)
Sorts the dataset's items by key and sends a DatasetChangeEvent to all registered listeners.
void
sortByValues(SortOrder order)
Sorts the dataset's items by value and sends a DatasetChangeEvent to all registered listeners.

Methods inherited from class org.jfree.data.general.AbstractDataset

addChangeListener, clone, fireDatasetChanged, getGroup, hasListener, notifyListeners, removeChangeListener, setGroup, validateObject

Constructor Details

DefaultPieDataset

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

DefaultPieDataset

public DefaultPieDataset(KeyedValues data)
Creates a new dataset by copying data from a KeyedValues instance.
Parameters:
data - the data (null not permitted).

Method Details

clear

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

clone

public Object clone()
            throws CloneNotSupportedException
Returns a clone of the dataset.
Overrides:
clone in interface AbstractDataset
Returns:
A clone.

equals

public boolean equals(Object obj)
Tests if this object is equal to another.
Parameters:
obj - the other object.
Returns:
A boolean.

getIndex

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

getItemCount

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

getKey

public Comparable getKey(int item)
Returns the key for the specified item, or null.
Specified by:
getKey in interface KeyedValues
Parameters:
item - the item index (in the range 0 to getItemCount() - 1).
Returns:
The key, or null.

getKeys

public List getKeys()
Returns the categories in the dataset. The returned list is unmodifiable.
Specified by:
getKeys in interface KeyedValues
Returns:
The categories in the dataset.

getValue

public Number getValue(Comparable key)
Returns the data value associated with a key.
Specified by:
getValue in interface KeyedValues
Parameters:
key - the key (null not permitted).
Returns:
The value (possibly 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).

hashCode

public int hashCode()
Returns a hash code.
Returns:
A hash code.

remove

public void remove(Comparable key)
Removes an item from the dataset and sends a DatasetChangeEvent to all registered listeners.
Parameters:
key - the key (null not permitted).

setValue

public void setValue(Comparable 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.

setValue

public void setValue(Comparable 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.

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).
Since:
1.0.3

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).
Since:
1.0.3