Class MaskTreeModel
java.lang.Object
uk.ac.starlink.vo.MaskTreeModel
- All Implemented Interfaces:
TreeModel
Wrapper tree model that includes only a selection of the nodes
in the base model. The selection is controlled by a supplied Mask object.
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.
- Since:
- 17 Mar 2015
- Author:
- Mark Taylor
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDefines node inclusion in a masked tree. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidReturns the underlying, unmasked, model.intgetChildCount(Object parent) intgetIndexOfChild(Object parent, Object child) getMask()Returns the currently active mask.intReturns the total number of nodes in this model.getRoot()booleanvoidvoidsetBaseModel(TreeModel base) Sets the underlying, unmasked, model.voidsetMask(MaskTreeModel.Mask mask) Sets the mask for defning inclusion of nodes in the base model.voidvalueForPathChanged(TreePath path, Object newValue)
-
Constructor Details
-
MaskTreeModel
Constructor.- Parameters:
base- underlying tree modelincludeDescendants- if true, all descendants of an included node are automatically included
-
-
Method Details
-
getRoot
-
isLeaf
-
getChildCount
- Specified by:
getChildCountin interfaceTreeModel
-
getChild
-
getIndexOfChild
- Specified by:
getIndexOfChildin interfaceTreeModel
-
valueForPathChanged
- Specified by:
valueForPathChangedin interfaceTreeModel
-
addTreeModelListener
- Specified by:
addTreeModelListenerin interfaceTreeModel
-
removeTreeModelListener
- Specified by:
removeTreeModelListenerin interfaceTreeModel
-
getBaseModel
-
setBaseModel
Sets the underlying, unmasked, model.- Parameters:
base- new base model
-
getMask
Returns the currently active mask.- Returns:
- mask, may be null for full inclusion
-
setMask
Sets the mask for defning inclusion of nodes in the base model. A null mask is used for full inclusion (and will be more efficient than one for whichisIncludedalways returns true).If the supplied
maskmatches 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.- Parameters:
mask- new mask, or null for full inclusion
-
getNodeCount
public int getNodeCount()Returns the total number of nodes in this model.- Returns:
- node count
-