NASA World Wind

gov.nasa.worldwind.util.layertree
Class KMLFeatureTreeNode

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.util.tree.BasicTreeNode
              extended by gov.nasa.worldwind.util.layertree.KMLFeatureTreeNode
All Implemented Interfaces:
AVList, MessageListener, TreeNode, WWObject, PropertyChangeListener, EventListener
Direct Known Subclasses:
KMLContainerTreeNode

public class KMLFeatureTreeNode
extends BasicTreeNode

A TreeNode that represents a KML feature defined by a KMLAbstractFeature.

The node's selection state is synchronized with its KML feature's visibility state. isSelected() returns whether the node's feature is visible. Calling setSelected(boolean) specifies both the the node's selection state, and whether its feature should be enabled for rendering and selection.


Field Summary
protected  KMLAbstractFeature feature
          Indicates the KML feature this node represents.
 
Fields inherited from class gov.nasa.worldwind.util.tree.BasicTreeNode
children, description, enabled, imageSource, parent, selected, text, texture, treeSelected, visible
 
Fields inherited from interface gov.nasa.worldwind.util.tree.TreeNode
NOT_SELECTED, PARTIALLY_SELECTED, SELECTED
 
Constructor Summary
KMLFeatureTreeNode(KMLAbstractFeature feature)
          Creates a new KMLFeatureTreeNode from the specified feature.
 
Method Summary
 void expandOpenContainers(Tree tree)
          Expands paths in the specified tree corresponding to open KML container elements.
static KMLFeatureTreeNode fromKMLFeature(KMLAbstractFeature feature)
          Creates a new KMLFeatureTreeNode from the specified feature.
 String getDescription()
          Get extra text associated with this node.
 KMLAbstractFeature getFeature()
          Indicates the KML feature this node represents.
 String getText()
          Get the text of this node.
protected  void initialize()
          Places the KML feature in the node's AVKey.CONTEXT field.
 boolean isSelected()
          Indicates whether this node's KML feature is enabled for rendering.
protected  String makeFeatureDescription()
          Makes this node's description text from its KML feature.
protected  boolean mustExpandNode()
          Indicates whether the tree path for this node must expanded.
 void setSelected(boolean selected)
          Specifies whether this node's feature is enabled for rendering and selection.
protected  String stripHtmlTags(String input)
          Remove HTML tags and extra whitespace from a string.
 
Methods inherited from class gov.nasa.worldwind.util.tree.BasicTreeNode
addChild, addChild, computeTreeSelected, getChildren, getImageSource, getParent, getPath, getTexture, hasImage, initializeTexture, isEnabled, isLeaf, isTreeSelected, isVisible, propertyChange, removeAllChildren, removeChild, setDescription, setEnabled, setImageSource, setParent, setVisible
 
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, finalize, 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

feature

protected KMLAbstractFeature feature
Indicates the KML feature this node represents. Initialized during construction.

Constructor Detail

KMLFeatureTreeNode

public KMLFeatureTreeNode(KMLAbstractFeature feature)
Creates a new KMLFeatureTreeNode from the specified feature. The node's name is set to the feature's name.

Parameters:
feature - the KML feature this node represents.
Throws:
IllegalArgumentException - if the feature is null.
Method Detail

expandOpenContainers

public void expandOpenContainers(Tree tree)
Expands paths in the specified tree corresponding to open KML container elements. This assumes that the tree's model contains this node.

This node's path is expanded if the feature's open property is true.

This calls expandOpenContainers on all children which are instances of KMLFeatureTreeNode.

Parameters:
tree - the Tree who's paths should be expanded.
Throws:
IllegalArgumentException - if the tree is null.

fromKMLFeature

public static KMLFeatureTreeNode fromKMLFeature(KMLAbstractFeature feature)
Creates a new KMLFeatureTreeNode from the specified feature. This maps the feature type to a node type as follows:

Parameters:
feature - the KML feature to create a new KMLFeatureTreeNode for.
Returns:
a new KMLFeatureTreeNode.
Throws:
IllegalArgumentException - if the feature is null.

getDescription

public String getDescription()
Description copied from interface: TreeNode
Get extra text associated with this node.

Specified by:
getDescription in interface TreeNode
Overrides:
getDescription in class BasicTreeNode
Returns:
Description of node.

getFeature

public KMLAbstractFeature getFeature()
Indicates the KML feature this node represents.

Returns:
this node's KML feature.

getText

public String getText()
Description copied from class: BasicTreeNode
Get the text of this node.

Specified by:
getText in interface TreeNode
Overrides:
getText in class BasicTreeNode
Returns:
Node text.

initialize

protected void initialize()
Places the KML feature in the node's AVKey.CONTEXT field.


isSelected

public boolean isSelected()
Indicates whether this node's KML feature is enabled for rendering.

Specified by:
isSelected in interface TreeNode
Overrides:
isSelected in class BasicTreeNode
Returns:
true if the KML feature is enabled for rendering, otherwise false.
See Also:
TreeNode.setSelected(boolean), TreeNode.isTreeSelected()

makeFeatureDescription

protected String makeFeatureDescription()
Makes this node's description text from its KML feature. This uses the feature's KMLSnippet if present, or the feature's description if there is no snippet.

Returns:
The feature description.

mustExpandNode

protected boolean mustExpandNode()
Indicates whether the tree path for this node must expanded. This return true if the KML feature's open property is true, and false otherwise.

Returns:
true if the tree path for this node must be expanded, otherwise false.

setSelected

public void setSelected(boolean selected)
Specifies whether this node's feature is enabled for rendering and selection. This sets both the node's selection state and its KML feature's visible state.

Specified by:
setSelected in interface TreeNode
Overrides:
setSelected in class BasicTreeNode
Parameters:
selected - true to enable the KML feature, otherwise false.
See Also:
TreeNode.isSelected()

stripHtmlTags

protected String stripHtmlTags(String input)
Remove HTML tags and extra whitespace from a string. Runs of whitespace will be collapsed to a single space.

Parameters:
input - Text to strip of HTML tags and extra whitespace.
Returns:
The input string with HTML tags removed, and runs of whitespace collapsed to a single space. Returns null if input is null.

NASA World Wind