public class EventListPieDataset<E,K>
extends AbstractDataset
EventList
to the JFreeChart PieDataset
interface. Changes to the backing EventList
are rebroadcast as
changes to this PieDataset.
Extension: JFreeChart | |
This Glazed Lists extension requires the third party library JFreeChart. | |
Tested Version: | 1.0.0 |
Home page: | http://www.jfree.org/jfreechart/ |
License: | LGPL |
Note: The DataEvents broadcasted by this class occur on the Thread the
ListEvents arrive on. If this PieDataset is attached to a swing component,
like a org.jfree.chart.ChartPanel
, it is the responsibility of the
client to ensure that the ListEvents are arriving on the Swing Event
Dispatch Thread, perhaps by using the
SwingThreadProxyEventList
.
SwingThreadProxyEventList
Constructor and Description |
---|
EventListPieDataset(EventList<E> source,
java.util.Comparator<E> groupingComparator,
FunctionList.Function<java.util.List<E>,java.lang.Comparable<K>> keyFunction,
FunctionList.Function<java.util.List<E>,java.lang.Number> valueFunction)
Adapts the given
source to the PieDataset interface by
applying the groupingComparator to forms groups to be
represented in the pie chart. |
EventListPieDataset(EventList<E> source,
FunctionList.Function<E,java.lang.Comparable<K>> keyFunction,
FunctionList.Function<E,java.lang.Number> valueFunction)
Adapts the given
source to the PieDataset interface. |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Releases the resources consumed by this EventListPieDataset so that it
may eventually be garbage collected.
|
protected void |
fireDatasetChanged()
We override this method for speed reasons, since the super needlessly
constructs a new DatasetChangedEvent each time this method is called.
|
int |
getIndex(java.lang.Comparable key)
Returns the index for a given key.
|
int |
getItemCount()
Returns the number of items (values).
|
java.lang.Comparable |
getKey(int index)
Returns the key of the value at the given
index . |
java.util.List |
getKeys()
Returns the keys for the values in this PieDataset.
|
java.lang.Number |
getValue(java.lang.Comparable key)
Returns the value for a given key.
|
java.lang.Number |
getValue(int index)
Returns the value at the given
index . |
public EventListPieDataset(EventList<E> source, FunctionList.Function<E,java.lang.Comparable<K>> keyFunction, FunctionList.Function<E,java.lang.Number> valueFunction)
source
to the PieDataset interface. The
given keyFunction
is then applied to each element of the
source
to produce the unique key for the element and the
given valueFunction
is applied to produce the value for an
element.
This constructor should be used when the elements in
source
do not need to be grouped together in order to
represent pie data.
source
- the EventList
containing the data to chartkeyFunction
- produces the keys of the source elements in the pie chartvalueFunction
- produces the values of the source elements in the pie chartpublic EventListPieDataset(EventList<E> source, java.util.Comparator<E> groupingComparator, FunctionList.Function<java.util.List<E>,java.lang.Comparable<K>> keyFunction, FunctionList.Function<java.util.List<E>,java.lang.Number> valueFunction)
source
to the PieDataset interface by
applying the groupingComparator
to forms groups to be
represented in the pie chart. The given keyFunction
is then
applied to produce the key for a group and the given
valueFunction
is applied to produce the value for a group.source
- the EventList
containing the data to chartgroupingComparator
- produces the groups in the pie chartkeyFunction
- produces the keys of the groups in the pie chartvalueFunction
- produces the values of the groups in the pie chartpublic java.lang.Comparable getKey(int index)
index
.index
- the item index (zero-based)java.lang.IndexOutOfBoundsException
- if index
is out of boundspublic int getIndex(java.lang.Comparable key)
key
- the key-1
if the key is unrecognisedpublic java.util.List getKeys()
null
).public java.lang.Number getValue(java.lang.Comparable key)
key
- the keynull
)org.jfree.data.UnknownKeyException
- if the key is not recognisedpublic int getItemCount()
public java.lang.Number getValue(int index)
index
.index
- the index of interest (zero-based index).public void dispose()
EventList
that backs this EventListPieDataset should outlast
this EventListPieDataset. This method should be called as soon as this
EventListPieDataset is no longer useful.
Warning: It is an error to call any method on an EventListPieDataset after it has been disposed.
protected void fireDatasetChanged()
Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by builder at 2016-02-12 23:17