public final class SimpleEventCategoryDataset<R extends java.lang.Comparable,C extends java.lang.Comparable> extends AbstractDataset implements ListEventListener<java.lang.Comparable>
EventLists 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 |
CategoryDataset is essentially a data model for a large matrix where
each unique row and unique column is identified by a Comparable key.
CategoryDataset requires its implementer to do three distinct things:
SimpleEventCategoryDataset.Context with information
about which row key and column key to use when producing a data value for
that position in the matrix. The logic of exactly how to produce that data
value is left to the particular implementation of the function.
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>)| Modifier and Type | Class and Description |
|---|---|
static class |
SimpleEventCategoryDataset.Context<R,C>
This object describes a cell within the "matrix" that is defined by
CategoryDataset. |
| Modifier and Type | Field and Description |
|---|---|
protected EventList<C> |
columnKeys
An ordered list of keys identifying the chart's columns.
|
protected EventList<R> |
rowKeys
An ordered list of keys identifying the chart's rows.
|
| Constructor and Description |
|---|
SimpleEventCategoryDataset(EventList<R> rowKeys,
EventList<C> columnKeys,
FunctionList.Function<SimpleEventCategoryDataset.Context<R,C>,java.lang.Number> valueMaker)
The given
rowKeys and columnKeys represent the
ordered lists of row and column keys presented by this
CategoryDataset. |
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Releases the resources consumed by this
SimpleEventCategoryDataset
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 |
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.
|
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<java.lang.Comparable> listChanges)
Watch the row key and column key lists for changes and rebroadcast those
ListEvents as DatasetChangeEvents.
|
protected EventList<R extends java.lang.Comparable> rowKeys
public SimpleEventCategoryDataset(EventList<R> rowKeys, EventList<C> columnKeys, FunctionList.Function<SimpleEventCategoryDataset.Context<R,C>,java.lang.Number> valueMaker)
rowKeys and columnKeys represent the
ordered lists of row and column keys presented by this
CategoryDataset. Any modifications to either of those
EventLists trigger this dataset to broadcast a change.
The given valueMaker is used to produce a Number
value for a given pair: {row key, column key}. This effectively creates
the data which is charted.
rowKeys - the keys identifying the unique rowscolumnKeys - the keys identifying the unique columnsvalueMaker - the function which maps {row key, column key} -> Numberpublic java.lang.Comparable getRowKey(int row)
row - the row index (zero-based)java.lang.IndexOutOfBoundsException - if row is out of boundspublic int getRowIndex(java.lang.Comparable key)
key - the row key-1 if the key is unrecognizedpublic java.util.List getRowKeys()
public int getRowCount()
public java.lang.Comparable getColumnKey(int column)
column - the column index (zero-based)java.lang.IndexOutOfBoundsException - if column is out of boundspublic int getColumnIndex(java.lang.Comparable key)
key - the column key-1 if the key is unrecognizedpublic java.util.List getColumnKeys()
public int getColumnCount()
public java.lang.Number getValue(java.lang.Comparable rowKey,
java.lang.Comparable columnKey)
rowKey - the row key (null not permitted)columnKey - the column key (null not permitted)org.jfree.data.UnknownKeyException - if either key is not recognizedpublic java.lang.Number getValue(int row,
int column)
row - the row index (zero-based)column - the column index (zero-based)null)java.lang.IndexOutOfBoundsException - if the row
or column is out of boundsprotected void fireDatasetChanged()
public void listChanged(ListEvent<java.lang.Comparable> listChanges)
listChanged in interface ListEventListener<java.lang.Comparable>listChanges - a ListEvent describing the changes to the listpublic void dispose()
SimpleEventCategoryDataset
so that it may eventually be garbage collected.
A SimpleEventCategoryDataset will be garbage collected without
a call to dispose(), but not before its row key and column key
EventLists are garbage collected. By calling dispose(),
you allow the SimpleEventCategoryDataset to be garbage collected
before its source EventLists. This is necessary for situations
where a SimpleEventCategoryDataset is short-lived but its source
EventLists are long-lived.
Warning: It is an error
to call any method on an SimpleEventCategoryDataset after it has
been disposed.
Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by mockbuild at 2017-07-26 15:03