Header
And More


org.jfree.data.category
Class CategoryToPieDataset

java.lang.Object
  extended by org.jfree.data.general.AbstractDataset
      extended by org.jfree.data.category.CategoryToPieDataset
All Implemented Interfaces:
java.io.ObjectInputValidation, java.io.Serializable, java.lang.Cloneable, java.util.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:
Serialized Form

Constructor Summary
CategoryToPieDataset(CategoryDataset source, org.jfree.util.TableOrder 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
 void datasetChanged(DatasetChangeEvent event)
          Sends a DatasetChangeEvent to all registered listeners, with this (not the underlying) dataset as the source.
 boolean equals(java.lang.Object obj)
          Tests this dataset for equality with an arbitrary object, returning true if obj is a dataset containing the same keys and values in the same order as this dataset.
 int getExtractIndex()
          Returns the index of the row or column from which to extract the data.
 org.jfree.util.TableOrder getExtractType()
          Returns the extract type, which determines whether data is read from one row or one column of the underlying dataset.
 int getIndex(java.lang.Comparable key)
          Returns the index for a given key, or -1 if there is no such key.
 int getItemCount()
          Returns the number of items (values) in the collection.
 java.lang.Comparable getKey(int index)
          Returns the key at the specified index.
 java.util.List getKeys()
          Returns the keys for the dataset.
 CategoryDataset getUnderlyingDataset()
          Returns the underlying dataset.
 java.lang.Number getValue(java.lang.Comparable key)
          Returns the value for a given key.
 java.lang.Number getValue(int item)
          Returns a value from the dataset.
 
Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, clone, fireDatasetChanged, getGroup, hasListener, notifyListeners, removeChangeListener, setGroup, 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 Detail

CategoryToPieDataset

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

If source is null, 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 Detail

getUnderlyingDataset

public CategoryDataset getUnderlyingDataset()
Returns the underlying dataset.

Returns:
The underlying dataset (possibly null).
Since:
1.0.2

getExtractType

public org.jfree.util.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 is null, this method returns zero.

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

getValue

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

Specified by:
getValue in interface Values
Parameters:
item - the item index (zero-based).
Returns:
The value (possibly null).
Throws:
java.lang.IndexOutOfBoundsException - if item is not in the range 0 to getItemCount() - 1.

getKey

public java.lang.Comparable getKey(int index)
Returns the key at the specified index.

Specified by:
getKey in interface KeyedValues
Parameters:
index - the item index (in the range 0 to getItemCount() - 1).
Returns:
The key.
Throws:
java.lang.IndexOutOfBoundsException - if index is not in the specified range.

getIndex

public int getIndex(java.lang.Comparable key)
Returns the index for a given key, or -1 if there is no such key.

Specified by:
getIndex in interface KeyedValues
Parameters:
key - the key.
Returns:
The index for the key, or -1.

getKeys

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

If the underlying dataset is null, this method returns an empty list.

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

getValue

public java.lang.Number getValue(java.lang.Comparable key)
Returns the value for a given key. If the key is not recognised, the method should return null (but note that null can be associated with a valid key also).

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

datasetChanged

public void datasetChanged(DatasetChangeEvent event)
Sends a DatasetChangeEvent to all registered listeners, with this (not the underlying) dataset as the source.

Specified by:
datasetChanged in interface DatasetChangeListener
Parameters:
event - the event (ignored, a new event with this dataset as the source is sent to the listeners).

equals

public boolean equals(java.lang.Object obj)
Tests this dataset for equality with an arbitrary object, returning true if obj is a dataset containing the same keys and values in the same order as this dataset.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to test (null permitted).
Returns:
A boolean.

Footer
And More


Copyright © 2000-2009 by Object Refinery Limited. All Rights Reserved.