A node in a tree data structure. A node may have at most one parent and zero or more children. A node with no parent is the root of its tree; a node with no children is a leaf.
allowsChildren | Boolean, default value: true | True if the node is able to have children. |
children (Read-only) | Array, default value: [] | Array of children, May be [] if this node has no children. Children are ordered according to their rank. NOTE: get.children(obj) returns children sorted in rank order. |
parent | modelit.layout.Node or [], default value: [] | This node's parent, or empty if this node has no parent. |
rank | Integer, default value: 0 | Relative position of the node. When ordering horizontally: Low rank goes left. High rank goes right. When ordering vertically. Low rank goes on top. High rank goes below. NOTE: only the relative ranks are important. |
signature (Read-only) | Unique numeric signature (within objects of class Node) |
modelit.layout.Node constructor.
obj = modelit.layout.Node(allowsChildren)
allowsChildren | any | boolean, true if this node can have children. |
obj | any | modelit.layout.Node Documentation for modelit.layout.Node/Node doc modelit.layout.Node |
Builds the parents of node up to and including the root node, where the original node is the last element in the returned array.
value = getPathToRoot(obj)
obj | any | modelit.layout.Node |
value | any | list of modelit.layout.Node |
Returns the number of levels above this node, i.e. the distance from the root to this node.
value = getLevel(obj)
obj | any | modelit.layout.Node |
value | any | integer |
Creates a list on nodes in depth-first order for the subtree starting at the specified node.
list = getDepthFirstList(obj, list)
obj | any | modelit.layout.Node |
list | any | array of modelit.layout.Node in depth-first order |
Creates a list on nodes in breadth-first order for the subtree starting at the specified node.
list = getBreadthFirstList(obj)
obj | any | <modelit.layout.Node> |
list | any | <array of modelit.layout.Node> in breadth-first order |
Determine if a node is active.
selectindx = isactivenode(list, parentIndex)
list | any | Nx1 array of Frames |
parentIndex | any | Nx1 array of parent index |
selectindx | any | Mx1 array, index in list, sorted according to parent and rank. Sorting is essential for correct display. |
Create list of active frames only, see getBreadthFirstList.
list = getBreadthFirstList(obj)
obj | any | modelit.layout.Node |
list | any | array of modelit.layout.Node in breadth-first order |
Returns the previous sibling of this node. Returns [] if this node has no parent or if it is the parent's first child.
value = getPreviousSibling(obj)
obj | any | modelit.layout.Node |
value | any | modelit.layout.Node or [] |
Returns the next sibling of this node. Returns [] if this node has no parent or if it is the parent's last child.
value = getNextSibling(obj)
obj | any | modelit.layout.Node |
value | any | modelit.layout.Node or [] |
Gets the siblings (nodes with the same parent) of this node. Note that this node is its own sibling
value = getSiblings(obj)
obj | any | modelit.layout.Node |
value | any | modelit.layout.Node |
Move a child of this frame to another frame.
moveChild(obj, child, newparent)
obj | any | modelit.layout.Node |
child | any | modelit.layout.Node |
newparent | any | modelit.layout.Node |
Child is removed from this frame and add as a child to the new parent frame.
Removes all of this node's children.
removeAllChildren(obj)
obj | any | modelit.layout.Node |
No output
Returns true if this node is the root of the tree.
obj = isRoot(obj)
obj | any | modelit.layout.Node |
value | any | boolean, true if this node is a root node |
Returns true if this node is a leaf.
value = isLeaf(obj)
obj | any | modelit.layout.Node |
value | any | boolean, true if this node is a leaf (has no children) |
Returns the root of this node.
obj = getRoot(obj)
obj | any | modelit.layout.Node |
obj | any | modelit.layout.Node |
Returns the index of this node in its parent's children.
value = getIndex(obj)
obj | any | modelit.layout.Node |
value | any | integer with index of this node in its parent's children, 0 if this node is a root |
Returns the number of children of this node.
value = getChildCount(obj)
obj | any | modelit.layout.Node |
value | any | integer with number of children of this node |
Returns the child of obj at index childIndex.
value = getChildAt(obj, childIndex)
obj | any | modelit.layout.Node |
childIndex | any | integer |
obj | any | modelit.layout.Node or [] if index exceeds number of children |
Returns the childs in sorted order.
value = getChildAt(obj, childIndex)
obj | any | modelit.layout.Node |
childIndex | any | integer |
obj | any | modelit.layout.Node or [] if index exceeds number of children |
Returns the objects whose property values match those passed as param-value pairs to the findobj command.
Returns the objects whose property values match those passed as param-value pairs to the findobj command.
Each node has its own unique numeric signature
DOUBLE Convert to double precision. DOUBLE(X) returns the double precision value for X. If X is already a double precision array, DOUBLE has no effect. DOUBLE is called for the expressions in FOR, IF, and WHILE loops if the expression isn't already double precision. DOUBLE should be overloaded for all objects where it makes sense to convert it into a double precision value. See also SINGLE, DATATYPES, ISFLOAT, ISNUMERIC.
Removes this node and its children from the tree.
remove(obj)
obj | any | modelit.layout.Node, node to remove from tree |
No output
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.
add(obj, newChild)
obj | any | modelit.layout.Node |
newChild | any | modelit.layout.Node, node to be added as a child of obj |
No output