org.sbml.jsbml
public abstract class AbstractTreeNode extends java.lang.Object implements TreeNodeWithChangeSupport
TreeNode
interface.Modifier and Type | Field and Description |
---|---|
protected java.util.List<TreeNodeChangeListener> |
listOfListeners
List of listeners for this component |
protected javax.swing.tree.TreeNode |
parent
The parent element of this
Annotation . |
private static long |
serialVersionUID
Generated serial version identifier.
|
Constructor and Description |
---|
AbstractTreeNode() |
AbstractTreeNode(javax.swing.tree.TreeNode node)
Constructor for cloning.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addAllChangeListeners(java.util.Collection<TreeNodeChangeListener> listeners)
Adds recursively all given
TreeNodeChangeListener instances to
this element. |
void |
addTreeNodeChangeListener(TreeNodeChangeListener listener)
Adds recursively a listener to the
TreeNodeWithChangeSupport object and
all of its sub-elements. |
void |
addTreeNodeChangeListener(TreeNodeChangeListener listener,
boolean recursive)
Adds a listener to this
TreeNodeWithChangeSupport object and
optionally also to all of its child nodes. |
java.util.Enumeration<javax.swing.tree.TreeNode> |
children() |
abstract javax.swing.tree.TreeNode |
clone() |
boolean |
equals(java.lang.Object object) |
void |
fireNodeAddedEvent()
All
TreeNodeChangeListener instances linked to this
TreeNode are informed about the adding of this Object to
an owning parent Object . |
void |
fireNodeRemovedEvent()
All
TreeNodeChangeListener instances linked to this
TreeNode are informed about the deletion of this TreeNode
from a parent Object . |
void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
All
TreeNodeChangeListener s are informed about the change in this
AbstractTreeNode . |
int |
getIndex(javax.swing.tree.TreeNode node) |
java.util.List<TreeNodeChangeListener> |
getListOfTreeNodeChangeListeners()
Returns all
TreeNodeChangeListener s that are assigned to this
element. |
int |
getNumChildren()
Deprecated.
use
TreeNode.getChildCount() |
javax.swing.tree.TreeNode |
getParent() |
int |
getTreeNodeChangeListenerCount() |
int |
hashCode() |
static int |
indexOf(javax.swing.tree.TreeNode parent,
javax.swing.tree.TreeNode child)
Searches the given child in the list of sub-nodes of the parent element.
|
boolean |
isLeaf() |
boolean |
isRoot()
Opposite of
TreeNodeWithChangeSupport.isSetParent() . |
boolean |
isSetParent() |
protected void |
notifyChildChange(javax.swing.tree.TreeNode oldChild,
javax.swing.tree.TreeNode newChild)
This method is called when one child has been swapped with another one
and can be used to check certain properties of the resulting changed
tree.
|
void |
removeAllTreeNodeChangeListeners()
Removes all SBase change listeners from this element.
|
void |
removeTreeNodeChangeListener(TreeNodeChangeListener listener)
Removes recursively the given change listener from this element.
|
void |
removeTreeNodeChangeListener(TreeNodeChangeListener listener,
boolean recursive)
Removes the given change listener from this element.
|
protected void |
setParent(javax.swing.tree.TreeNode parent) |
java.lang.String |
toString() |
private static final long serialVersionUID
protected java.util.List<TreeNodeChangeListener> listOfListeners
List
of listeners for this componentprotected javax.swing.tree.TreeNode parent
Annotation
.public AbstractTreeNode()
public AbstractTreeNode(javax.swing.tree.TreeNode node)
AbstractTreeNode
has two properties:
parent
and listOfListeners
. Both of them are not cloned
by this method, for two reasons:
parent
is not cloned and is left as null
because the new AbstractTreeNode
will get a parent set as soon as
it is added/linked again to a Model
. Note that only the top-level
element of the cloned sub-tree will have a null
value as its
parent. All sub-element will point to their correct parent element..listOfListeners
is needed in all other setXX() methods.
Cloning these might lead to strange and unexpected behavior, because when
doing a deep cloning, the listeners of the old object would suddenly be
informed about all value changes within this new object. Since we do
cloning, all values of all child elements have to be touched, i.e., all
listeners would be informed many times, but each time receive the
identical value as it was before. Since it is totally unclear of which
type listeners are, a deep cloning of these is not possible.TreeNodeChangeListener
s.node
- The original TreeNode
to be cloned.public static int indexOf(javax.swing.tree.TreeNode parent, javax.swing.tree.TreeNode child)
parent
- child
- public boolean addAllChangeListeners(java.util.Collection<TreeNodeChangeListener> listeners)
TreeNodeWithChangeSupport
TreeNodeChangeListener
instances to
this element.addAllChangeListeners
in interface TreeNodeWithChangeSupport
listeners
- the set of listeners to addtrue
if the set of listeners is added with success.public void addTreeNodeChangeListener(TreeNodeChangeListener listener)
TreeNodeWithChangeSupport
TreeNodeWithChangeSupport
object and
all of its sub-elements. Calling this method is effectively identical to
the call
TreeNodeWithChangeSupport.addTreeNodeChangeListener(TreeNodeChangeListener, boolean)
where
recursively = true
.addTreeNodeChangeListener
in interface TreeNodeWithChangeSupport
listener
- the listener to addTreeNodeWithChangeSupport.addTreeNodeChangeListener(TreeNodeChangeListener, boolean)
public void addTreeNodeChangeListener(TreeNodeChangeListener listener, boolean recursive)
TreeNodeWithChangeSupport
TreeNodeWithChangeSupport
object and
optionally also to all of its child nodes.addTreeNodeChangeListener
in interface TreeNodeWithChangeSupport
listener
- the listener to addrecursive
- if true
the given listener will be added to this node and
also recursively to all of its child nodes. If false
, the
listener will only be added to the current node.TreeNodeWithChangeSupport.addTreeNodeChangeListener(TreeNodeChangeListener)
public java.util.Enumeration<javax.swing.tree.TreeNode> children()
children
in interface javax.swing.tree.TreeNode
public abstract javax.swing.tree.TreeNode clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public void fireNodeAddedEvent()
TreeNodeWithChangeSupport
TreeNodeChangeListener
instances linked to this
TreeNode
are informed about the adding of this Object
to
an owning parent Object
.fireNodeAddedEvent
in interface TreeNodeWithChangeSupport
public void fireNodeRemovedEvent()
TreeNodeWithChangeSupport
TreeNodeChangeListener
instances linked to this
TreeNode
are informed about the deletion of this TreeNode
from a parent Object
.fireNodeRemovedEvent
in interface TreeNodeWithChangeSupport
public int getTreeNodeChangeListenerCount()
getTreeNodeChangeListenerCount
in interface TreeNodeWithChangeSupport
TreeNodeChangeListener
s currently assigned to
this TreeNodeWithChangeSupport
public void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
TreeNodeWithChangeSupport
TreeNodeChangeListener
s are informed about the change in this
AbstractTreeNode
.firePropertyChange
in interface TreeNodeWithChangeSupport
propertyName
- Tells the TreeNodeChangeListener
the name of the
property whose value has been changed.oldValue
- This is the value before the change.newValue
- This gives the new value that is now the new value for the
given property..public int getIndex(javax.swing.tree.TreeNode node)
getIndex
in interface javax.swing.tree.TreeNode
public java.util.List<TreeNodeChangeListener> getListOfTreeNodeChangeListeners()
TreeNodeWithChangeSupport
TreeNodeChangeListener
s that are assigned to this
element.getListOfTreeNodeChangeListeners
in interface TreeNodeWithChangeSupport
TreeNodeChangeListener
s that are assigned to this
element.@Deprecated public int getNumChildren()
TreeNode.getChildCount()
TreeNode
.public javax.swing.tree.TreeNode getParent()
getParent
in interface javax.swing.tree.TreeNode
public int hashCode()
hashCode
in class java.lang.Object
public boolean isLeaf()
isLeaf
in interface javax.swing.tree.TreeNode
public boolean isRoot()
TreeNodeWithChangeSupport
TreeNodeWithChangeSupport.isSetParent()
.
Returns true
if this AbstractTreeNode
is the root
node of a tree, false
otherwise.isRoot
in interface TreeNodeWithChangeSupport
true
if this AbstractTreeNode
is the root
node of a tree, false
otherwise.TreeNodeWithChangeSupport.isSetParent()
public boolean isSetParent()
isSetParent
in interface TreeNodeWithChangeSupport
protected void notifyChildChange(javax.swing.tree.TreeNode oldChild, javax.swing.tree.TreeNode newChild)
oldChild
- the element that was a child of this node before the change.newChild
- the new child whose new parent is this node.public void removeAllTreeNodeChangeListeners()
TreeNodeWithChangeSupport
removeAllTreeNodeChangeListeners
in interface TreeNodeWithChangeSupport
public void removeTreeNodeChangeListener(TreeNodeChangeListener listener)
TreeNodeWithChangeSupport
TreeNodeWithChangeSupport.removeTreeNodeChangeListener(TreeNodeChangeListener, boolean)
where the second argument is true
.removeTreeNodeChangeListener
in interface TreeNodeWithChangeSupport
listener
- the listener to remove.TreeNodeWithChangeSupport.removeTreeNodeChangeListener(TreeNodeChangeListener, boolean)
public void removeTreeNodeChangeListener(TreeNodeChangeListener listener, boolean recursive)
TreeNodeWithChangeSupport
removeTreeNodeChangeListener
in interface TreeNodeWithChangeSupport
listener
- the listener to remove.recursive
- switch to decide whether or not the given listener should be removed
in a recursive manner.TreeNodeWithChangeSupport.removeTreeNodeChangeListener(TreeNodeChangeListener)
protected void setParent(javax.swing.tree.TreeNode parent)
parent
- the parent to setpublic java.lang.String toString()
toString
in class java.lang.Object