org.problets.domain.model.expression
Class ExpressionViewExpert

java.lang.Object
  extended by org.problets.domain.model.expression.ExpressionViewExpert

public class ExpressionViewExpert
extends java.lang.Object

ExpressionViewExpert To hold the expression, evaluate it, provide its declarations, to hold its view tree, provide list of operators and operands in it

Author:
Amruth Kumar

Constructor Summary
ExpressionViewExpert(Expression inExpression)
          Constructor called for stand-alone expressions - This is expected to solve an expression before rendering it
ExpressionViewExpert(Expression inExpression, boolean shouldEvaluate)
          Constructor called by ParenthesisView - This must NOT solve an expression before rendering it - the expression has already been solved before
 
Method Summary
 java.util.Vector getDeclarations()
           
 Expression getExpression()
           
 java.util.Vector getGraphicSolution()
          This method will not work correctly unless expression.evaluate() is called first - which is called in the constructor.
 java.util.Vector getOperands()
           
 java.util.Vector getOperators()
           
 NodeView getRootView()
           
 void getTextSolution(java.util.Vector explanation)
          This method will not work correctly unless expression.evaluate() is called first which is actually called in the constructor.
static void main(java.lang.String[] args)
           
 void setExpression(Expression inExpression)
          Version called by ProbletView to update the expression of ExpressionViewExpert
 int typeset(java.awt.Graphics g, java.awt.FontMetrics inFontMetrics, int x, int y, int spacing)
          Given the graphics context and the font metrics used, this method will calculate the left and right extents of all the operators and operands in an expression.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionViewExpert

public ExpressionViewExpert(Expression inExpression)
Constructor called for stand-alone expressions - This is expected to solve an expression before rendering it


ExpressionViewExpert

public ExpressionViewExpert(Expression inExpression,
                            boolean shouldEvaluate)
Constructor called by ParenthesisView - This must NOT solve an expression before rendering it - the expression has already been solved before

Method Detail

getExpression

public Expression getExpression()

getDeclarations

public java.util.Vector getDeclarations()

getRootView

public NodeView getRootView()

getOperators

public java.util.Vector getOperators()

getOperands

public java.util.Vector getOperands()

setExpression

public void setExpression(Expression inExpression)
Version called by ProbletView to update the expression of ExpressionViewExpert


typeset

public int typeset(java.awt.Graphics g,
                   java.awt.FontMetrics inFontMetrics,
                   int x,
                   int y,
                   int spacing)
Given the graphics context and the font metrics used, this method will calculate the left and right extents of all the operators and operands in an expression. It will ensure that the expression is typeset ONLY once - otherwise, if the expression is typeset every time it is displayed typeset information will overwrite the information generated by explainProcess. This method must be called before an ExpressionView is explained


getGraphicSolution

public java.util.Vector getGraphicSolution()
This method will not work correctly unless expression.evaluate() is called first - which is called in the constructor. expression.evaluate() is handed off to operatorModel.evaluate() for each operator so that the expression is evaluated, and the intermediate results are stored in value. You must also call OperatorView.paintExpression() before calling this because paintExpression sets the left and right coordinates of operators and operands, needed for generating this expalantion. This method first generates the underbrace explanations through operatorView.explain(), reorders the underbraces as per the order of operator evaluation determined by Expression.createTree() in order to enforce associativity etc.


getTextSolution

public void getTextSolution(java.util.Vector explanation)
This method will not work correctly unless expression.evaluate() is called first which is actually called in the constructor. Returns text explanation of the expression after stripping explanation inappropriate for graphic display (such as line numbers etc)


main

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