|
||||||||||
| 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.SimpleEventCategoryDataset<R,C>
public final class SimpleEventCategoryDataset<R extends Comparable,C extends Comparable>
This class helps adapt a pair of 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) ,
Serialized Form| Nested Class Summary | |
|---|---|
static class |
SimpleEventCategoryDataset.Context<R,C>
This object describes a cell within the "matrix" that is defined by CategoryDataset. |
| Field Summary | |
|---|---|
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 Summary | |
|---|---|
SimpleEventCategoryDataset(EventList<R> rowKeys,
EventList<C> columnKeys,
FunctionList.Function<SimpleEventCategoryDataset.Context<R,C>,Number> valueMaker)
The given rowKeys and columnKeys represent the
ordered lists of row and column keys presented by this
CategoryDataset. |
|
| Method Summary | |
|---|---|
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(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 |
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. |
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<Comparable> listChanges)
Watch the row key and column key lists for changes and rebroadcast those ListEvents as DatasetChangeEvents. |
| 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 EventList<R extends Comparable> rowKeys
protected EventList<C extends Comparable> columnKeys
| Constructor Detail |
|---|
public SimpleEventCategoryDataset(EventList<R> rowKeys,
EventList<C> columnKeys,
FunctionList.Function<SimpleEventCategoryDataset.Context<R,C>,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} -> Number| Method Detail |
|---|
public Comparable getRowKey(int row)
getRowKey in interface KeyedValues2Drow - the row index (zero-based)
IndexOutOfBoundsException - if row is out of boundspublic int getRowIndex(Comparable key)
getRowIndex in interface KeyedValues2Dkey - the row key
-1 if the key is unrecognizedpublic List getRowKeys()
getRowKeys in interface KeyedValues2Dpublic int getRowCount()
getRowCount in interface Values2Dpublic Comparable getColumnKey(int column)
getColumnKey in interface KeyedValues2Dcolumn - the column index (zero-based)
IndexOutOfBoundsException - if column is out of boundspublic int getColumnIndex(Comparable key)
getColumnIndex in interface KeyedValues2Dkey - the column key
-1 if the key is unrecognizedpublic List getColumnKeys()
getColumnKeys in interface KeyedValues2Dpublic int getColumnCount()
getColumnCount in interface Values2D
public Number getValue(Comparable rowKey,
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 recognized
public Number getValue(int row,
int column)
getValue in interface Values2Drow - the row index (zero-based)column - the column index (zero-based)
null)
IndexOutOfBoundsException - if the row
or column is out of boundsprotected void fireDatasetChanged()
fireDatasetChanged in class AbstractDatasetpublic void listChanged(ListEvent<Comparable> listChanges)
listChanged in interface ListEventListener<Comparable>public 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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||