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
A
PieDataset
implementation that obtains its data from one row or
column of a CategoryDataset
.- See Also:
-
Constructor Summary
ConstructorDescriptionCategoryToPieDataset
(CategoryDataset source, TableOrder extract, int index) An adaptor class that converts anyCategoryDataset
into aPieDataset
, by taking the values from a single row or column. -
Method Summary
Modifier and TypeMethodDescriptionvoid
datasetChanged
(DatasetChangeEvent event) Sends aDatasetChangeEvent
to all registered listeners, with this (not the underlying) dataset as the source.boolean
Tests this dataset for equality with an arbitrary object, returningtrue
ifobj
is a dataset containing the same keys and values in the same order as this dataset.int
Returns the index of the row or column from which to extract the data.Returns the extract type, which determines whether data is read from one row or one column of the underlying dataset.int
getIndex
(Comparable key) Returns the index for a given key, or-1
if there is no such key.int
Returns the number of items (values) in the collection.getKey
(int index) Returns the key at the specified index.getKeys()
Returns the keys for the dataset.Returns the underlying dataset.getValue
(int item) Returns a value from the dataset.getValue
(Comparable key) Returns the value for a given key.Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, clone, fireDatasetChanged, getGroup, getNotify, hasListener, notifyListeners, removeChangeListener, setGroup, 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, getGroup, removeChangeListener, setGroup
-
Constructor Details
-
CategoryToPieDataset
An adaptor class that converts anyCategoryDataset
into aPieDataset
, by taking the values from a single row or column.If
source
isnull
, the created dataset will be empty.- Parameters:
source
- the source dataset (null
permitted).extract
- extract data from rows or columns? (null
not permitted).index
- the row or column index.
-
-
Method Details
-
getUnderlyingDataset
Returns the underlying dataset.- Returns:
- The underlying dataset (possibly
null
).
-
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.
-
getExtractIndex
public int getExtractIndex()Returns the index of the row or column from which to extract the data.- Returns:
- The extract index.
-
getItemCount
public int getItemCount()Returns the number of items (values) in the collection. If the underlying dataset isnull
, this method returns zero.- Specified by:
getItemCount
in interfaceValues
- Returns:
- The item count.
-
getValue
Returns a value from the dataset.- Specified by:
getValue
in interfaceValues
- Parameters:
item
- the item index (zero-based).- Returns:
- The value (possibly
null
). - Throws:
IndexOutOfBoundsException
- ifitem
is not in the range0
togetItemCount() -1
.
-
getKey
Returns the key at the specified index.- Specified by:
getKey
in interfaceKeyedValues
- Parameters:
index
- the item index (in the range0
togetItemCount() -1
).- Returns:
- The key.
- Throws:
IndexOutOfBoundsException
- ifindex
is not in the specified range.
-
getIndex
Returns the index for a given key, or-1
if there is no such key.- Specified by:
getIndex
in interfaceKeyedValues
- Parameters:
key
- the key.- Returns:
- The index for the key, or
-1
.
-
getKeys
Returns the keys for the dataset.If the underlying dataset is
null
, this method returns an empty list.- Specified by:
getKeys
in interfaceKeyedValues
- Returns:
- The keys.
-
getValue
Returns the value for a given key. If the key is not recognised, the method should returnnull
(but note thatnull
can be associated with a valid key also).- Specified by:
getValue
in interfaceKeyedValues
- Parameters:
key
- the key.- Returns:
- The value (possibly
null
).
-
datasetChanged
Sends aDatasetChangeEvent
to all registered listeners, with this (not the underlying) dataset as the source.- Specified by:
datasetChanged
in interfaceDatasetChangeListener
- Parameters:
event
- the event (ignored, a new event with this dataset as the source is sent to the listeners).
-
equals
Tests this dataset for equality with an arbitrary object, returningtrue
ifobj
is a dataset containing the same keys and values in the same order as this dataset.
-