|
Copyright © 2005 Scientific Applications. All Rights Reserved. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sciapp.treetable.AbstractTreeTableModel
com.sciapp.treetable.TreeModelMap
com.sciapp.treetable.DynamicTreeTableModel
public class DynamicTreeTableModel
DynamicTreeTableModel wraps around a ListTableModel instance in order to provide a tree-like view of the table's data.
Rows are grouped together if they are found to be equal by the row comparators that are defined.
Row comparators can be added/removed via the addRowComparator and
removeRowComparator methods respectively.
In the simplest of cases, a DefaultTreeTableComparator may be used, which compares rows by using
a single column. However, more complex schemes can be employed, such as comparing using
more than one columns.
A DynamicTreeTableModel builds a tree structure every time the data is changed. This tree comprises of nodes represented by TreeTableRow objects that are divided in:
Footer is
defined in the DynamicTreeTableModel.
The values returned by aggregate rows are defined by Aggregator objects (see Aggregator).
| Field Summary | |
|---|---|
protected ArrayList |
comparators
the list of row comparators. |
protected Aggregator |
defaultAggregator
the default aggregator |
protected Hashtable |
defaultComparatorsByColumnClass
A table of objects that compare two object with each other, indexed by class |
protected Footer |
footer
the footer object |
protected ListTableModel |
tableModel
|
| Fields inherited from class com.sciapp.treetable.TreeModelMap |
|---|
treeModel |
| Fields inherited from class com.sciapp.treetable.AbstractTreeTableModel |
|---|
listenerList, root |
| Fields inherited from interface com.sciapp.treetable.TreeTableModel |
|---|
CHANGE_COLUMN_SOURCE |
| Constructor Summary | |
|---|---|
DynamicTreeTableModel(ListTableModel tableModel)
DynamicTreeTableModel constructor comment. |
|
| Method Summary | |
|---|---|
void |
addReorderListener(ReorderListener l)
Adds a ReorderListener that is notified each time a change to the data model occurs so that the table updates the selected rows accordingly. |
void |
addRow(Object row)
Adds a row to the end of the model. |
void |
addRowComparator(TreeTableComparator newComparator)
Adds a new row comparator at the end of the list of comparators. |
void |
addRows(List addedRows)
Adds a list of rows to the end of the model. |
protected void |
buildFooter()
Creates and adds FooterRows to the tree. |
protected void |
buildTree()
Creates the tree based on the data supplied by the underlying ListTableModel. |
void |
clear()
Clears the model of any data. |
void |
clearComparators()
Removes all row comparators and rebuilds the tree. |
protected Aggregator |
createDefaultAggregator()
Creates and returns the aggregator that will be used by default. |
protected void |
createDefaultComparators()
Creates default comparators for objects, strings, date and boolean values. |
protected Footer |
createDefaultFooter()
Creates and returns the default footer. |
void |
fireRowsMapped(int[] changedIndices)
Notifies listeners that the rows of the table have been reordered according to the changedIndices map. |
void |
fireRowsReordered(ReorderEvent event)
Notifies listeners that the rows of the table have been reordered in some way. |
Aggregator |
getAggregator(int columnIndex)
Returns the aggregator for columnIndex. |
Object |
getCellValue(Object row,
int index)
Returns the Object found at index of row passed as a parameter. |
Class |
getColumnClass(int c)
Returns the class of all the cells in the column. |
int |
getColumnCount()
Returns the number of columns. |
String |
getColumnName(int columnIndex)
Returns the name of the column at columnIndex as it will be displayed by the table |
int |
getDataRow(TreeTableRow node)
Returns the index that corresponds to the object of the ListTableModel that holds the actual tabular data, for the node node. |
int[] |
getDataRows(TreeTableRow node)
Returns the indexes that correspond to the objects of the ListTableModel that holds the actual tabular data, that are children of the TreeTableRow for the node node. |
Aggregator |
getDefaultAggregator()
Returns the default aggregator that will be used to compute values for the aggregate rows of the model. |
Comparator |
getDefaultComparator(Class columnClass)
Returns the comparator to use for objects of the specified columnClass. |
Footer |
getFooter()
Returns the footer associated with this TreeTableModel instance. |
ListTableModel |
getModel()
Returns the underlying ListTableModel model |
int[] |
getModelIndexesUnderRow(TreeTableRow row,
boolean sorted)
Returns the indexes that correspond to the objects of the ListTableModel that holds the actual tabular data, that are children of the TreeTableRow row. |
TreeTableComparator |
getRowComparator(int index)
Returns the row comparator that will be used to determine row similarity at index. |
TreeTableComparator[] |
getRowComparators()
Returns the list of row comparators as an array. |
int |
getRowComparatorSize()
Returns the size of the currently defined row comparators of this treetable. |
Object |
getValueAt(Object n,
int columnIndex)
Returns the value to be displayed for node,
at column index column. |
void |
insertRowComparator(TreeTableComparator newComparator,
int index)
Inserts a row comparator at index in the list of row comparators of this model. |
boolean |
isAggregate(Object node)
Determines if node is an aggregate row. |
boolean |
isCellEditable(Object node,
int columnIndex)
Returns true if node at columnIndex is editable. |
boolean |
isFooter(Object node)
Determines if node is a footer. |
boolean |
isHeader(Object node)
Determines if node is a header. |
void |
loadComparators(ObjectInputStream in)
Restores the TreeTableComparators and assigns them on the model. |
void |
refresh()
Forces a re-creation of the entire tree. |
void |
removeReorderListener(ReorderListener l)
Removes a listener from the list that is notified each time a reorder event is generated. |
void |
removeRow(TreeTableRow row)
Removes row from the model. |
TreeTableComparator |
removeRowComparator(int index)
Removes the row comparator that is located at index. |
boolean |
removeRowComparator(TreeTableComparator comparator)
Removes a comparator from the list of comparators of this TreeTableModel. |
void |
removeRows(TreeTableRow[] rows)
Removes a list of rows identified by rows from the model. |
void |
rowsReordered(ReorderEvent e)
Called whenever the rows of a JTable have been restructured. |
void |
saveComparators(ObjectOutputStream out)
Saves the TreeTableComparators that are currently installed on the model. |
void |
setDefaultAggregator(Aggregator aggregator)
Sets the default aggregator that will be used to compute values for the aggregate rows of the model. |
void |
setDefaultComparator(Class columnClass,
Comparator comparator)
Sets the default comparator for columnClass. |
void |
setFooter(Footer footer)
Sets a footer instance to be used as the model's default footer. |
void |
setModel(ListTableModel newModel)
Sets the underlying ListTableModel to newModel. |
TreeTableComparator |
setRowComparator(TreeTableComparator newComparator,
int index)
Sets a treetable comparator at index. |
void |
setValueAt(Object aValue,
Object node,
int columnIndex)
Sets the value for node at columnIndex to aValue. |
void |
tableChanged(TableModelEvent e)
This fine grain notification tells listeners the exact range of cells, rows, or columns that changed. |
| Methods inherited from class com.sciapp.treetable.TreeModelMap |
|---|
getChild, getChildCount, getIndexOfChild, getPathToRoot, getPathToRoot, getRoot, getTreeModel, isLeaf, nodeChanged, nodesChanged, nodeStructureChanged, setTreeModel, treeNodesChanged, treeNodesInserted, treeNodesRemoved, treeStructureChanged, valueForPathChanged |
| Methods inherited from class com.sciapp.treetable.AbstractTreeTableModel |
|---|
addTreeModelListener, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, fireTreeTableStructureChanged, fireTreeTableStructureChanged, removeTreeModelListener, setRoot |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected ListTableModel tableModel
protected transient Footer footer
protected ArrayList comparators
protected transient Aggregator defaultAggregator
protected transient Hashtable defaultComparatorsByColumnClass
| Constructor Detail |
|---|
public DynamicTreeTableModel(ListTableModel tableModel)
tableModel - com.sciapp.table.ListTableModel| Method Detail |
|---|
public void addReorderListener(ReorderListener l)
addReorderListener in interface ReorderModell - the ReorderListenerpublic void addRow(Object row)
row - the row being addedpublic void addRowComparator(TreeTableComparator newComparator)
newComparator - the new row comparator to addpublic void addRows(List addedRows)
addedRows contains objects representing the actual rows being added. e.g. java.util.Vector, for DefaultTableModel.
addedRows - the rows being added.protected void buildFooter()
protected void buildTree()
buildFooter().
public void clear()
public void clearComparators()
protected Aggregator createDefaultAggregator()
DefaultCellAggregator.
protected void createDefaultComparators()
protected Footer createDefaultFooter()
setFooter(com.sciapp.treetable.Footer).
public void fireRowsMapped(int[] changedIndices)
fireRowsMapped in interface ReorderModelchangedIndices - int array indicating how the rows have been reordered.ReorderEventpublic void fireRowsReordered(ReorderEvent event)
fireRowsReordered in interface ReorderModelevent - the reorder event.ReorderEventpublic Aggregator getAggregator(int columnIndex)
columnIndex.
This method returns the default aggregator by default. You will need to override it
if you desire a more complex behaviour.
columnIndex - the index of the column
columnIndex
public Object getCellValue(Object row,
int index)
row - the row dataindex - an index
public Class getColumnClass(int c)
getColumnClass in interface TreeTableModelc - the index of the column
public int getColumnCount()
getColumnCount in interface TreeTableModelpublic String getColumnName(int columnIndex)
getColumnName in interface TreeTableModelcolumnIndex - the index of the column
public int getDataRow(TreeTableRow node)
node.
If this node is an aggregate row, this method returns -1.
node - the node whose model index we want returned.
public int[] getDataRows(TreeTableRow node)
node.
If this node is not an aggregate row, then an array of one integer
is returned, which contains the modelIndex of that node.
node - the node under which all model indexes are returned.
public Aggregator getDefaultAggregator()
public Comparator getDefaultComparator(Class columnClass)
columnClass - the class for which we want to find a comparator
public Footer getFooter()
public ListTableModel getModel()
public int[] getModelIndexesUnderRow(TreeTableRow row,
boolean sorted)
row - the node under which all model indexes are returned.sorted - if this is true, the integer array is sorted, otherwise the array contains
the model indexes as they appear on the table.
public TreeTableComparator getRowComparator(int index)
public TreeTableComparator[] getRowComparators()
public int getRowComparatorSize()
public Object getValueAt(Object n,
int columnIndex)
node,
at column index column.
getValueAt in interface TreeTableModeln - the node to querycolumnIndex - the column index
public void insertRowComparator(TreeTableComparator newComparator,
int index)
newComparator - the new row comparator to insertindex - the index at which we want the comparator insertedpublic boolean isAggregate(Object node)
node is an aggregate row.
isAggregate in interface TreeTableModelisAggregate in class AbstractTreeTableModelnode - the node to consider
node is an aggregate row, false otherwise
public boolean isCellEditable(Object node,
int columnIndex)
node at columnIndex is editable.
isCellEditable in interface TreeTableModelnode - the node to considercolumnIndex - the column index
public boolean isFooter(Object node)
node is a footer.
isFooter in interface TreeTableModelisFooter in class AbstractTreeTableModelnode - the row to consider
node is a footer, false otherwisepublic boolean isHeader(Object node)
node is a header.
isHeader in interface TreeTableModelisHeader in class AbstractTreeTableModelnode - the row to query
node is a header, false otherwisepublic void loadComparators(ObjectInputStream in)
saveComparators method.
in - the object input stream to read from in order to construct the comparators.public void refresh()
public void removeReorderListener(ReorderListener l)
removeReorderListener in interface ReorderModell - the RearrangeListenerpublic void removeRow(TreeTableRow row)
row from the model.
row - the node to remove.public TreeTableComparator removeRowComparator(int index)
index - the location of the comparator we want removed
public boolean removeRowComparator(TreeTableComparator comparator)
comparator - the comparator to remove
public void removeRows(TreeTableRow[] rows)
rows from the model.
rows - the nodes to remove.public void rowsReordered(ReorderEvent e)
rowsReordered in interface ReorderListenere - the ReorderEvent objectpublic void saveComparators(ObjectOutputStream out)
loadComparators method.
out - the object output stream to write to when saving the comparators state.public void setDefaultAggregator(Aggregator aggregator)
aggregator - the aggregator to assign as the default
public void setDefaultComparator(Class columnClass,
Comparator comparator)
columnClass - the Class for which a comparator we want to setcomparator - the comparator to setpublic void setFooter(Footer footer)
footer - the footer object to assign to this TreeTableModelpublic void setModel(ListTableModel newModel)
newModel - the new ListTableModel to set
public TreeTableComparator setRowComparator(TreeTableComparator newComparator,
int index)
newComparator - the new comparator to assignindex - set the new comparator at index
public void setValueAt(Object aValue,
Object node,
int columnIndex)
node at columnIndex to aValue.
setValueAt in interface TreeTableModelaValue - the new valuenode - the node whose value is to be changedcolumnIndex - the column whose value is to be changedpublic void tableChanged(TableModelEvent e)
tableChanged in interface TableModelListener
|
Copyright © 2005 Scientific Applications. All Rights Reserved. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||