edu.northwestern.at.utils.swing
Class SortedTreeNode

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by edu.northwestern.at.utils.swing.SortedTreeNode
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode

public abstract class SortedTreeNode
extends javax.swing.tree.DefaultMutableTreeNode

Sorted tree node.

This class extends DefaultMutableTreeNode to support sorted tree nodes.

The class is abstract. You must subclass it and implement the compareTo method to compare nodes for sorting.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
SortedTreeNode()
           
 
Method Summary
 void add(javax.swing.tree.MutableTreeNode newChild)
          Prohibits attempts to add nodes that aren't sortable.
 int add(SortedTreeNode newChild)
          Adds a new child node, in the proper sorted position.
abstract  int compareTo(SortedTreeNode otherNode)
          Compares this node to some other node.
 int getNodeCount()
          Gets the node count.
 void insert(javax.swing.tree.MutableTreeNode newChild, int childIndex)
          Prohibits attempts to add children at specific locations.
 void remove(javax.swing.tree.MutableTreeNode aChild)
          Prohibits attempts to remove nodes that aren't sortable.
 void remove(SortedTreeNode aChild)
          Removes a child node.
 void setUserObject(java.lang.Object userObject)
          Prohibits attempts to set a new user object.
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
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, removeAllChildren, removeFromParent, setAllowsChildren, setParent, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SortedTreeNode

public SortedTreeNode()
Method Detail

compareTo

public abstract int compareTo(SortedTreeNode otherNode)
Compares this node to some other node.

Parameters:
otherNode - The other node.
Returns:
< 0 if this < other, 0 if this = other, > 0 if this > other.

add

public int add(SortedTreeNode newChild)
Adds a new child node, in the proper sorted position.

Parameters:
newChild - The new child node.
Returns:
The index in the parent node where the new child was inserted.

remove

public void remove(SortedTreeNode aChild)
Removes a child node.

Parameters:
aChild - The child node.

getNodeCount

public int getNodeCount()
Gets the node count.

Returns:
The total number of nodes in the subtree rooted at this node, not counting the node itself.

add

public void add(javax.swing.tree.MutableTreeNode newChild)
Prohibits attempts to add nodes that aren't sortable.

Overrides:
add in class javax.swing.tree.DefaultMutableTreeNode
Throws:
UnsupportedOperationException.

remove

public void remove(javax.swing.tree.MutableTreeNode aChild)
Prohibits attempts to remove nodes that aren't sortable.

Specified by:
remove in interface javax.swing.tree.MutableTreeNode
Overrides:
remove in class javax.swing.tree.DefaultMutableTreeNode
Throws:
UnsupportedOperationException.

insert

public void insert(javax.swing.tree.MutableTreeNode newChild,
                   int childIndex)
Prohibits attempts to add children at specific locations.

Specified by:
insert in interface javax.swing.tree.MutableTreeNode
Overrides:
insert in class javax.swing.tree.DefaultMutableTreeNode
Throws:
java.lang.UnsupportedOperationException

setUserObject

public void setUserObject(java.lang.Object userObject)
Prohibits attempts to set a new user object.

Specified by:
setUserObject in interface javax.swing.tree.MutableTreeNode
Overrides:
setUserObject in class javax.swing.tree.DefaultMutableTreeNode
Throws:
java.lang.UnsupportedOperationException