com.dlsc.flexgantt.swing.treetable

## Class TreeTableNode

- java.lang.Object
- - com.dlsc.flexgantt.swing.treetable.TreeTableNode

-     public class TreeTableNode
      extends Object

  This class is primarily used internally by the `TreeTable` to store the state of its tree nodes. Objects of this class wrap the actual model nodes. The class caches its children so that the nodes in the tree keep their expand / collapse state even when new nodes are inserted.
  Since:
    1.0
  Author:
    Dirk Lemmermann

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected TreeTableNode[]` | `children` The array of children entries.
    `protected TreeTableNode` | `parent` Reference to the parent table entry.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `TreeTableNode(TreeTable table, Object modelNode)` Constructs a new tree table node.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `collapse()` Tells the entry to be closed.
    `protected void` | `expand()` Tells the entry to be open.
    `Object` | `getChildAt(int index)` Returns the child for the given child index.
    `int` | `getChildCount()` Returns the total number of child nodes attached to the node.
    `TreeTableNode` | `getChildNode(Object modelChildNode)` Returns the wrapping tree table node for the given model node.
    `TreeTableNode[]` | `getChildren()` Returns the array of child nodes.
    `int` | `getDepth()` Returns the depth of the node within the hierarchy.
    `int` | `getHeight()` Returns the row height of the node.
    `Object` | `getKey()` Returns the key value of the wrapped model node.
    `ITreeTableModel` | `getModel()` Returns the model to which the node (or the wrapped model node) belongs.
    `Object` | `getModelNode()` Returns the model node object that is wrapped by the tree table node.
    `Object` | `getNewParentForIndentation()` Returns the model node that will be the new parent of this node when it gets indented.
    `Object` | `getNewParentForOutdentation()` Returns the model node that will be the new parent of this node when it gets outdentend.
    `TreeTableNode` | `getParentNode()` Returns the parent node of the node.
    `TreePath` | `getPath()` Returns a tree path for the node.
    `int` | `getRow()` Returns the row of the entry inside the table.
    `int` | `getTotalChildrenCount()` Calculates the total number of all children rows.
    `int` | `getTotalChildrenHeight()` Calculates the total height of all children rows.
    `TreeTable` | `getTreeTable()` Returns the tree table in which the node gets displayed.
    `Object` | `getValueAt(int index)` Returns the column value of the wrapped model node for the given model index.
    `int` | `getY()` Returns the y-coordinate of the row in which the node gets displayed.
    `boolean` | `isExpanded()` Determines if the node is currently expanded.
    `boolean` | `isLeaf()` Determines if the tree node is a leaf, which means that the node does not have any child nodes attached to it.
    `boolean` | `isLoaded()` Determines if the node has already loaded its child elements.
    `boolean` | `isNewEntryPlaceholder()` Determines if the node is the one that gets used to create new nodes.
    `boolean` | `isSelected()` Determines if the node is currently selected.
    `protected void` | `load()` Loads the children nodes from the model, wraps each one of them and adds them to this node.
    `protected void` | `load(Map<Object,TreeTableNode> tableCache)` Loads the children nodes from the model, wraps each one of them and adds them to this node.
    `protected void` | `resetTotals()` Resets the totals for the cached values "children height" and "children count".
    `protected void` | `setDepth(int depth)` Sets the depth of the node within the hierarchy.
    `protected void` | `setParent(TreeTableNode parent)` Sets the node's parent node.
    `protected void` | `setRow(int row)` Sets the row index on the node.
    `protected void` | `setY(int y)` Sets the y-coordiante of the row in which the node gets displayed.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### parent

          protected TreeTableNode parent

      Reference to the parent table entry.
      Since:
        1.0

    - #### children

          protected TreeTableNode[] children

      The array of children entries.
      Since:
        1.0

  - ### Constructor Detail

    - #### TreeTableNode

          protected TreeTableNode(TreeTable table,
                                  Object modelNode)

      Constructs a new tree table node.
      Parameters:
        `table` - the table in which the node gets shown
        `modelNode` - the wrapped model node
      Since:
        1.0

  - ### Method Detail

    - #### isNewEntryPlaceholder

          public boolean isNewEntryPlaceholder()

      Determines if the node is the one that gets used to create new nodes. The default return value is FALSE.
      Returns:
        TRUE if the node is the placeholder where the user can create new nodes in the table
      Since:
        1.0

    - #### getTreeTable

          public TreeTable getTreeTable()

      Returns the tree table in which the node gets displayed.
      Returns:
        the tree table component in which the node gets rendered
      Since:
        1.0

    - #### getModel

          public ITreeTableModel getModel()

      Returns the model to which the node (or the wrapped model node) belongs.
      Returns:
        the model to which the node (or the wrapped model node) belongs
      Since:
        1.0

    - #### isLoaded

          public boolean isLoaded()

      Determines if the node has already loaded its child elements.
      Returns:
        TRUE if the children nodes have been loaded
      Since:
        1.0

    - #### load

          protected void load()

      Loads the children nodes from the model, wraps each one of them and adds them to this node.
      Since:
        1.0

    - #### load

          protected void load(Map<Object,TreeTableNode> tableCache)

      Loads the children nodes from the model, wraps each one of them and adds them to this node.
      Parameters:
        `tableCache` - the table can provide a cache of tree table nodes that can be reused (e.g. after drag and drop operations within the same table)
      Since:
        1.1

    - #### getModelNode

          public Object getModelNode()

      Returns the model node object that is wrapped by the tree table node.
      Returns:
        the model node object
      Since:
        1.0

    - #### getPath

          public TreePath getPath()

      Returns a tree path for the node.
      Returns:
        the node's tree path
      Since:
        1.0

    - #### getValueAt

          public Object getValueAt(int index)

      Returns the column value of the wrapped model node for the given model index.
      Parameters:
        `index` - the model index
      Returns:
        the column value for the given model index
      Since:
        1.0
      See Also:
        `ITreeTableModel.getColumnValue(Object, int)`

    - #### getKey

          public Object getKey()

      Returns the key value of the wrapped model node.
      Returns:
        the key value of the wrapped model node
      Since:
        1.0
      See Also:
        `ITreeTableModel.getKey(Object)`

    - #### setDepth

          protected void setDepth(int depth)

      Sets the depth of the node within the hierarchy. The depth is equivalent to the length of the tree path.
      Parameters:
        `depth` - the depth of the node within the hierarchy
      Since:
        1.0
      See Also:
        `getPath()`

    - #### getDepth

          public int getDepth()

      Returns the depth of the node within the hierarchy. The depth is equivalent to the length of the tree path.
      Returns:
        the depth of the node within the hierarchy
      Since:
        1.0
      See Also:
        `getPath()`

    - #### setParent

          protected void setParent(TreeTableNode parent)

      Sets the node's parent node.
      Parameters:
        `parent` - the parent node of the node
      Since:
        1.0

    - #### getParentNode

          public TreeTableNode getParentNode()

      Returns the parent node of the node.
      Returns:
        the node's parent node
      Since:
        1.0

    - #### isLeaf

          public boolean isLeaf()

      Determines if the tree node is a leaf, which means that the node does not have any child nodes attached to it.
      Returns:
        TRUE if the node is a leaf node without children
      Since:
        1.0

    - #### getChildCount

          public int getChildCount()

      Returns the total number of child nodes attached to the node.
      Returns:
        the total number of child nodes attached to the node
      Since:
        1.0
      See Also:
        `TreeModel.getChildCount(Object)`

    - #### getChildAt

          public Object getChildAt(int index)

      Returns the child for the given child index.
      Parameters:
        `index` - the index for which to return the child node
      Returns:
        the child for the given child index
      Since:
        1.0
      See Also:
        `TreeModel.getChild(Object, int)`

    - #### getChildren

          public TreeTableNode[] getChildren()

      Returns the array of child nodes. Each one of them wraps a model child node.
      Returns:
        the child nodes of the node
      Since:
        1.0

    - #### getChildNode

          public TreeTableNode getChildNode(Object modelChildNode)

      Returns the wrapping tree table node for the given model node.
      Parameters:
        `modelChildNode` - the model child node for which to return the wrapping tree table node
      Returns:
        the wrapping tree table node for the given model node
      Since:
        1.0

    - #### expand

          protected void expand()

      Tells the entry to be open. This method is called from the tree table.
      Since:
        1.0

    - #### collapse

          protected void collapse()

      Tells the entry to be closed. This method is called from the tree table.
      Since:
        1.0

    - #### isExpanded

          public boolean isExpanded()

      Determines if the node is currently expanded.
      Returns:
        TRUE if the node is expanded
      Since:
        1.0

    - #### isSelected

          public boolean isSelected()

      Determines if the node is currently selected.
      Returns:
        TRUE if the node is selected
      Since:
        1.1

    - #### setRow

          protected void setRow(int row)

      Sets the row index on the node.
      Parameters:
        `row` - the node's row index
      Since:
        1.0

    - #### getRow

          public int getRow()

      Returns the row of the entry inside the table. The row can vary over time depending on whether or not other nodes inside the table are open or closed. Also dragging and dropping can alter the row. The row of the table root entry is 0. The children of the root entry start at 1.
      Returns:
        the node's row index
      Since:
        1.0

    - #### getHeight

          public int getHeight()

      Returns the row height of the node.
      Returns:
        the node's row height
      Since:
        1.0

    - #### setY

          protected void setY(int y)

      Sets the y-coordiante of the row in which the node gets displayed.
      Parameters:
        `y` - the y-coordinate of the node's row
      Since:
        1.0

    - #### getY

          public int getY()

      Returns the y-coordinate of the row in which the node gets displayed.
      Returns:
        the y-coordinate of the row in which the node gets displayed
      Since:
        1.0

    - #### getTotalChildrenHeight

          public int getTotalChildrenHeight()

      Calculates the total height of all children rows. This value is important in the context of tree node animation (expand / collapse).
      Returns:
        the total height of the children rows
      Since:
        2.0

    - #### getTotalChildrenCount

          public int getTotalChildrenCount()

      Calculates the total number of all children rows. This value is important in the context of tree node animation (expand / collapse).
      Returns:
        the total height of the children rows
      Since:
        2.0

    - #### resetTotals

          protected void resetTotals()

      Resets the totals for the cached values "children height" and "children count".
      Since:
        2.0

    - #### getNewParentForIndentation

          public Object getNewParentForIndentation()

      Returns the model node that will be the new parent of this node when it gets indented.
      Returns:
        the candidate parent for indentation.
      Since:
        2.0

    - #### getNewParentForOutdentation

          public Object getNewParentForOutdentation()

      Returns the model node that will be the new parent of this node when it gets outdentend.
      Returns:
        the candidate parent for outdentation.
      Since:
        2.0

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.