org.freehep.jas.plugin.tree
Interface FTreeNode


public interface FTreeNode

An FTreeNode is a node of an FTree. It has a type and it can contain multiple objects. Its appearence and behavior are defined by FTreeNodeAdapters that are selected based on the FTreeNode's type. Each FTreeNode contains an Hashtable that can be used to store objects in the node. This Hashtable should be primarily used by FTreeNodeObjectProviders to store objects that can be then accesed via the objectForClass() method. Objects are stored in key-value pairs. Changes to the FTreeNode are propagated to the node's liteners via FTreeNodeEvents.


Method Summary
 void addFTreeNodeListener(FTreeNodeListener listener)
          Add an FTreeNodeListener to this node.
 void addKey(java.lang.Object key, java.lang.Object value)
          Add a key-value pair to this node.
 java.util.List childNodes()
          Get the list of children in this node.
 java.lang.Object objectForClass(java.lang.Class clazz)
          Get the object for a given class contained in this node.
 FTreeNode parent()
          Get the parent for this node.
 FTreePath path()
          Get the FTreePath that leads to this node.
 void removeFTreeNodeListener(FTreeNodeListener listener)
          Remove an FTreeNodeListener from this node.
 void removeKey(java.lang.Object key)
          Remove a key, and the corresponding value, from this node.
 FTree tree()
          Get the FTree to which this node belongs.
 java.lang.Class type()
          Get the node's type.
 java.lang.Object value(java.lang.Object key)
          Get the value contained in the node for a given key.
 

Method Detail

objectForClass

public java.lang.Object objectForClass(java.lang.Class clazz)
Get the object for a given class contained in this node.

Parameters:
clazz - The type of object to be returned.
Returns:
The node's object for the given class. If no object for the given class is present, null is returned.

type

public java.lang.Class type()
Get the node's type. This is the type of the node as it was assigned when the node was added to the tree. The type is used to select the FTreeNodeAdapters that provide the appearence and behavior for the given node.

Returns:
The node's type

path

public FTreePath path()
Get the FTreePath that leads to this node.

Returns:
The node's FTreePath.

tree

public FTree tree()
Get the FTree to which this node belongs.

Returns:
The FTree to which this node belongs.

childNodes

public java.util.List childNodes()
Get the list of children in this node. The list is ordered as the nodes are currently displayed in the tree. If the node has no children an empty list is returned.

Returns:
The ordered list of this node's children.

parent

public FTreeNode parent()
Get the parent for this node.

Returns:
The node's parent.

addKey

public void addKey(java.lang.Object key,
                   java.lang.Object value)
Add a key-value pair to this node. If the key already exists, its value is overritten.

Parameters:
key - The key for the given value.
value - The corresponding value.

removeKey

public void removeKey(java.lang.Object key)
Remove a key, and the corresponding value, from this node.

Parameters:
key - The key to be removed.

value

public java.lang.Object value(java.lang.Object key)
Get the value contained in the node for a given key.

Parameters:
key - The key.
Returns:
The corresponding object.

addFTreeNodeListener

public void addFTreeNodeListener(FTreeNodeListener listener)
Add an FTreeNodeListener to this node. All the listeners registered with this node will be notified of any changed to the FTreeNode.

Parameters:
listener - The FTreeNodeListener to be added.

removeFTreeNodeListener

public void removeFTreeNodeListener(FTreeNodeListener listener)
Remove an FTreeNodeListener from this node.

Parameters:
listener - The FTreeNodeListener to be removed.