NASA World Wind

gov.nasa.worldwind.util.tree
Class BasicTree

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.util.tree.BasicTree
All Implemented Interfaces:
AVList, MessageListener, OrderedRenderable, PreRenderable, Renderable, Tree, WWObject, PropertyChangeListener, EventListener
Direct Known Subclasses:
LayerTree

public class BasicTree
extends WWObjectImpl
implements Tree, PreRenderable

Basic implementation of a Tree control.


Field Summary
protected  Set<TreePath> expandedNodes
           
protected  TreeLayout layout
           
protected  TreeModel model
           
 
Constructor Summary
BasicTree()
          Create an empty tree.
 
Method Summary
 void collapsePath(TreePath path)
          Collapse a path in the tree.
 void expandPath(TreePath path)
          Expand a path in the tree.
 double getDistanceFromEye()
          Returns the ordered renderable's distance from the current view's eye point.
 TreeLayout getLayout()
          Get the tree layout.
 TreeModel getModel()
          Get the tree model.
 TreeNode getNode(TreePath path)
          Locate a node in the tree.
 boolean isNodeExpanded(TreeNode node)
          Is a node expanded?
 boolean isPathExpanded(TreePath path)
          Is a path expanded in the tree?
 void makeVisible(TreePath path)
          Make a node in the tree visible in the rendered tree.
 void pick(DrawContext dc, Point pickPoint)
          Executes a pick of the ordered renderable.
 void preRender(DrawContext dc)
          
 void render(DrawContext dc)
          Causes this Renderable to render itself using the provided draw context.
 void setLayout(TreeLayout layout)
          Set the tree layout.
 void setModel(TreeModel model)
          Set the tree model.
 void togglePath(TreePath path)
          Expand a collapsed path, or collapse an expanded path.
 
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, 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 java.beans.PropertyChangeListener
propertyChange
 
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
 

Field Detail

expandedNodes

protected Set<TreePath> expandedNodes

layout

protected TreeLayout layout

model

protected TreeModel model
Constructor Detail

BasicTree

public BasicTree()
Create an empty tree.

Method Detail

collapsePath

public void collapsePath(TreePath path)
Collapse a path in the tree. Has no effect on leaf nodes.

Specified by:
collapsePath in interface Tree
Parameters:
path - Path to collapse.

expandPath

public void expandPath(TreePath path)
Expand a path in the tree. Has no effect on leaf nodes.

Specified by:
expandPath in interface Tree
Parameters:
path - Path to expand.

getDistanceFromEye

public double getDistanceFromEye()
Returns the ordered renderable's distance from the current view's eye point. Intended to be used only to sort a list of ordered renderables according to eye distance, and only during frame generation when a view is active.

Specified by:
getDistanceFromEye in interface OrderedRenderable
Returns:
the distance of the ordered renderable from the current view's eye point.

getLayout

public TreeLayout getLayout()
Get the tree layout. The layout determines how the tree will be rendered.

Specified by:
getLayout in interface Tree
Returns:
The tree layout.
See Also:
Tree.setLayout(TreeLayout)

getModel

public TreeModel getModel()
Get the tree model. The model determines the contents of the tree.

Specified by:
getModel in interface Tree
Returns:
the tree model.
See Also:
Tree.setModel(TreeModel)

getNode

public TreeNode getNode(TreePath path)
Locate a node in the tree.

Specified by:
getNode in interface Tree
Parameters:
path - Path to the node.
Returns:
Node identified by path if it exists in the tree.

isNodeExpanded

public boolean isNodeExpanded(TreeNode node)
Is a node expanded?

Specified by:
isNodeExpanded in interface Tree
Parameters:
node - Node to test.
Returns:
true if the node is expanded, false if collapsed. Always returns false for leaf nodes.

isPathExpanded

public boolean isPathExpanded(TreePath path)
Is a path expanded in the tree?

Specified by:
isPathExpanded in interface Tree
Parameters:
path - Path to test.
Returns:
true if the path is expanded, false if collapsed. Always returns false for leaf nodes.

makeVisible

public void makeVisible(TreePath path)
Make a node in the tree visible in the rendered tree. For example, scroll the tree viewport so that a path is visible.

Specified by:
makeVisible in interface Tree
Parameters:
path - Path to make visible.

pick

public void pick(DrawContext dc,
                 Point pickPoint)
Executes a pick of the ordered renderable.

Specified by:
pick in interface OrderedRenderable
Parameters:
dc - the current draw context.
pickPoint - the pick point.

preRender

public void preRender(DrawContext dc)

Specified by:
preRender in interface PreRenderable

render

public void render(DrawContext dc)
Causes this Renderable to render itself using the provided draw context.

Specified by:
render in interface Renderable
Parameters:
dc - the DrawContext to be used
See Also:
DrawContext

setLayout

public void setLayout(TreeLayout layout)
Set the tree layout. The layout determines how the tree will be rendered.

Specified by:
setLayout in interface Tree
Parameters:
layout - New layout.
See Also:
Tree.getLayout()

setModel

public void setModel(TreeModel model)
Set the tree model. The model determines the contents of the tree.

Specified by:
setModel in interface Tree
Parameters:
model - New tree model.
See Also:
Tree.getModel()

togglePath

public void togglePath(TreePath path)
Expand a collapsed path, or collapse an expanded path. Has no effect on leaf nodes.

Specified by:
togglePath in interface Tree
Parameters:
path - Path to operate on. If the node defined by path is expanded, it will be collapsed. If it is collapsed it will be expanded.

NASA World Wind