org.sbml.jsbml.math
public class ASTFunction extends AbstractASTNode
Modifier and Type | Field and Description |
---|---|
protected java.util.List<ASTNode2> |
listOfNodes
Child nodes.
|
protected MathContainer |
parentSBMLObject
The container that holds this ASTFunctionNode.
|
strict, type
listOfListeners, parent, UNKNOWN_ATTRIBUTES, UNKNOWN_ELEMENTS
Constructor and Description |
---|
ASTFunction()
Creates a new
ASTFunction that lacks a pointer
to its containing MathContainer . |
ASTFunction(ASTNode2 astFunction)
Copy constructor; Creates a deep copy of the given
ASTFunction . |
Modifier and Type | Method and Description |
---|---|
void |
addChild(ASTNode2 child)
Adds a child to this node.
|
javax.swing.tree.TreeNode |
clone()
Clone ASTNode2
|
boolean |
getAllowsChildren() |
ASTNode2 |
getChildAt(int childIndex) |
int |
getChildCount() |
java.util.List<ASTNode2> |
getChildren()
Returns the list of children of the current ASTFunction.
|
java.util.List<ASTNode2> |
getListOfNodes()
Returns the list of children of the current ASTFunction.
|
java.util.List<ASTNode2> |
getListOfNodes(Filter filter)
Returns the list of children of the current ASTFunction that satisfy the
given filter.
|
private void |
initDefaults()
Initializes the default values/attributes of the node.
|
void |
insertChild(int n,
ASTNode2 newChild)
|
private boolean |
isSetList()
Returns True iff listOfNodes has been set
|
void |
prependChild(ASTNode2 child)
Adds the given node as a child of this ASTNode2.
|
boolean |
refersTo(java.lang.String id)
Returns
true if this node or one of its descendants contains some
identifier with the given id. |
ASTNode2 |
replaceChild(int n,
ASTNode2 newChild)
Replaces the nth child of this ASTNode2 with the given ASTNode2.
|
(package private) static void |
setParentSBMLObject(ASTNode2 node,
MathContainer parent)
Sets the Parent of the node and its children to the given value
|
private static void |
setParentSBMLObject(ASTNode2 node,
MathContainer parent,
int depth)
Sets the parent of the node and its children to the given value
|
void |
swapChildren(ASTFunction that)
Swaps the children of this
ASTFunction with the children of that
ASTFunction . |
java.lang.String |
toString() |
compile, getParentSBMLObject, getType, isStrict, setParent, setParentSBMLObject, setType, toFormula, toLaTeX, toMathML, unsetParentSBMLObject
addAllChangeListeners, addAllChangeListeners, addTreeNodeChangeListener, addTreeNodeChangeListener, children, clearUserObjects, containsUserObjectKey, equals, filter, filter, filter, fireNodeAddedEvent, fireNodeRemovedEvent, firePropertyChange, getIndex, getListOfTreeNodeChangeListeners, getNumChildren, getParent, getRoot, getTreeNodeChangeListenerCount, getUserObject, hashCode, indexOf, isLeaf, isRoot, isSetParent, isSetUserObjects, notifyChildChange, putUserObject, removeAllTreeNodeChangeListeners, removeAllTreeNodeChangeListeners, removeFromParent, removeTreeNodeChangeListener, removeTreeNodeChangeListener, removeUserObject, userObjectKeySet
finalize, getClass, notify, notifyAll, wait, wait, wait
addAllChangeListeners, addAllChangeListeners, addTreeNodeChangeListener, addTreeNodeChangeListener, clearUserObjects, containsUserObjectKey, filter, filter, filter, fireNodeAddedEvent, fireNodeRemovedEvent, firePropertyChange, getListOfTreeNodeChangeListeners, getRoot, getTreeNodeChangeListenerCount, getUserObject, isRoot, isSetParent, isSetUserObjects, putUserObject, removeAllTreeNodeChangeListeners, removeAllTreeNodeChangeListeners, removeFromParent, removeTreeNodeChangeListener, removeTreeNodeChangeListener, removeUserObject, userObjectKeySet
protected java.util.List<ASTNode2> listOfNodes
protected MathContainer parentSBMLObject
public ASTFunction()
ASTFunction
that lacks a pointer
to its containing MathContainer
.public ASTFunction(ASTNode2 astFunction)
ASTFunction
.astFunction
- the ASTFunction
to be copied.static void setParentSBMLObject(ASTNode2 node, MathContainer parent)
node
- the orphan nodeparent
- the parentprivate static void setParentSBMLObject(ASTNode2 node, MathContainer parent, int depth)
node
- the orphan nodeparent
- the parentdepth
- the current depth in the ASTNode2
tree.
It is just here for testing purposes to track the depth in the tree
during the process.public void addChild(ASTNode2 child)
child
- the node to add as child.public javax.swing.tree.TreeNode clone()
ASTNode2
clone
in interface ASTNode2
clone
in class AbstractTreeNode
public boolean getAllowsChildren()
public ASTNode2 getChildAt(int childIndex)
getChildAt
in interface javax.swing.tree.TreeNode
getChildAt
in class AbstractASTNode
public int getChildCount()
public java.util.List<ASTNode2> getChildren()
public java.util.List<ASTNode2> getListOfNodes()
public java.util.List<ASTNode2> getListOfNodes(Filter filter)
filter
- private void initDefaults()
public void insertChild(int n, ASTNode2 newChild)
private boolean isSetList()
null
- public void prependChild(ASTNode2 child)
child
- an ASTNode2
public boolean refersTo(java.lang.String id)
true
if this node or one of its descendants contains some
identifier with the given id. This method can be used to scan a formula
for a specific parameter or species and detect whether this component is
used by this formula. This search is done using a DFS.id
- the id of an SBML element.true
if this node or one of its descendants contains the
given id.public ASTNode2 replaceChild(int n, ASTNode2 newChild)
n
- long the index of the child to replacenewChild
- ASTNode2
to replace the nth childpublic void swapChildren(ASTFunction that)
Swaps the children of this ASTFunction
with the children of that
ASTFunction
.
Unfortunately, when swapping child nodes, we have to recursively traverse the entire subtrees in order to make sure that all pointers to the parent SBML object are correct. However, this must only be done if the parent SBML object of that differs from the one surrounding this node.
In any case, the pointer from each sub-node to its parent must be changed.
In contrast to other SBML elements, ASTFunction
s have sub-nodes as
direct children, i.e., there is no child called 'ListOfNodes'. The
setParent
method is also not recursive.
However, this might cause many calls to listeners.
that
- the other node whose children should be used to replace this
node's childrenpublic java.lang.String toString()
toString
in interface ASTNode2
toString
in class AbstractASTNode