|
.useful Home Page | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.tree.DefaultMutableTreeNode org.dotuseful.ui.tree.AutomatedTreeNode org.dotuseful.ui.tree.SortedTreeNode
A tree node which keeps its children sorted. It must be supplied with
Comparator
by which the list is ordered, or its children must
implement Comparable
interface.
SortedTreeNode
must be notified on its child's change which
could have effect on child's sorting order. SortedTreeNode
must be notified on change BEFORE some other operation which depend on
children order or could have effect on sorting order.
Field Summary | |
protected java.util.Comparator |
comparator
The Comparator by which the list is ordered. |
Fields inherited from class org.dotuseful.ui.tree.AutomatedTreeNode |
listenerList |
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode |
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject |
Constructor Summary | |
SortedTreeNode()
Creates a SortedTreeNode that has no parent and no
children, but which allows children. |
|
SortedTreeNode(java.lang.Object userObject)
Creates a SortedTreeNode node with no parent, no children,
but which allows children, and initializes it with the specified user
object. |
|
SortedTreeNode(java.lang.Object userObject,
boolean allowsChildren)
Creates a SortedTreeNode with no parent, no children,
initialized with the specified user object, and that allows children only
if specified. |
|
SortedTreeNode(java.lang.Object userObject,
boolean allowsChildren,
java.util.Comparator newComparator)
Creates a SortedTreeNode with no parent, no children,
initialized with the specified user object, that allows children only if
specified, and sets the comparator by which its children are ordered. |
|
SortedTreeNode(java.lang.Object userObject,
java.util.Comparator newComparator)
Creates a SortedTreeNode node with no parent, no children,
but which allows children, initializes it with the specified user object,
and sets the comparator by which its children are ordered. |
Method Summary | |
void |
add(javax.swing.tree.MutableTreeNode newChild)
Removes newChild from its parent and makes it a child of
this node by adding it to this node's child array in a sorted order. |
void |
setComparator(java.util.Comparator newComparator)
Sets the comparator for this node to newComparator , and
re-sorts children. |
protected void |
sortChildren(java.lang.Object[] changedChildren)
Keeps children in sorted order by removing given children and adding them back. |
void |
treeNodesChanged(javax.swing.event.TreeModelEvent e)
The node need to re-sort its changed children. |
void |
treeStructureChanged(javax.swing.event.TreeModelEvent e)
The node need to re-sort its changed children. |
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 |
Field Detail |
protected java.util.Comparator comparator
Comparator
by which the list is ordered.
Constructor Detail |
public SortedTreeNode()
SortedTreeNode
that has no parent and no
children, but which allows children. Its children must implement
Comparable
interface if no comparator is set.
public SortedTreeNode(java.lang.Object userObject)
SortedTreeNode
node with no parent, no children,
but which allows children, and initializes it with the specified user
object. Its children must implement Comparable
interface
if no comparator is set.
userObject
- an Object provided by the user that constitutes the node's
datapublic SortedTreeNode(java.lang.Object userObject, boolean allowsChildren)
SortedTreeNode
with no parent, no children,
initialized with the specified user object, and that allows children only
if specified. Its children must implement Comparable
interface if no comparator is set.
userObject
- an Object provided by the user that constitutes the node's
dataallowsChildren
- if true, the node is allowed to have child nodes -- otherwise,
it is always a leaf nodepublic SortedTreeNode(java.lang.Object userObject, java.util.Comparator newComparator)
SortedTreeNode
node with no parent, no children,
but which allows children, initializes it with the specified user object,
and sets the comparator by which its children are ordered.
userObject
- an Object provided by the user that constitutes the node's
datanewComparator
- The comparator by which its children are ordered. A
null value indicates that the elements' natural
ordering should be used.public SortedTreeNode(java.lang.Object userObject, boolean allowsChildren, java.util.Comparator newComparator)
SortedTreeNode
with no parent, no children,
initialized with the specified user object, that allows children only if
specified, and sets the comparator by which its children are ordered.
userObject
- an Object provided by the user that constitutes the node's
dataallowsChildren
- if true, the node is allowed to have child nodes -- otherwise,
it is always a leaf nodenewComparator
- The comparator by which its children are ordered. A
null value indicates that the elements' natural
ordering should be used.Method Detail |
public void setComparator(java.util.Comparator newComparator)
newComparator
, and
re-sorts children.
newComparator
- The comparator to set.public void add(javax.swing.tree.MutableTreeNode newChild)
newChild
from its parent and makes it a child of
this node by adding it to this node's child array in a sorted order.
newChild
- node to add as a child of this node
java.lang.IllegalArgumentException
- if newChild
is null
java.lang.IllegalStateException
- if this node does not allow childrenAutomatedTreeNode.insert(javax.swing.tree.MutableTreeNode, int)
public void treeNodesChanged(javax.swing.event.TreeModelEvent e)
treeNodesChanged
in interface javax.swing.event.TreeModelListener
treeNodesChanged
in class AutomatedTreeNode
public void treeStructureChanged(javax.swing.event.TreeModelEvent e)
treeStructureChanged
in interface javax.swing.event.TreeModelListener
treeStructureChanged
in class AutomatedTreeNode
protected void sortChildren(java.lang.Object[] changedChildren)
Keeps children in sorted order by removing given children and adding them back.
|
© 2004 .useful community | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |