|
Treeviz 0.37 2010-10-17 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectch.randelshofer.tree.TreePath2<T>
public class TreePath2<T>
Reimplementation of javax.swing.TreePath2 with supports for generics.
| Constructor Summary | |
|---|---|
protected |
TreePath2()
Primarily provided for subclasses that represent paths in a different manner. |
|
TreePath2(T singlePath)
Constructs a TreePath2 containing only a single element. |
|
TreePath2(T[] path)
Constructs a path from an array of Objects, uniquely identifying the path from the root of the tree to a specific node, as returned by the tree's data model. |
protected |
TreePath2(T[] path,
int length)
Constructs a new TreePath2 with the identified path components of length length. |
protected |
TreePath2(TreePath2<T> parent,
T lastElement)
Constructs a new TreePath2, which is the path identified by parent ending in lastElement. |
| Method Summary | |
|---|---|
boolean |
equals(java.lang.Object o)
Tests two TreePaths for equality by checking each element of the paths for equality. |
T |
getLastPathComponent()
Returns the last component of this path. |
TreePath2 |
getParentPath()
Returns a path containing all the elements of this object, except the last path component. |
T[] |
getPath()
Returns an ordered array of Objects containing the components of this TreePath2. |
T |
getPathComponent(int element)
Returns the path component at the specified index. |
int |
getPathCount()
Returns the number of elements in the path. |
int |
hashCode()
Returns the hashCode for the object. |
boolean |
isDescendant(TreePath2 aTreePath)
Returns true if aTreePath is a
descendant of this
TreePath2. |
TreePath2 |
pathByAddingChild(T child)
Returns a new path containing all the elements of this object plus child. |
java.lang.String |
toString()
Returns a string that displays and identifies this object's properties. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TreePath2(T[] path)
The model is free to return an array of any Objects it needs to represent the path. The DefaultTreeModel returns an array of TreeNode objects. The first TreeNode in the path is the root of the tree, the last TreeNode is the node identified by the path.
path - an array of Objects representing the path to a nodepublic TreePath2(T singlePath)
singlePath - an Object representing the path to a node#TreePath2(Object[])
protected TreePath2(TreePath2<T> parent,
T lastElement)
parent ending in lastElement.
protected TreePath2(T[] path,
int length)
length.
protected TreePath2()
getPath,
getPathCount, and
getPathComponent methods,
and possibly the equals method.
| Method Detail |
|---|
public T[] getPath()
#TreePath2(Object[]) public T getLastPathComponent()
#TreePath2(Object[]) public int getPathCount()
public T getPathComponent(int element)
element - an int specifying an element in the path, where
0 is the first element in the path
java.lang.IllegalArgumentException - if the index is beyond the length
of the path#TreePath2(Object[]) public boolean equals(java.lang.Object o)
.equals).
equals in class java.lang.Objecto - the Object to comparepublic int hashCode()
hashCode in class java.lang.Objectpublic boolean isDescendant(TreePath2 aTreePath)
aTreePath is a
descendant of this
TreePath2. A TreePath2 P1 is a descendent of a TreePath2 P2
if P1 contains all of the components that make up
P2's path.
For example, if this object has the path [a, b],
and aTreePath has the path [a, b, c],
then aTreePath is a descendant of this object.
However, if aTreePath has the path [a],
then it is not a descendant of this object.
aTreePath is a descendant of this pathpublic TreePath2 pathByAddingChild(T child)
child. child will be the last element
of the newly created TreePath2.
This will throw a NullPointerException
if child is null.
public TreePath2 getParentPath()
public java.lang.String toString()
toString in class java.lang.Object
|
Copyright 2007-2008 (c) Werner Randelshofer. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||