Class LayerTreeModel
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.util.tree.BasicTreeModel
-
- gov.nasa.worldwind.util.layertree.LayerTreeModel
-
- All Implemented Interfaces:
AVList,MessageListener,TreeModel,WWObject,java.beans.PropertyChangeListener,java.util.EventListener
public class LayerTreeModel extends BasicTreeModel
A tree model representingobjects and their content.LayerLayerTreeModelinitializes itself with a default root node. By default, this root node is of typeBasicTreeNodeand its text is "Layers". Nodes added under the tree model's root should always be of type. aLayerTreeNodeLayerTreeNodemay be of any type.LayerTreeModelprovides operations for performing the following common tasks on a layer tree:- Adding a layer node.
- Removing all layer nodes.
- Refreshing the layer nodes from a
.LayerList
By default, the tree model does not include layers marked as hidden. This allows an application to prevent certain layers in a
LayerListfrom appearing in the tree. For example, the layer that renders the tree itself usually should not appear in the tree. If it did then the user could turn off the tree layer and have no way of getting it back. A layer can be marked as hidden by settingAVKey.HIDDENtotrue:hiddenLayer.setValue(AVKey.HIDDEN, true); // Prevent layer from being displayed in the layer tree
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringDEFAULT_ROOT_NAMEThe default root name: "Layers".protected booleanincludeHiddenLayersIndicates whether or not the tree model must include hidden layers.-
Fields inherited from class gov.nasa.worldwind.util.tree.BasicTreeModel
root
-
-
Constructor Summary
Constructors Constructor Description LayerTreeModel()Creates a newLayerTreeModelwith the default root node.LayerTreeModel(LayerList layerList)Creates a newLayerTreeModelwith the default root node and adds a newLayerTreeNodefor each non-hiddenLayerin the specifiedlayerList.LayerTreeModel(LayerList layerList, boolean includeHiddenLayers)Creates a newLayerTreeModelwith the default root node and adds a newLayerTreeNodefor eachLayerin the specifiedlayerList.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LayerTreeNodeaddLayer(Layer layer)Adds the a newLayerTreeNodecreated with the specifiedlayerto this tree model's root node.voidaddLayer(LayerTreeNode layerNode)Adds the specifiedlayerNodeto this tree model's root node.protected LayerTreeNodecreateLayerNode(Layer layer)Returns a new rootLayerTreeNodefor the specifiedlayer.protected TreeNodecreateRootNode()Returns a new rootTreeNodefor this tree model.protected voidinitialize()Initializes this tree model with the default root node.booleanisIncludeHiddenLayers()Indicates whether or not this tree model includes layers marked as hidden.protected booleanmustIncludeLayer(Layer layer)Determines if a layer must be included in the layer tree.voidrefresh(LayerList layerList)Refreshes this tree model's layer nodes with the specifiedlayerList.voidremoveAllLayers()Clears this tree model by removing all children of the root node.voidsetIncludeHiddenLayers(boolean includeHiddenLayers)Specifies whether or not this tree model includes layers marked as hidden.-
Methods inherited from class gov.nasa.worldwind.util.tree.BasicTreeModel
getRoot, setRoot
-
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage, propertyChange
-
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
-
DEFAULT_ROOT_NAME
protected static final java.lang.String DEFAULT_ROOT_NAME
The default root name: "Layers".- See Also:
- Constant Field Values
-
includeHiddenLayers
protected boolean includeHiddenLayers
Indicates whether or not the tree model must include hidden layers.
-
-
Constructor Detail
-
LayerTreeModel
public LayerTreeModel()
Creates a newLayerTreeModelwith the default root node. Otherwise the new model is empty.
-
LayerTreeModel
public LayerTreeModel(LayerList layerList)
Creates a newLayerTreeModelwith the default root node and adds a newLayerTreeNodefor each non-hiddenLayerin the specifiedlayerList. The tree will not include layers marked as hidden.- Parameters:
layerList- the list ofLayerobjects to the new model represents.- Throws:
java.lang.IllegalArgumentException- if thelayerListisnull.
-
LayerTreeModel
public LayerTreeModel(LayerList layerList, boolean includeHiddenLayers)
Creates a newLayerTreeModelwith the default root node and adds a newLayerTreeNodefor eachLayerin the specifiedlayerList.- Parameters:
layerList- the list ofLayerobjects to the new model represents.includeHiddenLayers- if this parameter istrue, layers marked as hidden will be included in the tree. Otherwise hidden layers will not be included in the tree.- Throws:
java.lang.IllegalArgumentException- if thelayerListisnull.
-
-
Method Detail
-
isIncludeHiddenLayers
public boolean isIncludeHiddenLayers()
Indicates whether or not this tree model includes layers marked as hidden.- Returns:
trueif hidden layers are included in the tree mode.falseif hidden layers are not included.
-
setIncludeHiddenLayers
public void setIncludeHiddenLayers(boolean includeHiddenLayers)
Specifies whether or not this tree model includes layers marked as hidden. Changes will take effect on the next call torefresh. A layer can be marked as hidden by setting the value for keyAVKey.HIDDENtotrue.- Parameters:
includeHiddenLayers-trueif the tree model should include hidden layers.falseif the model should ignore layers marked as hidden.
-
initialize
protected void initialize()
Initializes this tree model with the default root node.
-
createRootNode
protected TreeNode createRootNode()
Returns a new rootTreeNodefor this tree model. Called frominitialize.- Returns:
- a new
TreeNode.
-
addLayer
public void addLayer(LayerTreeNode layerNode)
Adds the specifiedlayerNodeto this tree model's root node. Nodes added under this tree model's root should always be of type. Note: this method adds the layer to the tree model regardless of whether or not the layer is marked as hidden.LayerTreeNode- Parameters:
layerNode- the layer node to add.- Throws:
java.lang.IllegalArgumentException- if thelayerNodeisnull.
-
addLayer
public LayerTreeNode addLayer(Layer layer)
Adds the a newLayerTreeNodecreated with the specifiedlayerto this tree model's root node. Nodes added under this tree model's root should always be of type. Note: this method adds the layer to the tree model regardless of whether or not the layer is marked as hidden.LayerTreeNode- Parameters:
layer- the layer to add.- Returns:
- the
LayerTreeNodecreated for the specifiedlayer. - Throws:
java.lang.IllegalArgumentException- if thelayerisnull.
-
createLayerNode
protected LayerTreeNode createLayerNode(Layer layer)
Returns a new rootLayerTreeNodefor the specifiedlayer. Called fromaddLayer(Layer).- Parameters:
layer- theLayerto create a newLayerTreeNodefor.- Returns:
- a new
LayerTreeNode.
-
removeAllLayers
public void removeAllLayers()
Clears this tree model by removing all children of the root node.
-
refresh
public void refresh(LayerList layerList)
Refreshes this tree model's layer nodes with the specifiedlayerList. Clears this tree model by removing all children of the root node, then adds a newLayerTreeNodefor eachLayerin the specifiedlayerList. Layers marked as hidden will not be included in the tree model, unless theincludeHiddenLayersproperty is set totrue.- Parameters:
layerList- the list ofLayerobjects to the new model represents.- Throws:
java.lang.IllegalArgumentException- if thelayerListisnull.- See Also:
setIncludeHiddenLayers(boolean)
-
mustIncludeLayer
protected boolean mustIncludeLayer(Layer layer)
Determines if a layer must be included in the layer tree.- Parameters:
layer- Layer to test.- Returns:
trueif the layer must be included in the tree,falseif the layer must not be included.
-
-