Class TreeRows
The open nodes of a TreeTableModel, flattened into rows in the order
they are shown: the row engine of a tree DataGrid, for any other view
of a tree that needs rows.
The rows are empty until refresh() reads the roots. Nodes are told
apart by equals and hashCode (see TreeTableModel). A row is a node
and its depth, 0 for a root; opening a row inserts the rows of its open
descendants after it, and closing it removes them.
Children are asked of the model the first time a node is opened and kept; opening a node inserts its rows and closing one removes them, so either costs what the node shows and not what the tree holds. A filter is the exception: deciding which paths lead to a match reads the whole tree.
-
Constructor Summary
ConstructorsConstructorDescriptionTreeRows(TreeTableModel model) Rows over a tree model, empty untilrefresh(). -
Method Summary
Modifier and TypeMethodDescriptionintgetDepth(int row) How deep a row is: 0 for a root.getModel()The model the rows show.getNode(int row) The node a row shows.intThe row showing a node, or -1 when it has none.intHow many rows there are.booleanisNodeExpanded(Object node) Whether a node is open, shown or not.booleanisRowExpandable(int row) Whether a row can open: its node is not a leaf.booleanisRowExpanded(int row) Whether a row is open.voidrefresh()Asks the model for the whole tree again and flattens it, keeping which nodes are open.voidrefreshNode(Object node) Asks the model again for the children of one node and flattens the tree, keeping which nodes are open.intsetNodeExpanded(Object node, boolean open) Opens or closes a node whether it is shown or not; one that is not shown opens the next time it is.intsetRowExpanded(int row, boolean open) Opens or closes a row.
-
Constructor Details
-
TreeRows
Rows over a tree model, empty untilrefresh().
-
-
Method Details
-
getModel
The model the rows show. -
getRowCount
public int getRowCount()How many rows there are. -
getNode
The node a row shows. -
getDepth
public int getDepth(int row) How deep a row is: 0 for a root. -
isRowExpandable
public boolean isRowExpandable(int row) Whether a row can open: its node is not a leaf. -
isRowExpanded
public boolean isRowExpanded(int row) Whether a row is open. -
setRowExpanded
public int setRowExpanded(int row, boolean open) Opens or closes a row.
Returns
how many rows were inserted after it, or removed after it when negative; 0 when nothing moved
-
getRow
The row showing a node, or -1 when it has none. -
isNodeExpanded
Whether a node is open, shown or not. -
setNodeExpanded
Opens or closes a node whether it is shown or not; one that is not shown opens the next time it is.
Returns
the rows inserted or, when negative, removed after the node's row
-
refresh
public void refresh()Asks the model for the whole tree again and flattens it, keeping which nodes are open. -
refreshNode
Asks the model again for the children of one node and flattens the tree, keeping which nodes are open.
-