org.jscience.mathematics.analysis.expressions
Class ExpressionTreeModel

java.lang.Object
  extended by org.jscience.mathematics.analysis.expressions.ExpressionTreeModel
All Implemented Interfaces:
javax.swing.tree.TreeModel

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

The class ExpressionTreeModel is a TreeModel implementation that allows Expressions to be displayed as tree structures.
Example of use:

 Expression e = new Addition( new Multiplication( new Variable( "x" ),
 new Parameter(" p ") ),new Division( new Variable( "y" ),
 new Sin( new Variable( "t" ) ) ));
 ExpressionTreeModel model = new ExpressionTreeModel( e );
 Settings.recursivePrint = false;JTree tree = new JTree();
 tree.setModel( model );JFrame frame = new JFrame( "Computational tree" );
 frame.getContentPane().add( new JScrollPane( tree ), "Center" );
 frame.pack();frame.show();

See Also:
Expression

Constructor Summary
ExpressionTreeModel(Expression expr)
          Creates a new ExpressionTreeModel object.
 
Method Summary
 void addTreeModelListener(javax.swing.event.TreeModelListener l)
          DOCUMENT ME!
 java.lang.Object getChild(java.lang.Object parent, int index)
          DOCUMENT ME!
 int getChildCount(java.lang.Object parent)
          DOCUMENT ME!
 int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
          DOCUMENT ME!
 java.lang.Object getRoot()
          DOCUMENT ME!
 boolean isLeaf(java.lang.Object node)
          DOCUMENT ME!
static void main(java.lang.String[] args)
          DOCUMENT ME!
 void removeTreeModelListener(javax.swing.event.TreeModelListener l)
          DOCUMENT ME!
 void valueForPathChanged(javax.swing.tree.TreePath t, java.lang.Object o)
          DOCUMENT ME!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionTreeModel

public ExpressionTreeModel(Expression expr)
Creates a new ExpressionTreeModel object.

Parameters:
expr - DOCUMENT ME!
Method Detail

getRoot

public java.lang.Object getRoot()
DOCUMENT ME!

Specified by:
getRoot in interface javax.swing.tree.TreeModel
Returns:
DOCUMENT ME!

isLeaf

public boolean isLeaf(java.lang.Object node)
DOCUMENT ME!

Specified by:
isLeaf in interface javax.swing.tree.TreeModel
Parameters:
node - DOCUMENT ME!
Returns:
DOCUMENT ME!

getChildCount

public int getChildCount(java.lang.Object parent)
DOCUMENT ME!

Specified by:
getChildCount in interface javax.swing.tree.TreeModel
Parameters:
parent - DOCUMENT ME!
Returns:
DOCUMENT ME!

getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 int index)
DOCUMENT ME!

Specified by:
getChild in interface javax.swing.tree.TreeModel
Parameters:
parent - DOCUMENT ME!
index - DOCUMENT ME!
Returns:
DOCUMENT ME!

getIndexOfChild

public int getIndexOfChild(java.lang.Object parent,
                           java.lang.Object child)
DOCUMENT ME!

Specified by:
getIndexOfChild in interface javax.swing.tree.TreeModel
Parameters:
parent - DOCUMENT ME!
child - DOCUMENT ME!
Returns:
DOCUMENT ME!

valueForPathChanged

public void valueForPathChanged(javax.swing.tree.TreePath t,
                                java.lang.Object o)
DOCUMENT ME!

Specified by:
valueForPathChanged in interface javax.swing.tree.TreeModel
Parameters:
t - DOCUMENT ME!
o - DOCUMENT ME!

addTreeModelListener

public void addTreeModelListener(javax.swing.event.TreeModelListener l)
DOCUMENT ME!

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

removeTreeModelListener

public void removeTreeModelListener(javax.swing.event.TreeModelListener l)
DOCUMENT ME!

Specified by:
removeTreeModelListener in interface javax.swing.tree.TreeModel
Parameters:
l - DOCUMENT ME!

main

public static void main(java.lang.String[] args)
DOCUMENT ME!

Parameters:
args - DOCUMENT ME!