|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jfree.data.general.AbstractDataset
ca.odell.glazedlists.jfreechart.EventListCategoryDataset<R,C>
public abstract class EventListCategoryDataset<R extends Comparable,C extends Comparable>
This class helps adapt an 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
ValueSegment
s are added and removed from the EventList
, then
two hooks have been given for the benefit of subclasses:
postInsert(ca.odell.glazedlists.jfreechart.ValueSegment)
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)
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 ListEvent
s arrive on the Swing EDT.
GlazedListsSwing.swingThreadProxyList(ca.odell.glazedlists.EventList)
,
Serialized FormField Summary | |
---|---|
protected List<? extends Comparable> |
columnKeys
An ordered list of keys identifying the chart's columns. |
protected List<? extends Comparable> |
rowKeys
An ordered list of keys identifying the chart's rows. |
Constructor Summary | |
---|---|
EventListCategoryDataset(EventList<ValueSegment<C,R>> source)
Constructs an implementation of CategoryDataset which presents
the data contained in the given source . |
Method Summary | |
---|---|
protected List<? extends Comparable> |
createColumnKeyList()
A local factory method for creating the list containing the column keys. |
protected List<? extends 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(Comparable key)
Returns the column index for a given key. |
Comparable |
getColumnKey(int column)
Returns the column key for a given index. |
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(Comparable key)
Returns the row index for a given key. |
Comparable |
getRowKey(int row)
Returns the row key for a given index. |
List |
getRowKeys()
Returns the row keys. |
abstract Number |
getValue(Comparable rowKey,
Comparable columnKey)
Returns the value associated with the specified keys. |
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. |
Methods inherited from class org.jfree.data.general.AbstractDataset |
---|
addChangeListener, clone, getGroup, hasListener, notifyListeners, removeChangeListener, setGroup, validateObject |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.jfree.data.general.Dataset |
---|
addChangeListener, getGroup, removeChangeListener, setGroup |
Field Detail |
---|
protected List<? extends Comparable> rowKeys
protected List<? extends Comparable> columnKeys
Constructor Detail |
---|
public EventListCategoryDataset(EventList<ValueSegment<C,R>> source)
CategoryDataset
which presents
the data contained in the given source
.
source
- the EventList
of data to be chartedMethod Detail |
---|
protected List<? extends Comparable> createRowKeyList()
protected List<? extends Comparable> createColumnKeyList()
public Comparable getRowKey(int row)
getRowKey
in interface KeyedValues2D
row
- the row index (zero-based)
IndexOutOfBoundsException
- if row
is out of boundspublic int getRowIndex(Comparable key)
getRowIndex
in interface KeyedValues2D
key
- the row key
-1
if the key is unrecognizedpublic List getRowKeys()
getRowKeys
in interface KeyedValues2D
public int getRowCount()
getRowCount
in interface Values2D
public Comparable getColumnKey(int column)
getColumnKey
in interface KeyedValues2D
column
- the column index (zero-based)
IndexOutOfBoundsException
- if column
is out of boundspublic int getColumnIndex(Comparable key)
getColumnIndex
in interface KeyedValues2D
key
- the column key
-1
if the key is unrecognizedpublic List getColumnKeys()
getColumnKeys
in interface KeyedValues2D
public int getColumnCount()
getColumnCount
in interface Values2D
public Number getValue(int row, int column)
getValue
in interface Values2D
row
- the row index (zero-based)column
- the column index (zero-based)
null
)
IndexOutOfBoundsException
- if the row
or column
is out of boundspublic abstract Number getValue(Comparable rowKey, Comparable columnKey)
getValue
in interface KeyedValues2D
rowKey
- 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 AbstractDataset
public void listChanged(ListEvent<ValueSegment<C,R>> listChanges)
listChanged
in interface ListEventListener<ValueSegment<C extends Comparable,R extends Comparable>>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |