Diamond Control Suite 3.0

diamondedge.swing
Class DsTreeNode

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by diamondedge.swing.DsTreeNode
All Implemented Interfaces:
Serializable, Cloneable, MutableTreeNode, TreeNode

public class DsTreeNode
extends DefaultMutableTreeNode

A DsTreeNode is a node displayed in a DsTree component. All model in the tree must be of type DsTreeNode. For examples of using trees and tree model, see How to Use Trees in The Java Tutorial and the documentation on DefaultMutableTreeNode.

A tree node may have at most one parent and 0 or more children. DsTreeNode provides operations for examining and modifying a node's parent and children and also operations for examining the tree that the node is a part of. A node's tree is the set of all model that can be reached by starting at the node and following all the possible links to parents and children. A node with no parent is the root of its tree; a node with no children is a leaf. A tree may consist of many subtrees, each node acting as the root for its own subtree.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
  DsTreeNode()
           
  DsTreeNode(Object userObject)
          Creates a tree node with no parent, no children, but which allows children, and initializes it with the specified user object.
  DsTreeNode(Object userObject, boolean allowsChildren)
          Creates a tree node with no parent, no children, initialized with the specified user object, and that allows children only if specified.
  DsTreeNode(Object userObject, String key)
          Creates a tree node with no parent, no children, but which allows children, and initializes it with the specified user object.
protected DsTreeNode(Object userObject, String key, DsTreeModel model)
           
 
Method Summary
 boolean ensureVisible()
          Ensures a DsTreeNode object is visible, scrolling or expanding the control if necessary.
 Color getBackground()
          Returns the color that the background for a DsTreeNode object is displayed with.
 DsTreeNode getChild()
          Returns a reference to the first child of a DsTreeNode object.
 Object getData()
           
 DsTreeNode getFirstSibling()
          Returns a reference to the first DsTreeNode object in a hierarchy level.
 Font getFont()
           
 Color getForeground()
          Returns the color that the text for a DsTreeNode object is displayed with.
 String getFullPath()
          Returns the fully qualified name of a DsTreeNode object.
 int getHeight()
           
 Icon getIcon(int i)
           
 int getIndex()
          Returns the order that the node was added to the tree.
 String getKey()
          Returns the unique string of an object in a collection.
 DsTreeNode getLastSibling()
          Returns a reference to the last DsTreeNode object in a hierarchy level.
 DsTreeModel getModel()
           
 DsTreeNode getNext()
          Returns a reference to the next sibling DsTreeNode object in a hierarchy level.
 DsTreeNode getParentNode()
          Returns a reference to the previous DsTreeNode object in a hierarchy level.
 DsTreeNode getPrevious()
          Returns a reference to the previous sibling DsTreeNode object in a hierarchy level.
 DsTreeNode getRootNode()
          Returns a reference to the root DsTreeNode object of a DsTree control.
 int getSortOrder()
          Returns whether the children will be sorted in ascending or descending order.
 String getText()
          Returns the text to be displayed in a control.
 TreePath getTreePath()
           
 void insert(MutableTreeNode newChild, int childIndex)
           
 boolean isChecked()
          Returns a value that determines whether a DsTreeNode object is checked.
 boolean isExclusiveButton()
          Returns a value that determines whether a DsTreeNode object is displayed as an exclusive button.
 boolean isExpanded()
          Returns a value which specifies if a DsTreeNode object is expanded.
 boolean isFontBold()
          Returns a value that determines whether the text for a DsTreeNode object is displayed with a bold font.
 boolean isIconVisible()
          Returns a value that determines whether an icon is display for this DsTreeNode.
 boolean isSelected()
          Returns a value which determines if a DsTreeNode object is selected.
 boolean isSorted()
          Indicates whether the children of this node are automatically sorted alphabetically.
 boolean isToggleButton()
          Returns a value that determines whether a DsTreeNode object is displayed as a ToggleButton.
 boolean isVisible()
           
 void setBackground(Color c)
          Sets the color that the background for a DsTreeNode object is displayed with.
 void setChecked(boolean val)
          Sets a value that determines whether a DsTreeNode object is checked.
 void setData(Object obj)
           
 void setExclusiveButton(boolean val)
          Sets a value that determines whether a DsTreeNode object is displayed as an exclusive button.
 void setExpanded(boolean expand)
          Sets a value which specifies if a DsTreeNode object is expanded.
 void setFont(Font f)
          sets the font to be used for the node.
 void setFontBold(boolean val)
          Sets a value that determines whether the text for a DsTreeNode object is displayed with a bold font.
 void setForeground(Color c)
          Sets the color that the text for a DsTreeNode object is displayed with.
 void setHeight(int h)
          sets the row height for the node.
 void setIcon(int i, Object icon)
          set the given icon.
 void setIconVisible(boolean val)
          a value that determines whether an icon is display for this DsTreeNode.
 void setKey(String newkey)
          Sets the unique string of an object in a collection.
 void setModel(DsTreeModel newmodel)
           
 void setParent(MutableTreeNode newParent)
           
 void setSelected(boolean select)
          Sets a value which determines if a DsTreeNode object is selected.
 void setSorted(boolean sort)
          Indicates whether the children of this node are automatically sorted alphabetically.
 void setSortOrder(int sortOrder)
          Sets whether the children of this will be sorted in ascending or descending order.
 void setText(String s)
          Sets the UserObject to the given string.
 void setToggleButton(boolean val)
          Sets a value that determines whether a DsTreeNode object is displayed as a ToggleButton.
 void sort()
          Sorts the children by comparing values for the UserObject property using the SortOrder property.
 void sort(int sortOrder)
          Sorts the children by comparing values for the UserObject property.
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setUserObject, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DsTreeNode

