Package gov.nasa.worldwind.util.tree
Class BasicTreeNode
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.util.tree.BasicTreeNode
-
- All Implemented Interfaces:
AVList,MessageListener,TreeNode,WWObject,java.beans.PropertyChangeListener,java.util.EventListener
- Direct Known Subclasses:
KMLFeatureTreeNode,LayerTreeNode
public class BasicTreeNode extends WWObjectImpl implements TreeNode
Default implementation of aTreeNode.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<TreeNode>childrenprotected java.lang.Stringdescriptionprotected booleanenabledprotected java.lang.ObjectimageSourceprotected TreeNodeparentprotected booleanselectedprotected java.lang.Stringtextprotected BasicWWTexturetextureprotected java.lang.StringtreeSelectedFlag to indicate that any part of the sub-tree rooted at this node is selected.protected booleanvisible-
Fields inherited from interface gov.nasa.worldwind.util.tree.TreeNode
NOT_SELECTED, PARTIALLY_SELECTED, SELECTED
-
-
Constructor Summary
Constructors Constructor Description BasicTreeNode(java.lang.String text)Create a node with text.BasicTreeNode(java.lang.String text, java.lang.Object imageSource)Create a node with text and an icon.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(int index, TreeNode child)Add a child node at a specified position in the list of children.voidaddChild(TreeNode child)Add a child node.protected java.lang.StringcomputeTreeSelected()Determine if any part of the sub-tree rooted at this node is selected.java.lang.Iterable<TreeNode>getChildren()Get the children of this node.java.lang.StringgetDescription()Get extra text associated with this node.java.lang.ObjectgetImageSource()Get the source of the node icon.TreeNodegetParent()Get the node's parent.TreePathgetPath()Get the path from the root node to this node.java.lang.StringgetText()Get the text of this node.BasicWWTexturegetTexture()Get the texture loaded for the node's icon.booleanhasImage()Does this node have an icon? This method returns true if an image source has been set.protected voidinitializeTexture()Create and initialize the texture from the image source.booleanisEnabled()Is the node enabled?booleanisLeaf()Is the node a leaf node.booleanisSelected()Is the node selected?java.lang.StringisTreeSelected()Is any part of the sub-tree rooted at this node selected?booleanisVisible()Is the node visible?voidpropertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)The property change listener for this instance.voidremoveAllChildren()Remove all of the child nodes from this node.voidremoveChild(TreeNode child)Remove a child node.voidsetDescription(java.lang.String description)Set the node description.voidsetEnabled(boolean enabled)Set the node to enabled or not enabled.voidsetImageSource(java.lang.Object imageSource)Set the node's icon.voidsetParent(TreeNode node)Set the parent node.voidsetSelected(boolean selected)Set the node to selected or not selected.voidsetVisible(boolean visible)Set the node to visible or not visible.-
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage
-
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
-
-
-
-
Field Detail
-
text
protected java.lang.String text
-
imageSource
protected java.lang.Object imageSource
-
texture
protected BasicWWTexture texture
-
description
protected java.lang.String description
-
parent
protected TreeNode parent
-
children
protected java.util.List<TreeNode> children
-
enabled
protected boolean enabled
-
selected
protected boolean selected
-
visible
protected boolean visible
-
treeSelected
protected java.lang.String treeSelected
Flag to indicate that any part of the sub-tree rooted at this node is selected. This value is computed on demand and cached.
-
-
Constructor Detail
-
BasicTreeNode
public BasicTreeNode(java.lang.String text)
Create a node with text.- Parameters:
text- Node text.
-
BasicTreeNode
public BasicTreeNode(java.lang.String text, java.lang.Object imageSource)Create a node with text and an icon.- Parameters:
text- Node text.imageSource- Image source for the node icon. May be a String, URL, or BufferedImage.
-
-
Method Detail
-
getText
public java.lang.String getText()
Get the text of this node.
-
getParent
public TreeNode getParent()
Get the node's parent. Each node in the tree has a parent, except for the root node. The parent of the root node isnull.- Specified by:
getParentin interfaceTreeNode- Returns:
- Parent node, or
nullif this the root node. - See Also:
TreeNode.setParent(TreeNode)
-
setParent
public void setParent(TreeNode node)
Set the parent node.- Specified by:
setParentin interfaceTreeNode- Parameters:
node- New parent node.- See Also:
TreeNode.getParent()
-
getChildren
public java.lang.Iterable<TreeNode> getChildren()
Get the children of this node.- Specified by:
getChildrenin interfaceTreeNode- Returns:
- Child nodes, or an empty iterator if the node does not have children.
- See Also:
TreeNode.addChild(TreeNode)
-
isEnabled
public boolean isEnabled()
Is the node enabled?- Specified by:
isEnabledin interfaceTreeNode- Returns:
- True if the node is enabled.
- See Also:
TreeNode.setEnabled(boolean)
-
setEnabled
public void setEnabled(boolean enabled)
Set the node to enabled or not enabled. A node that is not enabled will not respond to user input.- Specified by:
setEnabledin interfaceTreeNode- Parameters:
enabled- New enabled state.- See Also:
TreeNode.isEnabled()
-
isSelected
public boolean isSelected()
Is the node selected?- Specified by:
isSelectedin interfaceTreeNode- Returns:
- True if the node is selected.
- See Also:
TreeNode.setSelected(boolean),TreeNode.isTreeSelected()
-
setSelected
public void setSelected(boolean selected)
Set the node to selected or not selected.- Specified by:
setSelectedin interfaceTreeNode- Parameters:
selected- New selection value.- See Also:
TreeNode.isSelected()
-
isTreeSelected
public java.lang.String isTreeSelected()
Is any part of the sub-tree rooted at this node selected?- Specified by:
isTreeSelectedin interfaceTreeNode- Returns:
TreeNode.SELECTED,TreeNode.NOT_SELECTED,TreeNode.PARTIALLY_SELECTED.
-
computeTreeSelected
protected java.lang.String computeTreeSelected()
Determine if any part of the sub-tree rooted at this node is selected.
-
isVisible
public boolean isVisible()
Is the node visible?- Specified by:
isVisiblein interfaceTreeNode- Returns:
- True if the node is visible.
- See Also:
TreeNode.setVisible(boolean)
-
isLeaf
public boolean isLeaf()
Is the node a leaf node.
-
setVisible
public void setVisible(boolean visible)
Set the node to visible or not visible. If the node is not visible it will not be drawn by the tree layout.- Specified by:
setVisiblein interfaceTreeNode- Parameters:
visible- New visibility setting.- See Also:
TreeNode.isVisible()
-
getDescription
public java.lang.String getDescription()
Description copied from interface:TreeNodeGet extra text associated with this node.- Specified by:
getDescriptionin interfaceTreeNode- Returns:
- Description of node.
-
setDescription
public void setDescription(java.lang.String description)
Description copied from interface:TreeNodeSet the node description. The description can hold any extra text associated with the node.- Specified by:
setDescriptionin interfaceTreeNode- Parameters:
description- New description.
-
getImageSource
public java.lang.Object getImageSource()
Get the source of the node icon.- Specified by:
getImageSourcein interfaceTreeNode- Returns:
- Image source of the icon.
nullif the node does not have an icon.
-
setImageSource
public void setImageSource(java.lang.Object imageSource)
Set the node's icon.- Specified by:
setImageSourcein interfaceTreeNode- Parameters:
imageSource- New icon source. May be a String, URL, or BufferedImage.
-
hasImage
public boolean hasImage()
Does this node have an icon? This method returns true if an image source has been set. The method returns true even if the image has not been fully loaded.
-
getTexture
public BasicWWTexture getTexture()
Get the texture loaded for the node's icon.- Specified by:
getTexturein interfaceTreeNode- Returns:
- Icon texture, or null if the texture has not been loaded yet.
-
initializeTexture
protected void initializeTexture()
Create and initialize the texture from the image source. If the image is not in memory this method will request that it be loaded.
-
addChild
public void addChild(TreeNode child)
Add a child node.
-
addChild
public void addChild(int index, TreeNode child)Add a child node at a specified position in the list of children.
-
removeChild
public void removeChild(TreeNode child)
Remove a child node.- Specified by:
removeChildin interfaceTreeNode- Parameters:
child- Child to remove.
-
removeAllChildren
public void removeAllChildren()
Remove all of the child nodes from this node.- Specified by:
removeAllChildrenin interfaceTreeNode
-
getPath
public TreePath getPath()
Get the path from the root node to this node.
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)
The property change listener for this instance. Receives property change notifications that this instance has registered with other property change notifiers.- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener- Overrides:
propertyChangein classWWObjectImpl- Parameters:
propertyChangeEvent- the event
-
-