edu.toronto.cs.simulator
Class XCTraceTree

java.lang.Object
  extended by edu.toronto.cs.simulator.XCTraceTree
All Implemented Interfaces:
javax.swing.tree.TreeModel

public class XCTraceTree
extends java.lang.Object
implements javax.swing.tree.TreeModel

XCTraceTree is the trace tree for the simulator.


Constructor Summary
XCTraceTree(MvSetModelChecker modelChecker)
          Builds a trace tree using a modelchecker initialized with a model.
 
Method Summary
 void addChild(XCTraceState parent, XCTraceState child)
          Adds a new child to the specified parent in the tree.
 boolean addPath(javax.swing.tree.TreePath path)
          Adds a node specified by the path to the tree.
 void addTreeModelListener(javax.swing.event.TreeModelListener l)
          Adds a listener for the TreeModelEvent posted after the tree changes.
 void expand(XCTraceState state, CTLNode condition)
          Given some initial state will add the successor states (as one multistate) satisfying the condition.
 void expandOne(XCTraceState state, CTLNode condition)
          Given some initial state will pick one of the successor states satisfying the condition and add it as a child.
protected  void fireTreeNodesChanged(javax.swing.event.TreeModelEvent e)
          Invoked after a node (or a set of siblings) has changed in some way.
protected  void fireTreeNodesInserted(javax.swing.event.TreeModelEvent e)
          Invoked after nodes have been inserted into the tree.
protected  void fireTreeNodesRemoved(javax.swing.event.TreeModelEvent e)
          Invoked after nodes have been removed from the tree.
protected  void fireTreeStructureChanged(javax.swing.event.TreeModelEvent e)
          Invoked after the tree has drastically changed structure from a given node down.
 IAlgebra getAlgebra()
          Gets the algebra used by states in the trace.
 java.lang.Object getChild(java.lang.Object parent, int index)
          Returns the child of parent at index index in the parent's child array.
 int getChildCount(java.lang.Object parent)
          Returns the number of children of parent.
 int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
          Returns the index of child in parent.
 XCTraceState getLastAdded()
          Returns the last node added to the tree.
 javax.swing.tree.TreePath getPath(XCTraceState s)
          Returns the path from the root of the trace to the specified state.
 java.lang.Object getRoot()
          Returns the root of the tree.
 boolean isLeaf(java.lang.Object node)
          Returns true if node is a leaf.
 XCTraceState remove(XCTraceState s)
          Removes the trace tree rooted at the state s (state s included except when s is the root).
 void removeTreeModelListener(javax.swing.event.TreeModelListener l)
          Removes a listener previously added with addTreeModelListener.
 XCTraceState split(XCTraceState state, CTLNode condition)
          Given a (multi-)state will attempt to split a single state off of it, modifying the tree accordingly (add 2 siblings in place of the old state).
 CTLNode[] stateToArray(XCStateInfo info)
          Eventually this will allow to merge siblings into one multi-state.
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
          Messaged when the user has altered the value for the item identified by path to newValue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XCTraceTree

public XCTraceTree(MvSetModelChecker modelChecker)
Builds a trace tree using a modelchecker initialized with a model.

Method Detail

addTreeModelListener

public void addTreeModelListener(javax.swing.event.TreeModelListener l)
Adds a listener for the TreeModelEvent posted after the tree changes.

Specified by:
addTreeModelListener in interface javax.swing.tree.TreeModel

getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 int index)
Returns the child of parent at index index in the parent's child array.

Specified by:
getChild in interface javax.swing.tree.TreeModel

getChildCount

public int getChildCount(java.lang.Object parent)
Returns the number of children of parent.

Specified by:
getChildCount in interface javax.swing.tree.TreeModel

getIndexOfChild

public int getIndexOfChild(java.lang.Object parent,
                           java.lang.Object child)
Returns the index of child in parent.

Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel

getRoot

public java.lang.Object getRoot()
Returns the root of the tree.

Specified by:
getRoot in interface javax.swing.tree.TreeModel

isLeaf

public boolean isLeaf(java.lang.Object node)
Returns true if node is a leaf.

Specified by:
isLeaf in interface javax.swing.tree.TreeModel

removeTreeModelListener

public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
Removes a listener previously added with addTreeModelListener.

Specified by:
removeTreeModelListener in interface javax.swing.tree.TreeModel

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath path,
                                java.lang.Object newValue)
Messaged when the user has altered the value for the item identified by path to newValue.

Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel

getAlgebra

public IAlgebra getAlgebra()
Gets the algebra used by states in the trace.


addChild

public void addChild(XCTraceState parent,
                     XCTraceState child)
Adds a new child to the specified parent in the tree.

Parameters:
parent - - parent node
child - - child node to be added

addPath

public boolean addPath(javax.swing.tree.TreePath path)
Adds a node specified by the path to the tree. All the necessary ancestor nodes are also added. The first node in the path must be equal to the root of the trace tree it's added to.

Returns:
true if added the path sucessfully, false if nothing was added (wrong TreePath or node already existed).

remove

public XCTraceState remove(XCTraceState s)
Removes the trace tree rooted at the state s (state s included except when s is the root).

Parameters:
s - - node to be removed.
Returns:
the removed node.

getPath

public javax.swing.tree.TreePath getPath(XCTraceState s)
Returns the path from the root of the trace to the specified state.

Parameters:
s - - state to get the path of.
Returns:
the path to the specified state.

fireTreeNodesChanged

protected void fireTreeNodesChanged(javax.swing.event.TreeModelEvent e)
Invoked after a node (or a set of siblings) has changed in some way.


fireTreeNodesInserted

protected void fireTreeNodesInserted(javax.swing.event.TreeModelEvent e)
Invoked after nodes have been inserted into the tree.


fireTreeNodesRemoved

protected void fireTreeNodesRemoved(javax.swing.event.TreeModelEvent e)
Invoked after nodes have been removed from the tree.


fireTreeStructureChanged

protected void fireTreeStructureChanged(javax.swing.event.TreeModelEvent e)
Invoked after the tree has drastically changed structure from a given node down.


expand

public void expand(XCTraceState state,
                   CTLNode condition)
Given some initial state will add the successor states (as one multistate) satisfying the condition.


expandOne

public void expandOne(XCTraceState state,
                      CTLNode condition)
Given some initial state will pick one of the successor states satisfying the condition and add it as a child.


split

public XCTraceState split(XCTraceState state,
                          CTLNode condition)
Given a (multi-)state will attempt to split a single state off of it, modifying the tree accordingly (add 2 siblings in place of the old state). NOTE: the root splits differently from other states, it creates children NOT siblings.

Returns:
the old unsplit state if it was removed from the tree.

stateToArray

public CTLNode[] stateToArray(XCStateInfo info)
Eventually this will allow to merge siblings into one multi-state. public void merge (XCTraceState [] siblings) { } /** Converts a state description to an array of "variable = value".


getLastAdded

public XCTraceState getLastAdded()
Returns the last node added to the tree. Note: removing any node resets this to null.