org.openbp.swing.components.treetable
Class DefaultTreeTableNode

java.lang.Object
  extended by org.openbp.swing.components.treetable.DefaultTreeTableNode
All Implemented Interfaces:
javax.swing.tree.TreeNode, TreeTableNode

public class DefaultTreeTableNode
extends java.lang.Object
implements TreeTableNode

Default implementation for the TreeTableNode, which is used in conjunction with the DefaultTreeTableModel

Author:
Erich Lauterbach

Field Summary
protected  java.util.Vector children
          TreeTableNode children.
protected  java.util.List columnObjects
          The column objects.
static javax.swing.JLabel EMPTY_COLUMN
          Empty label that is used to replace the object contained in the column vector, when that object is removed.
protected  DefaultTreeTableNode parent
          The Parent TreeTableNode to this one.
protected  java.awt.Dimension preferredSize
          The preferred size for this node.
 
Constructor Summary
DefaultTreeTableNode()
           
 
Method Summary
 void addChild(DefaultTreeTableNode child)
          Adds a TreeTable node as an child of the receiver node.
 void addColumn(java.lang.Object columnValue)
          Adds a column object to this node.
 java.util.Enumeration children()
          Returns the children of the receiver as an Enumeration.
 boolean getAllowsChildren()
          Returns true if the receiver allows children.
 javax.swing.tree.TreeNode getChildAt(int childIndex)
          Returns the child TreeNode at index childIndex.
 int getChildCount()
          Returns the number of children TreeNodes the receiver contains.
 int getColumnCount()
          Returns the number of column objects contained in the receiver node.
 java.lang.Object getColumnValue(int index)
          Returns the column value for a specified index for the receiver node.
 int getIndex(javax.swing.tree.TreeNode node)
          Returns the index of node in the receivers children.
 int getLastHeight()
          Returns the lastHeight used by the JTreeTable
 java.lang.String getNodeText()
          Gets the text field to be displayed for the node.
 javax.swing.tree.TreeNode getParent()
          Returns the parent TreeNode of the receiver.
 java.awt.Dimension getPreferredSize()
          Gets the preferred height of the node in the tree.
 void insertChild(DefaultTreeTableNode child, int index)
          Adds a child at the given index.
 boolean isLeaf()
          Determines if the receiver node is a leaf.
 boolean removeChild(DefaultTreeTableNode child)
          Removes the child node from the receiver node.
 void removeChildren()
          Removes all child nodes from the receiver node.
 boolean removeColumn(java.lang.Object columnValue)
          Removes a column object from this node.
 void setColumnValue(int index, java.lang.Object columnValue)
          Sets the object contained by column with specified index with the specified object.
 void setLastHeight(int lastHeight)
          Sets the lastHeight by the JTreeTable This method should never be called directly and is actually only meant for internal use by the JTreeTable
 void setParent(DefaultTreeTableNode parent)
          Set the parent node for the receiver node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_COLUMN

public static final javax.swing.JLabel EMPTY_COLUMN
Empty label that is used to replace the object contained in the column vector, when that object is removed. This is done so that the vector does not adjust its length, and thus move all trailing columns when a column object is removed from the vector.


columnObjects

protected java.util.List columnObjects
The column objects.


preferredSize

protected java.awt.Dimension preferredSize
The preferred size for this node.


children

protected java.util.Vector children
TreeTableNode children.


parent

protected DefaultTreeTableNode parent
The Parent TreeTableNode to this one.

Constructor Detail

DefaultTreeTableNode

public DefaultTreeTableNode()
Method Detail

getNodeText

public java.lang.String getNodeText()
Gets the text field to be displayed for the node.

Specified by:
getNodeText in interface TreeTableNode
Returns:
The string value of the text

getPreferredSize

public java.awt.Dimension getPreferredSize()
Gets the preferred height of the node in the tree.

Specified by:
getPreferredSize in interface TreeTableNode
Returns:
The height as an int in pixels

getChildAt

public javax.swing.tree.TreeNode getChildAt(int childIndex)
Returns the child TreeNode at index childIndex.

Specified by:
getChildAt in interface javax.swing.tree.TreeNode
Parameters:
childIndex - The index of the child of interest
Returns:
The javax.swing.tree.TreeNode child.

