Class Tree.Node<N extends Tree.Node,V,A extends Actor>

java.lang.Object
com.prineside.tdi2.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.
Enclosing class:
Tree<N extends Tree.Node,V>

public abstract static class Tree.Node<N extends Tree.Node,V,A extends Actor> extends Object
A Tree node which has an actor and value.

A subclass can be used so the generic type parameters don't need to be specified repeatedly.

Author:
Nathan Sweet
  • Constructor Details

    • Node

      public Node(A actor)
    • Node

      public Node()
      Creates a node without an actor. An actor must be set using setActor(Actor) before this node can be used.
  • Method Details

    • setExpanded

      public void setExpanded(boolean expanded)
    • add

      public void add(N node)
    • addAll

      public void addAll(Array<N> nodes)
    • 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 of getChildren().
      See Also:
    • getParent

      @Null public N getParent()
      Returns:
      May be null.
    • setIcon

      public void setIcon(@Null Drawable icon)
      Sets an icon that will be drawn to the left of the actor.
    • getValue

      @Null public V getValue()
    • setValue

      public void setValue(@Null V value)
      Sets an application specific value for this node.
    • getIcon

      @Null public Drawable getIcon()
    • 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)
    • findExpandedValues

      public void findExpandedValues(Array<V> values)
    • restoreExpandedValues

      public void restoreExpandedValues(Array<V> values)
    • 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.