Class Tree.Node<N extends Tree.Node,V,A extends Actor>
- java.lang.Object
-
- com.badlogic.gdx.scenes.scene2d.ui.Tree.Node<N,V,A>
-
- Type Parameters:
N- The type for the node's parent and child nodes.V- The type for the node's value.A- The type for the node's actor.
public abstract static class Tree.Node<N extends Tree.Node,V,A extends Actor> extends java.lang.ObjectATreenode which has an actor and value.A subclass can be used so the generic type parameters don't need to be specified repeatedly.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(N node)voidaddAll(Array<N> nodes)protected intaddToTree(Tree<N,V> tree, int actorIndex)Called to add the actor to the tree when the node's parent is expanded.voidclearChildren()Removes all children from this node.voidcollapseAll()Collapses all nodes under and including this node.voidexpandAll()Expands all nodes under and including this node.voidexpandTo()Expands all parent nodes of this node.voidfindExpandedValues(Array<V> values)NfindNode(V value)Returns this node or the child node with the specified value, or null.AgetActor()Array<N>getChildren()If the children order is changed,updateChildren()must be called to ensure the node's actors are in the correct order.floatgetHeight()Returns the height of the node as calculated for layout.DrawablegetIcon()intgetLevel()NgetParent()Tree<N,V>getTree()Returns the tree this node's actor is currently in, or null.VgetValue()booleanhasChildren()voidinsert(int childIndex, N node)booleanisAscendantOf(N node)Returns true if the specified node is this node or an ascendant of this node.booleanisDescendantOf(N node)Returns true if the specified node is this node or an descendant of this node.booleanisExpanded()booleanisSelectable()voidremove()Remove this node from its parent.voidremove(N node)Remove the specified child node from this node.protected voidremoveFromTree(Tree<N,V> tree, int actorIndex)Called to remove the actor from the tree, eg when the node is removed or the node's parent is collapsed.voidrestoreExpandedValues(Array<V> values)voidsetActor(A newActor)voidsetExpanded(boolean expanded)voidsetIcon(Drawable icon)Sets an icon that will be drawn to the left of the actor.voidsetSelectable(boolean selectable)voidsetValue(V value)Sets an application specific value for this node.voidupdateChildren()Updates the order of the actors in the tree for this node and all child nodes.
-
-
-
Constructor Detail
-
Node
public Node(A actor)
-
Node
public Node()
Creates a node without an actor. An actor must be set usingsetActor(Actor)before this node can be used.
-
-
Method Detail
-
setExpanded
public void setExpanded(boolean expanded)
-
addToTree
protected int addToTree(Tree<N,V> tree, int actorIndex)
Called to add the actor to the tree when the node's parent is expanded.- Returns:
- The number of node actors added to the tree.
-
removeFromTree
protected void removeFromTree(Tree<N,V> tree, int actorIndex)
Called to remove the actor from the tree, eg when the node is removed or the node's parent is collapsed.
-
add
public void add(N node)
-
insert
public void insert(int childIndex, N node)
-
remove
public void remove()
Remove this node from its parent.
-
remove
public void remove(N node)
Remove the specified child node from this node. Does nothing if the node is not a child of this node.
-
clearChildren
public void clearChildren()
Removes all children from this node.
-
getTree
@Null public Tree<N,V> getTree()
Returns the tree this node's actor is currently in, or null. The actor is only in the tree when all of its parent nodes are expanded.
-
setActor
public void setActor(A newActor)
-
getActor
public A getActor()
-
isExpanded
public boolean isExpanded()
-
getChildren
public Array<N> getChildren()
If the children order is changed,updateChildren()must be called to ensure the node's actors are in the correct order. That is not necessary if this node is not in the tree or is not expanded, because then the child node's actors are not in the tree.
-
hasChildren
public boolean hasChildren()
-
updateChildren
public void updateChildren()
Updates the order of the actors in the tree for this node and all child nodes. This is useful after changing the order ofgetChildren().- See Also:
Tree.updateRootNodes()
-
setIcon
public void setIcon(@Null Drawable icon)
Sets an icon that will be drawn to the left of the actor.
-
getLevel
public int getLevel()
-
findNode
@Null public N findNode(V value)
Returns this node or the child node with the specified value, or null.
-
collapseAll
public void collapseAll()
Collapses all nodes under and including this node.
-
expandAll
public void expandAll()
Expands all nodes under and including this node.
-
expandTo
public void expandTo()
Expands all parent nodes of this node.
-
isSelectable
public boolean isSelectable()
-
setSelectable
public void setSelectable(boolean selectable)
-
getHeight
public float getHeight()
Returns the height of the node as calculated for layout. A subclass may override and increase the returned height to create a blank space in the tree above the node, eg for a separator.
-
isAscendantOf
public boolean isAscendantOf(N node)
Returns true if the specified node is this node or an ascendant of this node.
-
isDescendantOf
public boolean isDescendantOf(N node)
Returns true if the specified node is this node or an descendant of this node.
-
-