Package gov.nasa.worldwind.util.tree
Class BasicTree
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.util.tree.BasicTree
-
- All Implemented Interfaces:
AVList
,MessageListener
,OrderedRenderable
,PreRenderable
,Renderable
,Tree
,WWObject
,java.beans.PropertyChangeListener
,java.util.EventListener
- Direct Known Subclasses:
LayerTree
public class BasicTree extends WWObjectImpl implements Tree, PreRenderable
Basic implementation of aTree
control.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<TreePath>
expandedNodes
protected TreeLayout
layout
protected TreeModel
model
-
Constructor Summary
Constructors Constructor Description BasicTree()
Create an empty tree.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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, java.awt.Point pickPoint)
Executes a pick of the ordered renderable.void
preRender(DrawContext dc)
void
render(DrawContext dc)
Causes thisRenderable
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, 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
-
layout
protected TreeLayout layout
-
model
protected TreeModel model
-
expandedNodes
protected java.util.Set<TreePath> expandedNodes
-
-
Method Detail
-
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 interfaceTree
- Parameters:
path
- Path to make visible.
-
expandPath
public void expandPath(TreePath path)
Expand a path in the tree. Has no effect on leaf nodes.- Specified by:
expandPath
in interfaceTree
- Parameters:
path
- Path to expand.
-
collapsePath
public void collapsePath(TreePath path)
Collapse a path in the tree. Has no effect on leaf nodes.- Specified by:
collapsePath
in interfaceTree
- Parameters:
path
- Path to collapse.
-
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 interfaceTree
- Parameters:
path
- Path to operate on. If the node defined bypath
is expanded, it will be collapsed. If it is collapsed it will be expanded.
-
isPathExpanded
public boolean isPathExpanded(TreePath path)
Is a path expanded in the tree?- Specified by:
isPathExpanded
in interfaceTree
- Parameters:
path
- Path to test.- Returns:
- true if the path is expanded, false if collapsed. Always returns false for leaf nodes.
-
isNodeExpanded
public boolean isNodeExpanded(TreeNode node)
Is a node expanded?- Specified by:
isNodeExpanded
in interfaceTree
- Parameters:
node
- Node to test.- Returns:
- true if the node is expanded, false if collapsed. Always returns false for leaf nodes.
-
preRender
public void preRender(DrawContext dc)
- Specified by:
preRender
in interfacePreRenderable
-
render
public void render(DrawContext dc)
Causes thisRenderable
to render itself using the provided draw context.- Specified by:
render
in interfaceRenderable
- Parameters:
dc
- theDrawContext
to be used- See Also:
DrawContext
-
pick
public void pick(DrawContext dc, java.awt.Point pickPoint)
Executes a pick of the ordered renderable.- Specified by:
pick
in interfaceOrderedRenderable
- Parameters:
dc
- the current draw context.pickPoint
- the pick point.
-
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 interfaceOrderedRenderable
- 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 interfaceTree
- Returns:
- The tree layout.
- See Also:
Tree.setLayout(TreeLayout)
-
setLayout
public void setLayout(TreeLayout layout)
Set the tree layout. The layout determines how the tree will be rendered.- Specified by:
setLayout
in interfaceTree
- Parameters:
layout
- New layout.- See Also:
Tree.getLayout()
-
getModel
public TreeModel getModel()
Get the tree model. The model determines the contents of the tree.- Specified by:
getModel
in interfaceTree
- Returns:
- the tree model.
- See Also:
Tree.setModel(TreeModel)
-
setModel
public void setModel(TreeModel model)
Set the tree model. The model determines the contents of the tree.- Specified by:
setModel
in interfaceTree
- Parameters:
model
- New tree model.- See Also:
Tree.getModel()
-
-