public DsTreeNode()

DsTreeNode

public DsTreeNode(Object userObject)
Creates a tree node with no parent, no children, but which allows children, and initializes it with the specified user object.

Parameters:
userObject - the node's data (userObject.toString() is displayed)

DsTreeNode

public DsTreeNode(Object userObject,
                  boolean allowsChildren)
Creates a tree node with no parent, no children, initialized with the specified user object, and that allows children only if specified.

Parameters:
userObject - the node's data (userObject.toString() is displayed)
allowsChildren - if true, the node is allowed to have child nodes -- otherwise, it is always a leaf node

DsTreeNode

public DsTreeNode(Object userObject,
                  String key)
Creates a tree node with no parent, no children, but which allows children, and initializes it with the specified user object.

Parameters:
userObject - the node's data (userObject.toString() is displayed)
key - unique key used to lookup this node in the model

DsTreeNode

protected DsTreeNode(Object userObject,
                     String key,
                     DsTreeModel model)
Method Detail

getModel

public DsTreeModel getModel()

setModel

public void setModel(DsTreeModel newmodel)

getText

public String getText()
Returns the text to be displayed in a control. The text returned is from UserObject.toString()


setText

public void setText(String s)
Sets the UserObject to the given string.


getIcon

public Icon getIcon(int i)

setIcon

public void setIcon(int i,
                    Object icon)
set the given icon.

Parameters:
i - one of DsTree.LEAF_ICON, DsTree.OPENED_ICON, DsTree.CLOSED_ICON, DsTree.SELECTED_ICON, DsTree.TOGGLE_ICON, DsTree.TOGGLE_SEL_ICON
icon - an Integer object that is the index of the icon in the IconList collection with the DsTree or a String that is the key into the IconList collection or an Image object or an Icon object.

getFont

public Font getFont()

setFont

public void setFont(Font f)
sets the font to be used for the node. Set to null to use default font for tree.


getForeground

public Color getForeground()
Returns the color that the text for a DsTreeNode object is displayed with.


setForeground

public void setForeground(Color c)
Sets the color that the text for a DsTreeNode object is displayed with.


getBackground

public Color getBackground()
Returns the color that the background for a DsTreeNode object is displayed with.


setBackground

public void setBackground(Color c)
Sets the color that the background for a DsTreeNode object is displayed with.


getData

public Object getData()

setData

public void setData(Object obj)

getKey

public String getKey()
Returns the unique string of an object in a collection.


setKey

public void setKey(String newkey)
Sets the unique string of an object in a collection.


getHeight

public int getHeight()

setHeight

public void setHeight(int h)
sets the row height for the node. Set to 0 to use default height. Maximum value is 255.


isSorted

public boolean isSorted()
Indicates whether the children of this node are automatically sorted alphabetically.


setSorted

public void setSorted(boolean sort)
Indicates whether the children of this node are automatically sorted alphabetically.


getSortOrder

public int getSortOrder()
Returns whether the children will be sorted in ascending or descending order.


setSortOrder

public void setSortOrder(int sortOrder)
Sets whether the children of this will be sorted in ascending or descending order.

