vipratech.beans.standardbeans
Class TreeNode

java.lang.Object
  |
  +--vipratech.beans.standardbeans.TreeNode

public class TreeNode
extends java.lang.Object
implements java.io.Serializable

This is a single node in the TreeView panel. It displays text and optionally one of two images depending on its state, collapsed or expanded. It also may have an object associated with it that doesn't get displayed.

See Also:
TreeView, Serialized Form

Constructor Summary
TreeNode()
          Constructs a default TreeNode.
TreeNode(java.lang.String text, java.awt.Image collapsedImage, java.awt.Image expandedImage, TreeView treeView)
          Constructs a TreeNode with the given text label, and collapsed and expanded images.
TreeNode(java.lang.String text, TreeView treeView)
          Constructs a TreeNode with the given text label.
 
Method Summary
 void collapse()
          Sets a flag indicating that this node is not expanded.
 void expand()
          Sets a flag indicating that this node is expanded, if it is expandable.
 TreeNode getChild()
          Gets the child of this node.
 java.lang.Object getDataObject()
          Gets the object associated with this node.
 int getDepth()
          Gets the depth of this node as previously noted.
 java.awt.Image getImage()
          Gets the proper image for this node in its current state, expanded or collapsed.
 TreeNode getParent()
          Gets the parent of this node.
 TreeNode getSibling()
          Gets the next sibling of this node.
 java.lang.String getText()
          Gets the current text label for this node.
 boolean isExpandable()
          Determines whether this node is expandable.
 boolean isExpanded()
          Determines whether this node is expanded.
 void setCollapsedImage(java.awt.Image image)
          Sets the image to use for this node when it is not expanded.
 void setDataObject(java.lang.Object theObject)
          Sets an object to associate with this node.
 void setExpandedImage(java.awt.Image image)
          Sets the image to use for this node when it is expanded.
 void setText(java.lang.String s)
          Sets a new text label for this node.
 void toggle()
          Toggles the node state between collapsed and expanded, if the node is expandable.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeNode

public TreeNode()
Constructs a default TreeNode.

TreeNode

public TreeNode(java.lang.String text,
                TreeView treeView)
Constructs a TreeNode with the given text label.
Parameters:
text - the text to display for this node
treeView - the instance of TreeView whose node this is. Typically "this"

TreeNode

public TreeNode(java.lang.String text,
                java.awt.Image collapsedImage,
                java.awt.Image expandedImage,
                TreeView treeView)
Constructs a TreeNode with the given text label, and collapsed and expanded images.
Parameters:
text - the text to display for this node
collapsedImage - the image to use when this node is collapsed, hiding all of its child nodes
expandedImage - the image to use when this node is expanded, showing all of its child nodes
treeView - the instance of TreeView whose node this is. Typically "this"
Method Detail

getDepth

public int getDepth()
Gets the depth of this node as previously noted.
Returns:
the depth of this node

isExpanded

public boolean isExpanded()
Determines whether this node is expanded. A node is expanded if its child nodes are visible.
Returns:
true if the node is expanded, false if it is collapsed

isExpandable

public boolean isExpandable()
Determines whether this node is expandable. A node is expandable if it has one or more child nodes.
Returns:
true if the node is expandable, false if not

expand

public void expand()
Sets a flag indicating that this node is expanded, if it is expandable.

collapse

public void collapse()
Sets a flag indicating that this node is not expanded.

toggle

public void toggle()
Toggles the node state between collapsed and expanded, if the node is expandable.

getImage

public java.awt.Image getImage()
Gets the proper image for this node in its current state, expanded or collapsed.
Returns:
the current image for this node in its current state

setExpandedImage

public void setExpandedImage(java.awt.Image image)
Sets the image to use for this node when it is expanded.
Parameters:
image - the image to use when this node is expanded
See Also:
setCollapsedImage(java.awt.Image), getImage()

setCollapsedImage

public void setCollapsedImage(java.awt.Image image)
Sets the image to use for this node when it is not expanded.
Parameters:
image - the image to use when this node is collapsed
See Also:
setExpandedImage(java.awt.Image), getImage()

getText

public java.lang.String getText()
Gets the current text label for this node.
Returns:
the current text label for this node
See Also:
setText(java.lang.String)

setText

public void setText(java.lang.String s)
Sets a new text label for this node.
Parameters:
s - the new text label for this node
See Also:
getText()

getDataObject

public java.lang.Object getDataObject()
Gets the object associated with this node. This object does not get displayed.
Returns:
the object associated with this node
See Also:
setDataObject(java.lang.Object)

setDataObject

public void setDataObject(java.lang.Object theObject)
Sets an object to associate with this node. This object does not get displayed.
Parameters:
theObject - an object to associate with this node
See Also:
getDataObject()

getParent

public TreeNode getParent()
Gets the parent of this node.
Returns:
this node's parent node
See Also:
getChild(), getSibling()

getChild

public TreeNode getChild()
Gets the child of this node.
Returns:
this node's child node
See Also:
getParent(), getSibling()

getSibling

public TreeNode getSibling()
Gets the next sibling of this node.
Returns:
this node's next sibling node
See Also:
getChild(), getParent()

dathe@chemie.uni-leipzig.de"

http://leipzig.vernetztes-studium.de