Tree node for FvTree componant.
new FvTreeNode()public function FvTreeNode(userObject:FvTreeItem, allowsChildren:Boolean, draggable:Boolean, editable:Boolean, deletable:Boolean)Creates a tree node with no parent, no children, initialized with the specified user object, and that allows children only if specified.
userObject | an Object provided by the user that constitutes the node's data |
allowsChildren | (optional)if true, the node is allowed to have child nodes -- otherwise, it is always a leaf node. Default is true. |
draggable | Node is draggable or not ( override tree behaviour for this specific node ) |
editable | Node is editable or not ( override tree behaviour for this specific node ) |
public function setUserObject(userObject:FvTreeItem):Void
Sets the user object for this node to userObject.
userObject | the Object that constitutes this node's user-specified data |
setUserObject() in fvaswing.components.tree.FvAbstractTreeNode
public function insert(newChild:FvTreeNode, childIndex:Number):Void
Removes newChild from its present parent (if it has a
parent), sets the child's parent to this node, and then adds the child
to this node's child array at index childIndex.
newChild must not be null and must not be an ancestor of
this node.
newChild | the FvTreeNode to insert under this node |
childIndex | the index in this node's child array where this node is to be inserted |
| Error | if
newChild is null or is an ancestor of this node,
or if childIndex is out of bounds, or if this
node does not allow children
|
insert() in fvaswing.components.tree.FvAbstractTreeNode
public function setParent(newParent:FvTreeNode):Void
Sets this node's parent to newParent but does not
change the parent's child array. This method is called from
insert() and remove() to
reassign a child's parent, it should not be messaged from anywhere
else.
newParent | this node's new parent |
public function getParent():FvTreeNodeReturns this node's parent or null if this node has no parent.
this node's parent TreeNode, or null if this node has no parent
public function getChildAt(index:Number):FvTreeNodeReturns the child at the specified index in this node's child array.
index | an index into this node's child array |
the TreeNode in this node's child array at the specified index
| ArrayIndexOutOfBoundsException | if index
is out of bounds
|
public function getIndex(aChild:FvTreeNode):Number
Returns the index of the specified child in this node's child array.
If the specified node is not a child of this node, returns
-1. This method performs a linear search and is O(n)
where n is the number of children.
aChild | the FvTreeNode to search for among this node's children |
an int giving the index of the node in this node's child
array, or -1 if the specified node is a not
a child of this node
public function remove(aChild:FvTreeNode):Void
Removes aChild from this node's child array, giving it a
null parent.
aChild | a child of this node to remove |
public function append(newChild:FvTreeNode):Void
Removes newChild from its parent and makes it a child of
this node by adding it to the end of this node's child array.
newChild | node to add as a child of this node |
public function isNodeAncestor(anotherNode:FvTreeNode):Boolean
Returns true if anotherNode is an ancestor of this node
-- if it is this node, this node's parent, or an ancestor of this
node's parent. (Note that a node is considered an ancestor of itself.)
If anotherNode is null, this method returns false. This
operation is at worst O(h) where h is the distance from the root to
this node.
anotherNode | node to test as an ancestor of this node |
true if this node is a descendant of anotherNode
isNodeAncestor() in fvaswing.components.tree.FvAbstractTreeNode
public function isNodeDescendant(anotherNode:FvTreeNode):Boolean
Returns true if anotherNode is a descendant of this node
-- if it is this node, one of this node's children, or a descendant of
one of this node's children. Note that a node is considered a
descendant of itself. If anotherNode is null, returns
false. This operation is at worst O(h) where h is the distance from the
root to anotherNode.
anotherNode | node to test as descendant of this node |
true if this node is an ancestor of anotherNode
isNodeDescendant() in fvaswing.components.tree.FvAbstractTreeNode
public function getSharedAncestor(aNode:FvTreeNode):FvTreeNode
Returns the nearest common ancestor to this node and aNode.
Returns null, if no such ancestor exists -- if this node and
aNode are in different trees or if aNode is
null. A node is considered an ancestor of itself.
aNode | node to find common ancestor with |
nearest ancestor common to this node and aNode,
or null if none
getSharedAncestor() in fvaswing.components.tree.FvAbstractTreeNode
public function isNodeRelated(aNode:FvTreeNode):Boolean
Returns true if and only if aNode is in the same tree
as this node. Returns false if aNode is null.
true if aNode is in the same tree as this node;
false if aNode is null
isNodeRelated() in fvaswing.components.tree.FvAbstractTreeNode
public function getRoot():FvTreeNodeReturns the root of the tree that contains this node. The root is the ancestor with a null parent.
the root of the tree that contains this node
public function getNextNode():FvTreeNodeReturns the node that follows this node in a preorder traversal of this node's tree. Returns null if this node is the last node of the traversal. This is an inefficient way to traverse the entire tree; use an enumeration, instead.
the node that follows this node in a preorder traversal, or null if this node is last
getNextNode() in fvaswing.components.tree.FvAbstractTreeNode
public function getPreviousNode():FvTreeNode
Returns the node that precedes this node in a preorder traversal of
this node's tree. Returns null if this node is the
first node of the traversal -- the root of the tree.
This is an inefficient way to
traverse the entire tree; use an enumeration, instead.
the node that precedes this node in a preorder traversal, or null if this node is the first
getPreviousNode() in fvaswing.components.tree.FvAbstractTreeNode
public function pathFromAncestorEnumeration(ancestor:FvTreeNode):Array
Creates and returns an enumeration that follows the path from
ancestor to this node. The enumeration's
nextElement() method first returns ancestor,
then the child of ancestor that is an ancestor of this
node, and so on, and finally returns this node. Creation of the
enumeration is O(m) where m is the number of nodes between this node
and ancestor, inclusive. Each nextElement()
message is O(1).
Modifying the tree by inserting, removing, or moving a node invalidates any enumerations created before the modification.
an enumeration for following the path from an ancestor of this node to this one
| IllegalArgumentException | if ancestor is
not an ancestor of this node
|
pathFromAncestorEnumeration() in fvaswing.components.tree.FvAbstractTreeNode
public function isNodeChild(aNode:FvTreeNode):Boolean
Returns true if aNode is a child of this node. If
aNode is null, this method returns false.
true if aNode is a child of this node; false if
aNode is null
isNodeChild() in fvaswing.components.tree.FvAbstractTreeNode
public function getFirstChild():FvTreeNodeReturns this node's first child.
the first child of this node, null if this node has no children
getFirstChild() in fvaswing.components.tree.FvAbstractTreeNode
public function getLastChild():FvTreeNodeReturns this node's last child.
the last child of this node, null if this node has no children
getLastChild() in fvaswing.components.tree.FvAbstractTreeNode
public function getChildAfter(aChild:FvTreeNode):FvTreeNode
Returns the child in this node's child array that immediately
follows aChild, which must be a child of this node. If
aChild is the last child, returns null. This method
performs a linear search of this node's children for
aChild and is O(n) where n is the number of children; to
traverse the entire array of children, use an enumeration instead.
the child of this node that immediately follows
aChild
| Error | if aChild is
null or is not a child of this node
|
getChildAfter() in fvaswing.components.tree.FvAbstractTreeNode
public function getChildBefore(aChild:FvTreeNode):FvTreeNode
Returns the child in this node's child array that immediately
precedes aChild, which must be a child of this node. If
aChild is the first child, returns null. This method
performs a linear search of this node's children for aChild
and is O(n) where n is the number of children.
the child of this node that immediately precedes
aChild
| IllegalArgumentException | if aChild is null
or is not a child of this node
|
getChildBefore() in fvaswing.components.tree.FvAbstractTreeNode
public function isNodeSibling(anotherNode:FvTreeNode):Boolean
Returns true if anotherNode is a sibling of (has the
same parent as) this node. A node is its own sibling. If
anotherNode is null, returns false.
anotherNode | node to test as sibling of this node |
true if anotherNode is a sibling of this node
isNodeSibling() in fvaswing.components.tree.FvAbstractTreeNode
public function getNextSibling():FvTreeNodeReturns the next sibling of this node in the parent's children array. Returns null if this node has no parent or is the parent's last child. This method performs a linear search that is O(n) where n is the number of children; to traverse the entire array, use the parent's child enumeration instead.
the sibling of this node that immediately follows this node
getNextSibling() in fvaswing.components.tree.FvAbstractTreeNode
public function getPreviousSibling():FvTreeNodeReturns the previous sibling of this node in the parent's children array. Returns null if this node has no parent or is the parent's first child. This method performs a linear search that is O(n) where n is the number of children.
the sibling of this node that immediately precedes this node
getPreviousSibling() in fvaswing.components.tree.FvAbstractTreeNode
public function getFirstLeaf():FvTreeNodeFinds and returns the first leaf that is a descendant of this node -- either this node or its first child's first leaf. Returns this node if it is a leaf.
the first leaf in the subtree rooted at this node
getFirstLeaf() in fvaswing.components.tree.FvAbstractTreeNode
public function getLastLeaf():FvTreeNodeFinds and returns the last leaf that is a descendant of this node -- either this node or its last child's last leaf. Returns this node if it is a leaf.
the last leaf in the subtree rooted at this node
getLastLeaf() in fvaswing.components.tree.FvAbstractTreeNode
public function getNextLeaf():FvTreeNodeReturns the leaf after this node or null if this node is the last leaf in the tree.
In this implementation of the MutableNode interface,
this operation is very inefficient. In order to determine the
next node, this method first performs a linear search in the
parent's child-list in order to find the current node.
That implementation makes the operation suitable for short
traversals from a known position. But to traverse all of the
leaves in the tree, you should use depthFirstEnumeration
to enumerate the nodes in the tree and use isLeaf
on each node to determine which are leaves.
returns the next leaf past this node
getNextLeaf() in fvaswing.components.tree.FvAbstractTreeNode
public function getPreviousLeaf():FvTreeNodeReturns the leaf before this node or null if this node is the first leaf in the tree.
In this implementation of the MutableNode interface,
this operation is very inefficient. In order to determine the
previous node, this method first performs a linear search in the
parent's child-list in order to find the current node.
That implementation makes the operation suitable for short
traversals from a known position. But to traverse all of the
leaves in the tree, you should use depthFirstEnumeration
to enumerate the nodes in the tree and use isLeaf
on each node to determine which are leaves.
returns the leaf before this node
getPreviousLeaf() in fvaswing.components.tree.FvAbstractTreeNode