org.jfree.data
Class CategoryToPieDataset

java.lang.Object
  |
  +--org.jfree.data.AbstractDataset
        |
        +--org.jfree.data.CategoryToPieDataset
All Implemented Interfaces:
Dataset, KeyedValues, PieDataset, java.io.Serializable, Values

public class CategoryToPieDataset
extends AbstractDataset
implements PieDataset

A PieDataset implementation that obtains its data from one row or column of a CategoryDataset.

Author:
David Gilbert
See Also:
Serialized Form

Field Summary
static int COLUMN
          A constant indicating that data should be extracted from a column.
static int ROW
          A constant indicating that data should be extracted from a row.
 
Constructor Summary
CategoryToPieDataset(CategoryDataset source, int extract, int index)
          An adaptor class that converts any CategoryDataset into a PieDataset, by taking the values from a single row or column.
 
Method Summary
 int getIndex(java.lang.Comparable key)
          Returns the index for a given key.
 int getItemCount()
          Returns the number of items (values) in the collection.
 java.lang.Comparable getKey(int index)
          Returns a key.
 java.util.List getKeys()
          Returns the keys.
 java.lang.Number getValue(java.lang.Comparable key)
          Returns the value (possibly null) for a given key.
 java.lang.Number getValue(int item)
          Returns a value.
 
Methods inherited from class org.jfree.data.AbstractDataset
addChangeListener, fireDatasetChanged, getGroup, notifyListeners, removeChangeListener, setGroup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jfree.data.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
 

Field Detail

ROW

public static final int ROW
A constant indicating that data should be extracted from a row.

See Also:
Constant Field Values

COLUMN

public static final int COLUMN
A constant indicating that data should be extracted from a column.

See Also:
Constant Field Values
Constructor Detail

CategoryToPieDataset

public CategoryToPieDataset(CategoryDataset source,
                            int extract,
                            int index)
An adaptor class that converts any CategoryDataset into a PieDataset, by taking the values from a single row or column.

Parameters:
source - the source dataset.
extract - ROW or COLUMN.
index - the row or column index.
Method Detail

getItemCount

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

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

getValue

public java.lang.Number getValue(int item)
Returns a value.

Specified by:
getValue in interface Values
Parameters:
item - the item index (zero-based).
Returns:
the value.

getKey

public java.lang.Comparable getKey(int index)
Returns a key.

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

getIndex

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

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

getKeys

public java.util.List getKeys()
Returns the keys.

Specified by:
getKeys in interface KeyedValues
Returns:
the keys.

getValue

public java.lang.Number getValue(java.lang.Comparable key)
Returns the value (possibly null) for a given key.

If the key is not recognised, the method should return null.

Specified by:
getValue in interface KeyedValues
Parameters:
key - the key.
Returns:
the value.