Parameters:
sortOrder - One of: DsConstants.ASCENDING, DsConstants.DESCENDING, DsConstants.ASCENDING_CASE, DsConstants.DESCENDING_CASE

sort

public void sort()
Sorts the children by comparing values for the UserObject property using the SortOrder property.

See Also:
setSortOrder(int)

sort

public void sort(int sortOrder)
Sorts the children by comparing values for the UserObject property.

Parameters:
sortOrder - One of: DsConstants.ASCENDING, DsConstants.DESCENDING, DsConstants.ASCENDING_CASE, DsConstants.DESCENDING_CASE

isFontBold

public boolean isFontBold()
Returns a value that determines whether the text for a DsTreeNode object is displayed with a bold font.


setFontBold

public void setFontBold(boolean val)
Sets a value that determines whether the text for a DsTreeNode object is displayed with a bold font.


isChecked

public boolean isChecked()
Returns a value that determines whether a DsTreeNode object is checked.


setChecked

public void setChecked(boolean val)
Sets a value that determines whether a DsTreeNode object is checked.


isToggleButton

public boolean isToggleButton()
Returns a value that determines whether a DsTreeNode object is displayed as a ToggleButton.


setToggleButton

public void setToggleButton(boolean val)
Sets a value that determines whether a DsTreeNode object is displayed as a ToggleButton. By default the button will be displayed as a CheckBox.


isExclusiveButton

public boolean isExclusiveButton()
Returns a value that determines whether a DsTreeNode object is displayed as an exclusive button. By default exclusive buttons are displayed as a RadioButton.


setExclusiveButton

public void setExclusiveButton(boolean val)
Sets a value that determines whether a DsTreeNode object is displayed as an exclusive button. By default exclusive buttons are displayed as a RadioButton.


isIconVisible

public boolean isIconVisible()
Returns a value that determines whether an icon is display for this DsTreeNode.


setIconVisible

public void setIconVisible(boolean val)
a value that determines whether an icon is display for this DsTreeNode.


isExpanded

public boolean isExpanded()
Returns a value which specifies if a DsTreeNode object is expanded.


setExpanded

public void setExpanded(boolean expand)
Sets a value which specifies if a DsTreeNode object is expanded.


isSelected

public boolean isSelected()
Returns a value which determines if a DsTreeNode object is selected.


setSelected

public void setSelected(boolean select)
Sets a value which determines if a DsTreeNode object is selected.


isVisible

public boolean isVisible()

ensureVisible

public boolean ensureVisible()
Ensures a DsTreeNode object is visible, scrolling or expanding the control if necessary.


getIndex

public int getIndex()
Returns the order that the node was added to the tree.


getFirstSibling

public DsTreeNode getFirstSibling()
Returns a reference to the first DsTreeNode object in a hierarchy level.


getLastSibling

public DsTreeNode getLastSibling()
Returns a reference to the last DsTreeNode object in a hierarchy level.


getChild

public DsTreeNode getChild()
Returns a reference to the first child of a DsTreeNode object. This is the same as getFirstChild() cast to a DsTreeNode.


getNext

public DsTreeNode getNext()
Returns a reference to the next sibling DsTreeNode object in a hierarchy level. This is the same as getNextSibling() cast to a DsTreeNode.


getPrevious

public DsTreeNode getPrevious()
Returns a reference to the previous sibling DsTreeNode object in a hierarchy level. This is the same as getPreviousSibling() cast to a DsTreeNode.


getParentNode

public DsTreeNode getParentNode()
Returns a reference to the previous DsTreeNode object in a hierarchy level. This is the same as getParent() cast to a DsTreeNode.


getRootNode

public DsTreeNode getRootNode()
Returns a reference to the root DsTreeNode object of a DsTree control. This is the same as getRoot() cast to a DsTreeNode.


getFullPath

public String getFullPath()
Returns the fully qualified name of a DsTreeNode object.


getTreePath

public TreePath getTreePath()

insert

public void insert(MutableTreeNode newChild,
                   int childIndex)
Specified by:
insert in interface MutableTreeNode
Overrides:
insert in class DefaultMutableTreeNode

setParent

public void setParent(MutableTreeNode newParent)
Specified by:
setParent in interface MutableTreeNode
Overrides:
setParent in class DefaultMutableTreeNode

Diamond Control Suite 3.0

Diamond Edge and Diamond Control Suite are trademarks or registered trademarks of Diamond Edge, Inc. Copyright 1999-2005 Diamond Edge, Inc. All Rights Reserved.