Package com.prineside.tdi2.scene2d.ui
Class Tree<N extends Tree.Node,V>
java.lang.Object
com.prineside.tdi2.scene2d.Actor
com.prineside.tdi2.scene2d.Group
com.prineside.tdi2.scene2d.ui.WidgetGroup
com.prineside.tdi2.scene2d.ui.Tree<N,V>
- Type Parameters:
N
- The type of nodes in the tree.V
- The type of values for each node.
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
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
clearChildren
(boolean unfocus) Removes all tree nodes.void
void
If this method is overridden, the super method orWidgetGroup.validate()
should be called to ensure the widget group is laid out.void
void
findExpandedValues
(Array<V> values) Returns the node with the specified value, or null.Returns the click listener the tree uses for clicking on nodes and the over node.float
Returns the amount of horizontal space for indentation level.getNodeAt
(float y) getNodes()
Deprecated.float
float
If the order of the root nodes is changed,updateRootNodes()
must be called to ensure the nodes' actors are in the correct order.Returns the first selected node, or null.Returns the first selected value, or null.getStyle()
float
void
void
Invalidates this actor's layout, causingLayout.layout()
to happen the next timeLayout.validate()
is called.void
layout()
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child, callsLayout.invalidate()
on any each child whose width or height has changed, and callsLayout.validate()
on each child.void
void
restoreExpandedValues
(Array<V> values) void
setIconSpacing
(float left, float right) Sets the amount of horizontal space left and right of the node's icon.void
setIndentSpacing
(float indentSpacing) void
setOverNode
(N overNode) void
setPadding
(float padding) Sets the amount of horizontal space between the nodes and the left/right edges of the tree.void
setPadding
(float left, float right) Sets the amount of horizontal space between the nodes and the left/right edges of the tree.void
setStyle
(Tree.TreeStyle style) void
setYSpacing
(float ySpacing) Sets the amount of vertical space between nodes.void
Updates the order of the actors in the tree for all root nodes and all child nodes.Methods inherited from class com.prineside.tdi2.scene2d.ui.WidgetGroup
getMaxHeight, getMaxHeightValue, getMaxWidth, getMaxWidthValue, getMinHeight, getMinHeightValue, getMinWidth, getMinWidthValue, getPrefHeightValue, getPrefWidthValue, hit, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setPrefHeight, setPrefHeight, setPrefWidth, setPrefWidth, setWidth, validate
Methods inherited from class com.prineside.tdi2.scene2d.Group
act, addActor, addActorAfter, addActorAt, addActorBefore, clear, clear, clearChildren, debugAll, drawDebug, findActor, getChild, getChildren, getCullingArea, hasChildren, isTransform, localToDescendantCoordinates, removeActor, removeActor, removeActorAt, setCullingArea, setDebug, setTransform, swapActor, swapActor, toString
Methods inherited from class com.prineside.tdi2.scene2d.Actor
addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotateBy, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
-
Constructor Details
-
Tree
-
-
Method Details
-
setStyle
-
add
-
insert
-
remove
-
clearChildren
public void clearChildren(boolean unfocus) Removes all tree nodes.- Overrides:
clearChildren
in classGroup
-
invalidate
public void invalidate()Description copied from interface:Layout
Invalidates this actor's layout, causingLayout.layout()
to happen the next timeLayout.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 interfaceLayout
- Overrides:
invalidate
in classWidgetGroup
-
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, callsLayout.invalidate()
on any each child whose width or height has changed, and callsLayout.validate()
on each child. This method should almost never be called directly, insteadLayout.validate()
should be used.- Specified by:
layout
in interfaceLayout
- Overrides:
layout
in classWidgetGroup
-
draw
Description copied from class:WidgetGroup
If this method is overridden, the super method orWidgetGroup.validate()
should be called to ensure the widget group is laid out.- Overrides:
draw
in classWidgetGroup
parentAlpha
- The parent alpha, to be multiplied with this actor's alpha, allowing the parent's alpha to affect all children.
-
getNodeAt
- Returns:
- May be null.
-
getSelection
-
getSelectedNode
Returns the first selected node, or null. -
getSelectedValue
Returns the first selected value, or null. -
getStyle
-
getRootNodes
If the order of the root nodes is changed,updateRootNodes()
must be called to ensure the nodes' actors are in the correct order. -
getNodes
Deprecated.UsegetRootNodes()
. -
updateRootNodes
public void updateRootNodes()Updates the order of the actors in the tree for all root nodes and all child nodes. This is useful after changing the order ofgetRootNodes()
.- See Also:
-
getOverNode
- Returns:
- May be null.
-
getOverValue
- Returns:
- May be null.
-
setOverNode
- Parameters:
overNode
- May be null.
-
setPadding
public void setPadding(float padding) Sets the amount of horizontal space between the nodes and the left/right edges of the tree. -
setPadding
public void setPadding(float left, float right) Sets the amount of horizontal space between the nodes and the left/right edges of the tree. -
setIndentSpacing
public void setIndentSpacing(float indentSpacing) -
getIndentSpacing
public float getIndentSpacing()Returns the amount of horizontal space for indentation level. -
setYSpacing
public void setYSpacing(float ySpacing) Sets the amount of vertical space between nodes. -
getYSpacing
public float getYSpacing() -
setIconSpacing
public void setIconSpacing(float left, float right) Sets the amount of horizontal space left and right of the node's icon. If a node has no icon, the left spacing is used between the plus/minus drawable and the node's actor. -
getPrefWidth
public float getPrefWidth()- Specified by:
getPrefWidth
in interfaceLayout
- Overrides:
getPrefWidth
in classWidgetGroup
-
getPrefHeight
public float getPrefHeight()- Specified by:
getPrefHeight
in interfaceLayout
- Overrides:
getPrefHeight
in classWidgetGroup
-
findExpandedValues
-
restoreExpandedValues
-
findNode
Returns the node with the specified value, or null. -
collapseAll
public void collapseAll() -
expandAll
public void expandAll() -
getClickListener
Returns the click listener the tree uses for clicking on nodes and the over node.
-
getRootNodes()
.