org.geotoolkit.gui.swing.tree
Class DefaultMutableTreeNode

Object
  extended by DefaultMutableTreeNode
      extended by DefaultMutableTreeNode
All Implemented Interfaces:
Serializable, Cloneable, MutableTreeNode, TreeNode, Localized
Direct Known Subclasses:
NamedTreeNode

public class DefaultMutableTreeNode
extends DefaultMutableTreeNode
implements MutableTreeNode, Localized

General-purpose node in a tree data structure. This default implementation implements the Geotk MutableTreeNode interface, which inherits a getUserObject() method. This method is provided in the Swing DefaultMutableTreeNode implementation but seems to have been forgotten in all Swing interfaces.

In addition, the toString() method has been overridden in order to process InternationalString specially: if the value returned by getLocale() is non-null, then that value is used for getting a String from the InternationalString object.

Since:
2.0
Version:
3.17
Author:
Martin Desruisseaux (IRD, Geomatys)
See Also:
Serialized Form
Module:
utility/geotk-utility (download)    View source code for this class

Field Summary
 
Fields inherited from class DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
DefaultMutableTreeNode()
          Creates a tree node that has no parent and no children, but which allows children.
DefaultMutableTreeNode(Object userObject)
          Creates a tree node with no parent, no children, but which allows children, and initializes it with the specified user object.
DefaultMutableTreeNode(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.
 
Method Summary
 Enumeration<? extends TreeNode> children()
          Returns the children of this node as an Enumeration.
 Locale getLocale()
          Returns the locale to use for the value returned by toString().
 String toString()
          Returns the string value of the user object, or null if none.
 
Methods inherited from class DefaultMutableTreeNode
add, breadthFirstEnumeration, 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, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface MutableTreeNode
insert, remove, remove, removeFromParent, setParent, setUserObject
 
Methods inherited from interface TreeNode
getUserObject
 
Methods inherited from interface TreeNode
getAllowsChildren, getChildAt, getChildCount, getIndex, getParent, isLeaf
 

Constructor Detail

DefaultMutableTreeNode

public DefaultMutableTreeNode()
Creates a tree node that has no parent and no children, but which allows children.


DefaultMutableTreeNode

public DefaultMutableTreeNode(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 - an Object provided by the user that constitutes the node's data

DefaultMutableTreeNode

public DefaultMutableTreeNode(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 - an Object provided by the user that constitutes the node's data
allowsChildren - if true, the node is allowed to have child nodes -- otherwise, it is always a leaf node
Method Detail

children

public Enumeration<? extends TreeNode> children()
Returns the children of this node as an Enumeration.

Specified by:
children in interface TreeNode
Overrides:
children in class DefaultMutableTreeNode
Returns:
The children.

getLocale

public Locale getLocale()
Returns the locale to use for the value returned by toString(). The default implementation returns the locale of the parent, if any, or null otherwise.

Specified by:
getLocale in interface Localized
Returns:
The locale, or null if not explicitly defined.
Since:
3.17

toString

public String toString()
Returns the string value of the user object, or null if none. This method is invoked by JTree for populating the tree widget. The string can be localized if the following conditions are meet:

In such case, this method returns the value of InternationalString.toString(Locale).

Overrides:
toString in class DefaultMutableTreeNode
Returns:
The localized string value of the user object, or null if none.


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.