- java.lang.Object
-
- org.jfree.data.general.AbstractDataset
-
- org.jfree.data.category.CategoryToPieDataset
-
- All Implemented Interfaces:
ObjectInputValidation,Serializable,Cloneable,EventListener,Dataset,DatasetChangeListener,PieDataset,KeyedValues,Values
public class CategoryToPieDataset extends AbstractDataset implements PieDataset, DatasetChangeListener
APieDatasetimplementation that obtains its data from one row or column of aCategoryDataset.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CategoryToPieDataset(CategoryDataset source, TableOrder extract, int index)An adaptor class that converts anyCategoryDatasetinto aPieDataset, by taking the values from a single row or column.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddatasetChanged(DatasetChangeEvent event)Sends aDatasetChangeEventto all registered listeners, with this (not the underlying) dataset as the source.booleanequals(Object obj)Tests this dataset for equality with an arbitrary object, returningtrueifobjis a dataset containing the same keys and values in the same order as this dataset.intgetExtractIndex()Returns the index of the row or column from which to extract the data.TableOrdergetExtractType()Returns the extract type, which determines whether data is read from one row or one column of the underlying dataset.intgetIndex(Comparable key)Returns the index for a given key, or-1if there is no such key.intgetItemCount()Returns the number of items (values) in the collection.ComparablegetKey(int index)Returns the key at the specified index.ListgetKeys()Returns the keys for the dataset.CategoryDatasetgetUnderlyingDataset()Returns the underlying dataset.NumbergetValue(int item)Returns a value from the dataset.NumbergetValue(Comparable key)Returns the value for a given key.-
Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, clone, fireDatasetChanged, getNotify, hasListener, notifyListeners, removeChangeListener, setNotify, validateObject
-
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jfree.data.general.Dataset
addChangeListener, removeChangeListener
-
-
-
-
Constructor Detail
-
CategoryToPieDataset
public CategoryToPieDataset(CategoryDataset source, TableOrder extract, int index)
An adaptor class that converts anyCategoryDatasetinto aPieDataset, by taking the values from a single row or column.If
sourceisnull, the created dataset will be empty.- Parameters:
source- the source dataset (nullpermitted).extract- extract data from rows or columns? (nullnot permitted).index- the row or column index.
-
-
Method Detail
-
getUnderlyingDataset
public CategoryDataset getUnderlyingDataset()
Returns the underlying dataset.- Returns:
- The underlying dataset (possibly
null). - Since:
- 1.0.2
-
getExtractType
public TableOrder getExtractType()
Returns the extract type, which determines whether data is read from one row or one column of the underlying dataset.- Returns:
- The extract type.
- Since:
- 1.0.2
-
getExtractIndex
public int getExtractIndex()
Returns the index of the row or column from which to extract the data.- Returns:
- The extract index.
- Since:
- 1.0.2
-
getItemCount
public int getItemCount()
Returns the number of items (values) in the collection. If the underlying dataset isnull, this method returns zero.- Specified by:
getItemCountin interfaceValues- Returns:
- The item count.
-
getValue
public Number getValue(int item)
Returns a value from the dataset.- Specified by:
getValuein interfaceValues- Parameters:
item- the item index (zero-based).- Returns:
- The value (possibly
null). - Throws:
IndexOutOfBoundsException- ifitemis not in the range0togetItemCount() -1.
-
getKey
public Comparable getKey(int index)
Returns the key at the specified index.- Specified by:
getKeyin interfaceKeyedValues- Parameters:
index- the item index (in the range0togetItemCount() -1).- Returns:
- The key.
- Throws:
IndexOutOfBoundsException- ifindexis not in the specified range.
-
getIndex
public int getIndex(Comparable key)
Returns the index for a given key, or-1if there is no such key.- Specified by:
getIndexin interfaceKeyedValues- Parameters:
key- the key.- Returns:
- The index for the key, or
-1.
-
getKeys
public List getKeys()
Returns the keys for the dataset.If the underlying dataset is
null, this method returns an empty list.- Specified by:
getKeysin interfaceKeyedValues- Returns:
- The keys.
-
getValue
public Number getValue(Comparable key)
Returns the value for a given key. If the key is not recognised, the method should returnnull(but note thatnullcan be associated with a valid key also).- Specified by:
getValuein interfaceKeyedValues- Parameters:
key- the key.- Returns:
- The value (possibly
null).
-
datasetChanged
public void datasetChanged(DatasetChangeEvent event)
Sends aDatasetChangeEventto all registered listeners, with this (not the underlying) dataset as the source.- Specified by:
datasetChangedin interfaceDatasetChangeListener- Parameters:
event- the event (ignored, a new event with this dataset as the source is sent to the listeners).
-
-