Package arc.scene.ui

Class TreeElement

All Implemented Interfaces:
Cullable

public class TreeElement extends WidgetGroup
A tree widget where each node has an icon, element, and child nodes.

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

ChangeListener.ChangeEvent is fired when the selected node changes.

  • Constructor Details

  • Method Details

    • add

      public void add(TreeElement.TreeElementNode node)
    • insert

      public void insert(int index, TreeElement.TreeElementNode node)
    • remove

      public void remove(TreeElement.TreeElementNode node)
    • clearChildren

      public void clearChildren()
      Removes all tree nodes.
      Overrides:
      clearChildren in class Group
    • getNodes

      public Seq<TreeElement.TreeElementNode> getNodes()
    • invalidate

      public void invalidate()
      Description copied from class: Element
      Invalidates this actor's layout, causing Element.layout() to happen the next time Element.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).
      Overrides:
      invalidate in class WidgetGroup
    • layout

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

      public void draw()
      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
    • drawBackground

      protected void drawBackground()
      Called to draw the background. Default implementation draws the style background drawable.
    • getNodeAt

      public TreeElement.TreeElementNode getNodeAt(float y)
      Returns:
      May be null.
    • getSelection

      public Selection<TreeElement.TreeElementNode> getSelection()
    • getStyle

      public TreeElement.TreeStyle getStyle()
    • setStyle

      public void setStyle(TreeElement.TreeStyle style)
    • getRootNodes

      public Seq<TreeElement.TreeElementNode> getRootNodes()
    • getOverNode

      public TreeElement.TreeElementNode getOverNode()
      Returns:
      May be null.
    • setOverNode

      public void setOverNode(TreeElement.TreeElementNode overNode)
      Parameters:
      overNode - May be null.
    • getOverObject

      public Object getOverObject()
      Returns:
      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.
    • getIndentSpacing

      public float getIndentSpacing()
      Returns the amount of horizontal space for indentation level.
    • getYSpacing

      public float getYSpacing()
    • 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 elements and icons.
    • getPrefWidth

      public float getPrefWidth()
      Overrides:
      getPrefWidth in class WidgetGroup
    • getPrefHeight

      public float getPrefHeight()
      Overrides:
      getPrefHeight in class WidgetGroup
    • findExpandedObjects

      public void findExpandedObjects(Seq objects)
    • restoreExpandedObjects

      public void restoreExpandedObjects(Seq objects)
    • findNode

      public TreeElement.TreeElementNode 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.