getChildCount

public int getChildCount()
Returns the number of children TreeNodes the receiver contains.

Specified by:
getChildCount in interface javax.swing.tree.TreeNode
Returns:
The number of children contained in receiver javax.swing.tree.TreeNode.

getParent

public javax.swing.tree.TreeNode getParent()
Returns the parent TreeNode of the receiver.

Specified by:
getParent in interface javax.swing.tree.TreeNode
Returns:
The parent javax.swing.tree.TreeNode.

getIndex

public int getIndex(javax.swing.tree.TreeNode node)
Returns the index of node in the receivers children. If the receiver does not contain node, -1 will be returned.

Specified by:
getIndex in interface javax.swing.tree.TreeNode
Parameters:
node - The node for which the index is required
Returns:
The index of the node of interest. If the node is non-existing, the -1 is returned.

getAllowsChildren

public boolean getAllowsChildren()
Returns true if the receiver allows children. In the case of the DefaultTreeTable node it always allows children, thus always returns true.

Specified by:
getAllowsChildren in interface javax.swing.tree.TreeNode
Returns:
true if the receiver node allows children,
false if no children are allowed.

isLeaf

public boolean isLeaf()
Determines if the receiver node is a leaf.

Specified by:
isLeaf in interface javax.swing.tree.TreeNode
Returns:
true if the receiver node is a leaf.
false is the receiver node is NOT a leaf.

children

public java.util.Enumeration children()
Returns the children of the receiver as an Enumeration. If the receiver does not contain any children the an empty enumeration is returned.

Specified by:
children in interface javax.swing.tree.TreeNode
Returns:
All the children contained in the receiver node as an Enumeration

addChild

public void addChild(DefaultTreeTableNode child)
Adds a TreeTable node as an child of the receiver node.

Parameters:
child - The child node to be added

removeChild

public boolean removeChild(DefaultTreeTableNode child)
Removes the child node from the receiver node.

Parameters:
child - The child node to be removed
Returns:
True if the child was successfully removed.
False if an error occurred while removing the child.

removeChildren

public void removeChildren()
Removes all child nodes from the receiver node.


insertChild

public void insertChild(DefaultTreeTableNode child,
                        int index)
Adds a child at the given index. child will be messaged with setParent.

Parameters:
child - The DefaultTreeTableNode child node to be added
index - The index where the child is to be added

setParent

public void setParent(DefaultTreeTableNode parent)
Set the parent node for the receiver node.

Parameters:
parent - The parent DefaultTreeTableNode

addColumn

public void addColumn(java.lang.Object columnValue)
Adds a column object to this node. Use this mehtod to add a value to the node.

Parameters:
columnValue - The column object to be added

removeColumn

public boolean removeColumn(java.lang.Object columnValue)
Removes a column object from this node.

Parameters:
columnValue - The column object to be removed
Returns:
True if the object was successfully removed. False if object was NOT successfully removed.

setColumnValue

public void setColumnValue(int index,
                           java.lang.Object columnValue)
Sets the object contained by column with specified index with the specified object. Overwrites the value in the node. ATTENTION: The value must be set before, the column has to be added before by calling the addColumn(java.lang.Object) method.

Parameters:
index - The column index
columnValue - The new object to be set for the specified column index

getColumnValue

public java.lang.Object getColumnValue(int index)
Returns the column value for a specified index for the receiver node.

Specified by:
getColumnValue in interface TreeTableNode
Parameters:
index - The column index
Returns:
The object contained in that column for this node. If no objext is available, then a null is returned.

getColumnCount

public int getColumnCount()
Returns the number of column objects contained in the receiver node.

Returns:
The number of column objects

getLastHeight

public int getLastHeight()
Returns the lastHeight used by the JTreeTable

Specified by:
getLastHeight in interface TreeTableNode
Returns:
The last height used

setLastHeight

public void setLastHeight(int lastHeight)
Sets the lastHeight by the JTreeTable This method should never be called directly and is actually only meant for internal use by the JTreeTable

Specified by:
setLastHeight in interface TreeTableNode
Parameters:
lastHeight - The lastHeight to set


Copyright © 2011. All Rights Reserved.