org.problets.domain.model.expression.node.operator.misc
Class ParenthesisView

java.lang.Object
  extended by org.problets.domain.model.expression.node.NodeView
      extended by org.problets.domain.model.expression.node.operator.OperatorView
          extended by org.problets.domain.model.expression.node.operator.misc.ParenthesisView
All Implemented Interfaces:
java.lang.Cloneable

public class ParenthesisView
extends OperatorView

To keep track of displaying a parenthesized expression, and underbraces

Author:
Amruth Kumar

Constructor Summary
ParenthesisView(NodeModel inOperator)
           
 
Method Summary
 void classifyNodes(java.util.Vector operatorViewVector, java.util.Vector operandViewVector)
          Does an in-order traversal of the view tree (to preserve left to right order) and adds leaf operators to operatorView, and leaf operands to operandView
 void explain(java.util.Vector explanation)
          Graphically explains the evaluation of the expression as opposed to textual explanation by the model
 NodeView getCopyIfExists(java.util.Vector availableViews, java.lang.String presumedValue)
          If actualNodeView exists in availableViews, return a copy of it, else return null actualNodeView is part of the actual answer, an OperatorView or OperandView object.
 boolean isCovered(int leftCoord, int rightCoord)
          Returns true if this node is straddled by leftX and rightX, and false otherwise.
 void paintExpression(java.awt.Graphics g, int y)
          Method should be called only after this node has been typeset first
static java.util.Vector stripParentheses(java.util.Vector originalVector)
          Given a vector of ExpressionViewStep objects, strip all that correspond to parenthesis
 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 org.problets.domain.model.expression.node.operator.OperatorView
getContentWidth
 
Methods inherited from class org.problets.domain.model.expression.node.NodeView
clone, getBackupLeftX, getBackupRightX, getContent, getFontMetrics, getLeftChild, getLeftMax, getLeftMin, getLeftX, getNode, getNodeView, getRightChild, getRightMax, getRightMin, getRightX, getSideEffects, getValue, print, setLeftChild, setRightChild, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParenthesisView

public ParenthesisView(NodeModel inOperator)
Method Detail

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.

Overrides:
typeset in class NodeView

paintExpression

public void paintExpression(java.awt.Graphics g,
                            int y)
Method should be called only after this node has been typeset first

Overrides:
paintExpression in class NodeView

classifyNodes

public void classifyNodes(java.util.Vector operatorViewVector,
                          java.util.Vector operandViewVector)
Does an in-order traversal of the view tree (to preserve left to right order) and adds leaf operators to operatorView, and leaf operands to operandView

Overrides:
classifyNodes in class NodeView

isCovered

public boolean isCovered(int leftCoord,
                         int rightCoord)
Returns true if this node is straddled by leftX and rightX, and false otherwise. This method is used by ExpressionProblemView to check which NodeView objects in the correct answer were covered by an underbrace drawn by a student. Original design - brought back: // If parenthesis is to be treated as a separate step, do so, // else, return if the underbrace covers the root of the embedded expression Current design - abandoned: // Actually, return whether this ParenthesisView was selected. // This will help generate the correct expression for the intermediate result dialog box // e.g., ! ( 3 < 5 ) instead of ! 3 < 5 // We will build a separate Parenthesis node in student answer if student has selected one // If isSeparateStep is false, we will simply ignore this additional node during grading. // Hence, the entire function is commented out in favor of OperatorView's function

Overrides:
isCovered in class NodeView

getCopyIfExists

public NodeView getCopyIfExists(java.util.Vector availableViews,
                                java.lang.String presumedValue)
If actualNodeView exists in availableViews, return a copy of it, else return null actualNodeView is part of the actual answer, an OperatorView or OperandView object. availableViews consists of OperandViews and StudentNodeViews/BailedOutStudentNodeViews. Short-circuits any newly constructed operator nodes

Overrides:
getCopyIfExists in class OperatorView

stripParentheses

public static java.util.Vector stripParentheses(java.util.Vector originalVector)
Given a vector of ExpressionViewStep objects, strip all that correspond to parenthesis


explain

public void explain(java.util.Vector explanation)
Graphically explains the evaluation of the expression as opposed to textual explanation by the model

Overrides:
explain in class OperatorView