Package uk.ac.starlink.vo
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 interface
Defines node inclusion in a masked tree. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Returns the underlying, unmasked, model.int
getChildCount
(Object parent) int
getIndexOfChild
(Object parent, Object child) getMask()
Returns the currently active mask.int
Returns the total number of nodes in this model.getRoot()
boolean
void
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)
-
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:
getChildCount
in interfaceTreeModel
-
getChild
-
getIndexOfChild
- Specified by:
getIndexOfChild
in interfaceTreeModel
-
valueForPathChanged
- Specified by:
valueForPathChanged
in interfaceTreeModel
-
addTreeModelListener
- Specified by:
addTreeModelListener
in interfaceTreeModel
-
removeTreeModelListener
- Specified by:
removeTreeModelListener
in interfaceTreeModel
-
getBaseModel
Returns the underlying, unmasked, model.- Returns:
- base tree model
-
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 whichisIncluded
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.- 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
-