public class IlvTreeListRowIndexCache extends Object
IlvTreeListModel
.
When a tree model is converted to a list or table, each object corresponds
to a "row" in the list or table. The order of the rows is given by the
preOrderIterator
function. This class implements a fast
conversion between the objects in the tree model and the indices of the
rows. Additionally, it provides also a conversion between the objects and
the TreePath
s leading to these objects; that is, it remembers
the position of each object in the tree.
This class acts as a cache. It updates itself when the underlying model changes.
Constructor and Description |
---|
IlvTreeListRowIndexCache(IlvTreeListModel model)
Creates a row index cache for the given model.
|
Modifier and Type | Method and Description |
---|---|
void |
disconnect()
Drops references to objects to help garbage collection.
|
void |
dispose()
Cleans up this cache and drops references to the model and its objects to
help garbage collection.
|
int |
getBranchSize(Object node)
Returns the number of node in the branch below the given node (including
the given node itself).
|
int |
getBranchSizeForPath(TreePath path)
Returns the number of node in the branch below the given tree path (including
the node at which the given tree path ends).
|
int |
getRowCount()
Returns the number of rows.
|
int |
getRowIndex(Object node)
Returns the row index of a given tree node.
|
int |
getRowIndexForPath(TreePath path)
Returns the row index of a given tree path.
|
int[] |
getRowIntervalForPath(TreePath path)
Returns a two-element array containing the first row index and the last
row index corresponding to the branch below the given tree path (including
the node at which the given tree path ends).
|
Object |
getTreeNodeAt(int row)
Returns the tree node at a given index.
|
TreePath |
getTreePathAt(int row)
Returns the tree path from the root to the node at a given index.
|
TreePath |
getTreePathOf(Object node)
Returns the tree path leading to a given node.
|
public IlvTreeListRowIndexCache(IlvTreeListModel model)
public int getRowCount()
public Object getTreeNodeAt(int row)
public TreePath getTreePathAt(int row)
public TreePath getTreePathOf(Object node)
lastPathComponent
is the given node.public int getRowIndex(Object node)
public int getRowIndexForPath(TreePath path)
public int getBranchSize(Object node)
public int getBranchSizeForPath(TreePath path)
public int[] getRowIntervalForPath(TreePath path)
This is the same as
[first, first + count - 1]
where first = getRowIndexForPath(path)
and count = getBranchSizeForPath(path)
.
public void dispose()
Note: After calling this function, this cache is no longer functional.
public void disconnect()
Note: After calling this function, and after some changes occurred in the underlying model, this cache is no longer functional.
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.