com.dlsc.flexgantt.swing.treetable
Class TreeTableNode

java.lang.Object
  extended by com.dlsc.flexgantt.swing.treetable.TreeTableNode

public class TreeTableNode
extends java.lang.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
protected  TreeTableNode[] children
          The array of children entries.
protected  TreeTableNode parent
          Reference to the parent table entry.
 
Constructor Summary
protected TreeTableNode(TreeTable table, java.lang.Object modelNode)
          Constructs a new tree table node.
 
Method Summary
protected  void collapse()
          Tells the entry to be closed.
protected  void expand()
          Tells the entry to be open.
 java.lang.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(java.lang.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.
 java.lang.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.
 java.lang.Object getModelNode()
          Returns the model node object that is wrapped by the tree table node.
 TreeTableNode getParentNode()
          Returns the parent node of the node.
 javax.swing.tree.TreePath getPath()
          Returns a tree path for the node.
 int getRow()
          Returns the row of the entry inside the table.
 TreeTable getTreeTable()
          Returns the tree table in which the node gets displayed.
 java.lang.Object getValueAt(int index)
          Returns the column value of the wrapped model node for the given model index.
 int getY()
          Returns the y-coordiante 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.
protected  void load()
          Loads the children nodes from the model, wraps each one of them and adds them to this node.
protected  void setDepth(int depth)
          Sets the depth of the node within the hierarchy.
protected  void setHeight(int height)
          Sets the row height of the node.
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,
                        java.lang.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

getModelNode

public java.lang.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 javax.swing.tree.TreePath getPath()
Returns a tree path for the node.

Returns:
the node's tree path
Since:
1.0

getValueAt

public java.lang.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 java.lang.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 java.lang.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(java.lang.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

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

setHeight

protected void setHeight(int height)
Sets the row height of the node.

Parameters:
height - the node's row height
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-coordiante 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