com.badlogic.gdx.scenes.scene2d.ui
Class Tree

java.lang.Object
  extended by com.badlogic.gdx.scenes.scene2d.Actor
      extended by com.badlogic.gdx.scenes.scene2d.Group
          extended by com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
              extended by com.badlogic.gdx.scenes.scene2d.ui.Tree
All Implemented Interfaces:
Cullable, Layout

public class Tree
extends WidgetGroup

A tree widget where each node has an icon, actor, and child nodes.

The preferred size of the tree is determined by the preferred size of the actors for the expanded nodes.

ChangeListener.ChangeEvent is fired when the selected node changes.

Author:
Nathan Sweet

Nested Class Summary
static class Tree.Node
           
static class Tree.TreeStyle
          The style for a Tree.
 
Constructor Summary
Tree(Skin skin)
           
Tree(Skin skin, String styleName)
           
Tree(Tree.TreeStyle style)
           
 
Method Summary
 void add(Tree.Node node)
           
 void addSelection(Tree.Node node)
           
 void clearChildren()
          Removes all tree nodes.
 void clearSelection()
           
 void collapseAll()
           
 void draw(SpriteBatch batch, float parentAlpha)
          If this method is overridden, the super method or WidgetGroup.validate() should be called to ensure the widget group is laid out.
 void expandAll()
           
 void findExpandedObjects(Array objects)
           
 Tree.Node findNode(Object object)
          Returns the node with the specified object, or null.
 ClickListener getClickListener()
          Returns the click listener the tree uses for clicking on nodes and the over node.
 Tree.Node getNodeAt(float y)
           
 Array<Tree.Node> getNodes()
           
 Tree.Node getOverNode()
           
 float getPrefHeight()
           
 float getPrefWidth()
           
 Array<Tree.Node> getRootNodes()
           
 Array<Tree.Node> getSelection()
           
 Tree.TreeStyle getStyle()
           
 void insert(int index, Tree.Node node)
           
 void invalidate()
          Invalidates this actor's layout, causing Layout.layout() to happen the next time Layout.validate() is called.
 void layout()
          Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, calls Layout.invalidate() any each child whose width or height has changed, and calls Layout.validate() on each child.
 void remove(Tree.Node node)
           
 void restoreExpandedObjects(Array objects)
           
 void setIconSpacing(float left, float right)
          Sets the amount of horizontal space between the node actors and icons.
 void setMultiSelect(boolean multiSelect)
           
 void setOverNode(Tree.Node overNode)
           
 void setPadding(float padding)
          Sets the amount of horizontal space between the nodes and the left/right edges of the tree.
 void setSelection(Array<Tree.Node> nodes)
           
 void setSelection(Tree.Node node)
           
 void setStyle(Tree.TreeStyle style)
           
 void setToggleSelect(boolean toggleSelect)
           
 void setYSpacing(float ySpacing)
          Sets the amount of vertical space between nodes.
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, validate
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Group
act, addActor, addActorAfter, addActorAt, addActorBefore, clear, findActor, getChildren, hasChildren, hit, isTransform, localToDescendantCoordinates, print, removeActor, setCullingArea, setTransform, swapActor, swapActor
 
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
addAction, addCaptureListener, addListener, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, fire, getActions, getCaptureListeners, getColor, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getWidth, getX, getY, getZIndex, hasParent, isAscendantOf, isDescendantOf, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotate, scale, scale, screenToLocalCoordinates, setBounds, setColor, setColor, setHeight, setName, setOrigin, setOriginX, setOriginY, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setVisible, setWidth, setX, setY, setZIndex, size, size, stageToLocalCoordinates, toBack, toFront, toString, translate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Tree

public Tree(Skin skin)

Tree

public Tree(Skin skin,
            String styleName)

Tree

public Tree(Tree.TreeStyle style)
Method Detail

setStyle

public void setStyle(Tree.TreeStyle style)

add

public void add(Tree.Node node)

insert

public void insert(int index,
                   Tree.Node node)

remove

public void remove(Tree.Node node)

clearChildren

public void clearChildren()
Removes all tree nodes.

Overrides:
clearChildren in class Group

getNodes

public Array<Tree.Node> getNodes()

invalidate

public void invalidate()
Description copied from interface: Layout
Invalidates this actor's layout, causing Layout.layout() to happen the next time Layout.validate() is called. This method should be called when state changes in the actor that requires a layout but does not change the minimum, preferred, maximum, or actual size of the actor (meaning it does not affect the parent actor's layout).

Specified by:
invalidate in interface Layout
Overrides:
invalidate in class WidgetGroup

layout

public void layout()
Description copied from interface: Layout
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, calls Layout.invalidate() any each child whose width or height has changed, and calls Layout.validate() on each child. This method should almost never be called directly, instead Layout.validate() should be used.

Specified by:
layout in interface Layout
Overrides:
layout in class WidgetGroup

draw

public void draw(SpriteBatch batch,
                 float parentAlpha)
Description copied from class: WidgetGroup
If this method is overridden, the super method or WidgetGroup.validate() should be called to ensure the widget group is laid out.

Overrides:
draw in class WidgetGroup
parentAlpha - Should be multiplied with the actor's alpha, allowing a parent's alpha to affect all children.

getNodeAt

public Tree.Node getNodeAt(float y)
Returns:
May be null.

getSelection

public Array<Tree.Node> getSelection()

setSelection

public void setSelection(Tree.Node node)

setSelection

public void setSelection(Array<Tree.Node> nodes)

addSelection

public void addSelection(Tree.Node node)

clearSelection

public void clearSelection()

getStyle

public Tree.TreeStyle getStyle()

getRootNodes

public Array<Tree.Node> getRootNodes()

getOverNode

public Tree.Node getOverNode()

setOverNode

public void setOverNode(Tree.Node overNode)

setPadding

public void setPadding(float padding)
Sets the amount of horizontal space between the nodes and the left/right edges of the tree.


setYSpacing

public void setYSpacing(float ySpacing)
Sets the amount of vertical space between nodes.


setIconSpacing

public void setIconSpacing(float left,
                           float right)
Sets the amount of horizontal space between the node actors and icons.


getPrefWidth

public float getPrefWidth()
Specified by:
getPrefWidth in interface Layout
Overrides:
getPrefWidth in class WidgetGroup

getPrefHeight

public float getPrefHeight()
Specified by:
getPrefHeight in interface Layout
Overrides:
getPrefHeight in class WidgetGroup

findExpandedObjects

public void findExpandedObjects(Array objects)

restoreExpandedObjects

public void restoreExpandedObjects(Array objects)

findNode

public Tree.Node findNode(Object object)
Returns the node with the specified object, or null.


collapseAll

public void collapseAll()

expandAll

public void expandAll()

getClickListener

public ClickListener getClickListener()
Returns the click listener the tree uses for clicking on nodes and the over node.


setMultiSelect

public void setMultiSelect(boolean multiSelect)

setToggleSelect

public void setToggleSelect(boolean toggleSelect)


Copyright © 2013. All Rights Reserved.