|
Copyright © 2011 Citra Technologies. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.table.AbstractTableModel
com.citra.table.ListTableMap
com.citra.tree.TreeTableModel
public class TreeTableModel
TreeTableModel is the tablemodel that the TreeTable class uses. TreeTableModel 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 TreeTableModel 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 TreeTableModel.
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 HeaderRow |
root
the root object of the tree structure |
protected JTree |
tree
the tree structure created every time the data changes |
protected DefaultTreeModel |
treeModel
the model of the tree |
Fields inherited from class com.citra.table.ListTableMap |
---|
tableModel |
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Constructor Summary | |
---|---|
TreeTableModel(ListTableModel tableModel)
Constructs a TreeTableModel with tableModel as the underlying tablemodel
holding the data. |
Method Summary | |
---|---|
void |
addRowComparator(TreeTableComparator newComparator)
Adds a new row comparator at the end of the list of comparators. |
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 |
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. |
Aggregator |
getAggregator(int rowIndex,
int columnIndex)
Returns the aggregator at rowIndex and columnIndex. |
int |
getDataRow(int rowIndex)
Returns the index that corresponds to the object of the ListTableModel that holds the actual tabular data, that is found at row rowIndex. |
int[] |
getDataRows(int rowIndex)
Returns the indexes that correspond to the objects of the ListTableModel that holds the actual tabular data, that are children of the TreeTableRow found at row rowIndex. |
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. |
int |
getLevel(int rowIndex)
Returns the level of the TreeTableRow object at rowIndex below the root node of the tree structure of the model. |
int[] |
getModelIndexesUnderRow(int 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 found at row row. |
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. |
int |
getRowCount()
Returns tableModel.getRowCount |
List |
getRows()
Returns tableModel.getRows Returns a list containing the TreeTableRows of the model. |
TreeTableRow |
getTreeRow(int rowIndex)
Returns the TreeTableRow found at row rowIndex of the TreeTable. |
Object |
getValueAt(int rowIndex,
int columnIndex)
Returns the value for the cell at columnIndex and rowIndex . |
void |
insertRowComparator(TreeTableComparator newComparator,
int index)
Inserts a row comparator at index in the list of row comparators of this model. |
boolean |
isAggregate(int rowIndex)
Determines if the row at rowIndex is an aggregate row. |
boolean |
isCellEditable(int rowIndex,
int columnIndex)
Returns false if the row at rowIndex is an aggregate row, otherwise returns the value of its super method. |
boolean |
isFooter(int rowIndex)
Determines if the row at rowIndex is a footer. |
boolean |
isHeader(int rowIndex)
Determines if the row at rowIndex is a header. |
void |
refresh()
Forces a re-creation of the entire tree. |
void |
removeRow(int row)
Removes a row from the data 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(int[] rows)
Removes a few rows from the data model |
void |
rowsReordered(ReorderEvent e)
Called whenever the rows of a JTable have been restructured. |
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. |
TreeTableComparator |
setRowComparator(TreeTableComparator newComparator,
int index)
Sets a TreeTable comparator at index. |
void |
setValueAt(Object aValue,
int rowIndex,
int columnIndex)
Sets the value in the cell 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.citra.table.ListTableMap |
---|
addReorderListener, addRow, addRows, clear, convertRowIndexToModel, convertRowIndexToView, fireRowsMapped, fireRowsReordered, getCellValue, getColumnClass, getColumnCount, getColumnName, getInnerModel, getModel, removeReorderListener, setModel |
Methods inherited from class javax.swing.table.AbstractTableModel |
---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.citra.table.ListTableModel |
---|
fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged |
Methods inherited from interface javax.swing.table.TableModel |
---|
addTableModelListener, removeTableModelListener |
Field Detail |
---|
protected transient Footer footer
protected JTree tree
protected DefaultTreeModel treeModel
protected HeaderRow root
protected ArrayList comparators
protected transient Aggregator defaultAggregator
protected transient Hashtable defaultComparatorsByColumnClass
Constructor Detail |
---|
public TreeTableModel(ListTableModel tableModel)
tableModel
as the underlying tablemodel
holding the data.
Method Detail |
---|
public void addRowComparator(TreeTableComparator newComparator)
newComparator
- the new row comparator to addprotected void buildFooter()
protected void buildTree()
TreeTableModel.buildFooter()
.
public void clearComparators()
protected Aggregator createDefaultAggregator()
DefaultCellAggregator
.
protected void createDefaultComparators()
protected Footer createDefaultFooter()
TreeTableModel.setFooter(com.citra.tree.Footer)
.
public Aggregator getAggregator(int rowIndex, int columnIndex)
rowIndex
- the index of the rowcolumnIndex
- the index of the column
public int getDataRow(int rowIndex)
rowIndex
- the index of the node whose model index we want returned.
public int[] getDataRows(int rowIndex)
rowIndex
- the index of 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 int getLevel(int rowIndex)
rowIndex
- the row index at which the TreeTableRow is located
public int[] getModelIndexesUnderRow(int row, boolean sorted)
row
- the index of 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 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 int getRowCount()
getRowCount
in interface TableModel
getRowCount
in class ListTableMap
TableModel.getColumnCount()
public List getRows()
getRows
in interface ListTableModel
getRows
in class ListTableMap
public TreeTableRow getTreeRow(int rowIndex)
rowIndex
- the row of the table
public Object getValueAt(int rowIndex, int columnIndex)
columnIndex
and rowIndex
.
If the row at rowIndex is an aggregate row, the aggregator at (rowIndex, columnIndex)
is retrieved and used to return the aggregate value.
Otherwise, the value of the object at the specified cell is returned as normal.
getValueAt
in interface TableModel
getValueAt
in class ListTableMap
rowIndex
- the row whose value is to be queriedcolumnIndex
- the column whose value is to be queried
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(int rowIndex)
rowIndex
- the row to query
public boolean isCellEditable(int rowIndex, int columnIndex)
isCellEditable
in interface TableModel
isCellEditable
in class ListTableMap
rowIndex
- the row being queriedcolumnIndex
- the column being queried
TableModel.setValueAt(java.lang.Object, int, int)
public boolean isFooter(int rowIndex)
rowIndex
- the row to query
public boolean isHeader(int rowIndex)
rowIndex
- the row to query
public void refresh()
public void removeRow(int row)
removeRow
in interface ListTableModel
removeRow
in class ListTableMap
row
- the index of the row being removedpublic 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(int[] rows)
removeRows
in interface ListTableModel
removeRows
in class ListTableMap
rows
- an integer array that contains indexes of the rows being deletedpublic void rowsReordered(ReorderEvent e)
rowsReordered
in interface ReorderListener
rowsReordered
in class ListTableMap
e
- the ReorderEvent objectpublic void setDefaultAggregator(Aggregator aggregator)
aggregator
- the aggregator to assign as the defaultpublic 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 TreeTableComparator setRowComparator(TreeTableComparator newComparator, int index)
newComparator
- the new comparator to assignindex
- set the new comparator at index
public void setValueAt(Object aValue, int rowIndex, int columnIndex)
columnIndex and
rowIndex
to aValue.
setValueAt
in interface TableModel
setValueAt
in class ListTableMap
aValue
- value to assign to cellrowIndex
- row of cellcolumnIndex
- column of cellTableModel.getValueAt(int, int)
,
TableModel.isCellEditable(int, int)
public void tableChanged(TableModelEvent e)
tableChanged
in interface TableModelListener
tableChanged
in class ListTableMap
|
Copyright © 2011 Citra Technologies. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |