ubiware.core.visualizer
Class BeliefContainerTreeModel

java.lang.Object
  extended by ubiware.core.visualizer.BeliefContainerTreeModel
All Implemented Interfaces:
javax.swing.tree.TreeModel, SubtreesTreeModel

public class BeliefContainerTreeModel
extends java.lang.Object
implements SubtreesTreeModel

Maps a belief container/context to a tree-like structure.

This is a tree structure whose nodes are complete subtrees. For more information, read SubtreesTreeModel.

A BeliefContainerTreeModel has one or more BeliefTreeModels as children of its. It is initialised only once and after that it only uses its own, local, final and unmutable storage of beliefs. It never asks the Agent about beliefs ever again.

Author:
Nikos Mouchtaris

Constructor Summary
BeliefContainerTreeModel(javax.swing.tree.TreeModel root, ReusableAtomicBehavior rabi, java.lang.String contextID)
           Initialises a new instance of BeliefContainerTreeModel which will represent the context/container specified by this ID.
 
Method Summary
 void addTreeModelListener(javax.swing.event.TreeModelListener l)
           This method has no effect in this implementation.
 java.lang.Object getChild(java.lang.Object parent, int index)
           
 int getChildCount(java.lang.Object parent)
           
 java.lang.String getContextID()
          Returns the actual ID of the container that this node came from.
 int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
           
 javax.swing.tree.TreeModel getRoot()
           
 boolean isLeaf(java.lang.Object node)
           
 void removeTreeModelListener(javax.swing.event.TreeModelListener l)
           
 java.lang.String toString()
           Returns a textual representation of this object, which is the ID of the belief context/container, surrounded by braces ({})
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
           This method has no effect in this implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BeliefContainerTreeModel

public BeliefContainerTreeModel(javax.swing.tree.TreeModel root,
                                ReusableAtomicBehavior rabi,
                                java.lang.String contextID)

Initialises a new instance of BeliefContainerTreeModel which will represent the context/container specified by this ID.

The given ReusableAtomicBehavior, rabi, is used in order to acquire all beliefs in the belief context specified by the given contextID. rabi is never used again, throughout the whole life cycle of this object. It is not even stored in a field.

This model will create a whole tree-like substructure of the Agent's beliefs (as acquired by rabi). The children of this model will be BeliefTreeModels, created according to the actual beliefs of the Agent. This locally re-created structure of beliefs is used whenever queries are made to this model. The Agent's actual belief storage is never re-read.

root is the actual root element of this model. This could be any TreeModel which might cooperate with this one. If root is null then the root of the tree is believed to be this! and this belief is being passed accordingly to the children TreeModels created as the result of this model's initialisation.

Parameters:
root - the actual root of the whole tree (if null then root = this)
rabi - a RAB to be used for accessing the Agent's beliefs
contextID - the context id to be represented by this model
Method Detail

getRoot

public javax.swing.tree.TreeModel getRoot()
Specified by:
getRoot in interface javax.swing.tree.TreeModel

getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 int index)
Specified by:
getChild in interface javax.swing.tree.TreeModel

getChildCount

public int getChildCount(java.lang.Object parent)
Specified by:
getChildCount in interface javax.swing.tree.TreeModel

isLeaf

public boolean isLeaf(java.lang.Object node)
Specified by:
isLeaf in interface javax.swing.tree.TreeModel

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newValue)

This method has no effect in this implementation.

Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel
Parameters:
path - ignored
newValue - ignored

getIndexOfChild

public int getIndexOfChild(java.lang.Object parent,
                           java.lang.Object child)
Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel

addTreeModelListener

public void addTreeModelListener(javax.swing.event.TreeModelListener l)

This method has no effect in this implementation.

Specified by:
addTreeModelListener in interface javax.swing.tree.TreeModel
Parameters:
l -

removeTreeModelListener

public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
Specified by:
removeTreeModelListener in interface javax.swing.tree.TreeModel

toString

public java.lang.String toString()

Returns a textual representation of this object, which is the ID of the belief context/container, surrounded by braces ({})

Overrides:
toString in class java.lang.Object
Returns:
{_contextID}

getContextID

public java.lang.String getContextID()
Returns the actual ID of the container that this node came from.

Returns:
the actual ID of the container that this node came from.