public class MaskTreeModel extends Object implements TreeModel
It's intended for use with a static base model. It ought to work for a base model which sends TreeModelEvents, but that hasn't been tested, and it doesn't translate the events very cleverly to downstream listeners.
Modifier and Type | Class and Description |
---|---|
static interface |
MaskTreeModel.Mask
Defines node inclusion in a masked tree.
|
Constructor and Description |
---|
MaskTreeModel(TreeModel base,
boolean includeDescendants)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addTreeModelListener(TreeModelListener lnr) |
TreeModel |
getBaseModel()
Returns the underlying, unmasked, model.
|
Object |
getChild(Object parent,
int index) |
int |
getChildCount(Object parent) |
int |
getIndexOfChild(Object parent,
Object child) |
MaskTreeModel.Mask |
getMask()
Returns the currently active mask.
|
int |
getNodeCount()
Returns the total number of nodes in this model.
|
Object |
getRoot() |
boolean |
isLeaf(Object node) |
void |
removeTreeModelListener(TreeModelListener lnr) |
void |
setBaseModel(TreeModel base)
Sets the underlying, unmasked, model.
|
void |
setMask(MaskTreeModel.Mask mask)
Sets the mask for defning inclusion of nodes in the base model.
|
void |
valueForPathChanged(TreePath path,
Object newValue) |
public MaskTreeModel(TreeModel base, boolean includeDescendants)
base
- underlying tree modelincludeDescendants
- if true, all descendants of an included node
are automatically includedpublic int getChildCount(Object parent)
getChildCount
in interface TreeModel
public int getIndexOfChild(Object parent, Object child)
getIndexOfChild
in interface TreeModel
public void valueForPathChanged(TreePath path, Object newValue)
valueForPathChanged
in interface TreeModel
public void addTreeModelListener(TreeModelListener lnr)
addTreeModelListener
in interface TreeModel
public void removeTreeModelListener(TreeModelListener lnr)
removeTreeModelListener
in interface TreeModel
public TreeModel getBaseModel()
public void setBaseModel(TreeModel base)
base
- new base modelpublic MaskTreeModel.Mask getMask()
public void setMask(MaskTreeModel.Mask mask)
isIncluded
always returns true).
If the supplied mask
matches the previously installed
one by equality, no action is performed. So it's not essential
that mask implementations implement equals/hashCode, but it may be
beneficial.
mask
- new mask, or null for full inclusionpublic int getNodeCount()
Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.