public class Tree
extends java.lang.Object
implements javax.swing.tree.TreeModel, java.lang.Cloneable
| Modifier and Type | Field and Description |
|---|---|
protected javax.swing.tree.MutableTreeNode |
root
The root of this tree.
|
| Constructor and Description |
|---|
Tree(javax.swing.tree.MutableTreeNode root)
Constructs the tree by defining the root.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTreeModelListener(javax.swing.event.TreeModelListener l)
Adds a tree mode listener.
|
Tree |
clone()
A deep clone of this tree.
|
boolean |
equals(java.lang.Object otherTree)
Checks this tree for equality with another tree.
|
void |
exchangeNodes(javax.swing.tree.MutableTreeNode own,
javax.swing.tree.MutableTreeNode other,
Tree otherTree)
Exchanges the subtree at node 'own' from this tree with another subtree given by 'other'.
|
javax.swing.tree.TreeNode |
getChild(java.lang.Object parent,
int index)
Returns the child of a parent node at the given index.
|
int |
getChildCount(java.lang.Object parent)
Returns the number of children of the parent.
|
int |
getIndexOfChild(java.lang.Object parent,
java.lang.Object child)
Returns the index of a parent's child.
|
java.lang.Object |
getRoot()
Returns the root node.
|
int |
hashCode()
Returns a hash code for the tree by using the nodes' hashCode().
|
boolean |
isLeaf(java.lang.Object node)
Returns if the given node is a leaf node.
|
TreeIterator |
iterator()
Returns a tree iterator for this tree.
|
void |
removeTreeModelListener(javax.swing.event.TreeModelListener l)
Removes a tree mode listener.
|
void |
replaceNode(javax.swing.tree.MutableTreeNode own,
javax.swing.tree.MutableTreeNode other)
Replaces the subtree at node 'own' from this tree with another subtree given by 'other'.
|
void |
setRoot(javax.swing.tree.MutableTreeNode node)
Sets the root node.
|
int |
size()
Returns the number of nodes in this tree.
|
java.lang.String |
toString()
Returns the string representation of this tree in Polish notation.
|
void |
valueForPathChanged(javax.swing.tree.TreePath path,
java.lang.Object newValue)
Receives notification of a node change.
|
public Tree(javax.swing.tree.MutableTreeNode root)
root - the root nodepublic Tree clone()
clone in class java.lang.Objectpublic boolean equals(java.lang.Object otherTree)
equals in class java.lang.ObjectotherTree - another treepublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.Object getRoot()
getRoot in interface javax.swing.tree.TreeModelpublic void setRoot(javax.swing.tree.MutableTreeNode node)
node - a tree nodepublic javax.swing.tree.TreeNode getChild(java.lang.Object parent,
int index)
getChild in interface javax.swing.tree.TreeModelparent - a parent nodeindex - the index of the childpublic int getChildCount(java.lang.Object parent)
getChildCount in interface javax.swing.tree.TreeModelparent - a parent nodepublic int getIndexOfChild(java.lang.Object parent,
java.lang.Object child)
getIndexOfChild in interface javax.swing.tree.TreeModelparent - a parent nodechild - a child node of the parentpublic boolean isLeaf(java.lang.Object node)
isLeaf in interface javax.swing.tree.TreeModelnode - a tree nodepublic void valueForPathChanged(javax.swing.tree.TreePath path,
java.lang.Object newValue)
valueForPathChanged in interface javax.swing.tree.TreeModelpath - a tree path to the changed nodenewValue - the new value for the changed nodepublic void addTreeModelListener(javax.swing.event.TreeModelListener l)
addTreeModelListener in interface javax.swing.tree.TreeModell - a tree model listenerpublic void removeTreeModelListener(javax.swing.event.TreeModelListener l)
removeTreeModelListener in interface javax.swing.tree.TreeModell - a tree model listenerpublic TreeIterator iterator()
public int size()
public void replaceNode(javax.swing.tree.MutableTreeNode own,
javax.swing.tree.MutableTreeNode other)
own - a node in this tree to be replaced, may be rootother - a node from another tree to replace 'own', may be rootpublic void exchangeNodes(javax.swing.tree.MutableTreeNode own,
javax.swing.tree.MutableTreeNode other,
Tree otherTree)
own - a node in this tree to be exchanged, may be rootother - a node from another tree to be exchanged, may be roototherTree - the other treepublic java.lang.String toString()
toString in class java.lang.Object