public abstract class EventListCategoryDataset<R extends java.lang.Comparable,C extends java.lang.Comparable> extends AbstractDataset implements CategoryDataset, ListEventListener<ValueSegment<C,R>>
EventList to the CategoryDataset
interface which is the necessary model for JFreeChart views such as
| 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 |
If it is possible to create a pipeline of list transformations such that
your source is an EventList of ValueSegment objects then
this class can aid you in showing and maintaining that data within a
JFreeChart. It handles the maintenance of efficient data structures for
implementing getValue(int, int) and leaves subclasses the task
of defining the logic for maintaining the lists of rowkeys and columnkeys.
If the rowkeys and columnkeys are statically determined, they can be set like so:
EventList myValueSegments = ... CategoryDataset dataset = new EventListCategoryDataset(myValueSegments); dataset.getColumnKeys().add(...); dataset.getRowKeys().add(...);If the rowkeys and/or columnkeys are dynamically maintained as
ValueSegments are added and removed from the EventList, then
two hooks have been given for the benefit of subclasses:
postInsert(ca.odell.glazedlists.jfreechart.ValueSegment<C, R>) is a hook to process the insertion of new source.
This is commonly where rows or columns may be created by adding their
keys to the rowKey or columnKey lists.
postDelete(ca.odell.glazedlists.jfreechart.ValueSegment<C, R>) is a hook to process the deletion of existing
source. This is commonly where rows or columns may be removed by
removing their keys from the rowKey or columnKey lists.
Note: If this
EventListCategoryDataset is being shown in a Swing User Interface,
and thus Dataset Changes should be broadcast on the Swing Event Dispatch
Thread, it is the responsibility of the caller to ensure
that ListEvents arrive on the Swing EDT.
GlazedListsSwing.swingThreadProxyList(ca.odell.glazedlists.EventList<E>),
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<? extends java.lang.Comparable> |
columnKeys
An ordered list of keys identifying the chart's columns.
|
protected java.util.List<? extends java.lang.Comparable> |
rowKeys
An ordered list of keys identifying the chart's rows.
|
| Constructor and Description |
|---|
EventListCategoryDataset(EventList<ValueSegment<C,R>> source)
Constructs an implementation of
CategoryDataset which presents
the data contained in the given source. |
| Modifier and Type | Method and Description |
|---|---|
protected java.util.List<? extends java.lang.Comparable> |
createColumnKeyList()
A local factory method for creating the list containing the column keys.
|
protected java.util.List<? extends java.lang.Comparable> |
createRowKeyList()
A local factory method for creating the list containing the row keys.
|
void |
dispose()
Releases the resources consumed by this
EventListCategoryDataset
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 DatasetChangeEvent each time this method is called.
|
int |
getColumnCount()
Returns the number of columns in the table.
|
int |
getColumnIndex(java.lang.Comparable key)
Returns the column index for a given key.
|
java.lang.Comparable |
getColumnKey(int column)
Returns the column key for a given index.
|
java.util.List |
getColumnKeys()
Returns the column keys.
|
int |
getCount(R rowKey)
Returns the number of values associated with the given
rowKey. |
int |
getCount(R rowKey,
C start,
C end)
Returns the number of values associated with the given
rowKey
between the given start and end values. |
int |
getRowCount()
Returns the number of rows in the table.
|
int |
getRowIndex(java.lang.Comparable key)
Returns the row index for a given key.
|
java.lang.Comparable |
getRowKey(int row)
Returns the row key for a given index.
|
java.util.List |
getRowKeys()
Returns the row keys.
|
abstract java.lang.Number |
getValue(java.lang.Comparable rowKey,
java.lang.Comparable columnKey)
Returns the value associated with the specified keys.
|
java.lang.Number |
getValue(int row,
int column)
Returns a value from the table.
|
void |
listChanged(ListEvent<ValueSegment<C,R>> listChanges)
This listener maintains a fast set of TreePairs for each unique value
found in the ValueSegments of the source list.
|
protected void |
postDelete(ValueSegment<C,R> valueSegment)
This no-op method is left as a hook for subclasses.
|
protected void |
postInsert(ValueSegment<C,R> valueSegment)
This no-op method is left as a hook for subclasses.
|
addChangeListener, clone, getGroup, hasListener, notifyListeners, removeChangeListener, setGroup, validateObjectequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddChangeListener, getGroup, removeChangeListener, setGroupprotected java.util.List<? extends java.lang.Comparable> rowKeys
protected java.util.List<? extends java.lang.Comparable> columnKeys
public EventListCategoryDataset(EventList<ValueSegment<C,R>> source)
CategoryDataset which presents
the data contained in the given source.source - the EventList of data to be chartedprotected java.util.List<? extends java.lang.Comparable> createRowKeyList()
protected java.util.List<? extends java.lang.Comparable> createColumnKeyList()
public java.lang.Comparable getRowKey(int row)
getRowKey in interface KeyedValues2Drow - the row index (zero-based)java.lang.IndexOutOfBoundsException - if row is out of boundspublic int getRowIndex(java.lang.Comparable key)
getRowIndex in interface KeyedValues2Dkey - the row key-1 if the key is unrecognizedpublic java.util.List getRowKeys()
getRowKeys in interface KeyedValues2Dpublic int getRowCount()
getRowCount in interface Values2Dpublic java.lang.Comparable getColumnKey(int column)
getColumnKey in interface KeyedValues2Dcolumn - the column index (zero-based)java.lang.IndexOutOfBoundsException - if column is out of boundspublic int getColumnIndex(java.lang.Comparable key)
getColumnIndex in interface KeyedValues2Dkey - the column key-1 if the key is unrecognizedpublic java.util.List getColumnKeys()
getColumnKeys in interface KeyedValues2Dpublic int getColumnCount()
getColumnCount in interface Values2Dpublic java.lang.Number getValue(int row,
int column)
public abstract java.lang.Number getValue(java.lang.Comparable rowKey,
java.lang.Comparable columnKey)
getValue in interface KeyedValues2DrowKey - the row key (null not permitted)columnKey - the column key (null not permitted)UnknownKeyException - if either key is not recognizedpublic void dispose()
EventListCategoryDataset
so that it may eventually be garbage collected.
An EventListCategoryDataset will be garbage collected without
a call to dispose(), but not before its source EventList
is garbage collected. By calling dispose(), you allow the
EventListCategoryDataset to be garbage collected before its
source EventList. This is necessary for situations where a
EventListCategoryDataset is short-lived but its source
EventList is long-lived.
Warning: It is an error
to call any method on an EventListCategoryDataset after it has
been disposed.
public int getCount(R rowKey)
rowKey.public int getCount(R rowKey, C start, C end)
rowKey
between the given start and end values.protected void postInsert(ValueSegment<C,R> valueSegment)
valueSegment - the data element inserted into this data setprotected void postDelete(ValueSegment<C,R> valueSegment)
valueSegment - the data element removed from this data setprotected void fireDatasetChanged()
fireDatasetChanged in class AbstractDatasetpublic void listChanged(ListEvent<ValueSegment<C,R>> listChanges)
listChanged in interface ListEventListener<ValueSegment<C extends java.lang.Comparable,R extends java.lang.Comparable>>listChanges - a ListEvent describing the changes to the listGlazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by swimmesberger at Wed Feb 13 09:45:20 CET 2019