|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--freegraph.ExpressionEvaluator
ExpressionEvaluator takes an expression as a String and evaluates the expression. Values of single character variables may be set. The ExpressionEvaluator uses and ExpressionStack to convert the expression to postfix for evaluation.
ExpressionEvaluator implements GraphPlaneItem to draw the graph of function on GraphPlane.
GraphPlane,
ExpressionStack| Constructor Summary | |
ExpressionEvaluator()
constructs a new ExpressionEvaluator with an empty expression |
|
ExpressionEvaluator(java.lang.String expression)
constructs a new ExpressionEvaluator with expression |
|
| Method Summary | |
void |
drawItem(GraphPlane graphPlane,
java.awt.Graphics g,
char variableChar)
called by GraphPlane to draw this GraphPlaneItem. |
double |
evaluate()
evaluates the expression using the current variable values and returns the result (ExpressionEvaluator does some down casting on the ExpressionItems when evaluating expressions. |
java.awt.Color |
getColor()
returns the color of the expression. |
java.lang.String |
getExpression()
returns the expression as the String it was set with. |
VariableValues |
getVariables()
returns the VariableValues object representing the variables for this expression evaluator. |
void |
setColor(java.awt.Color newColor)
sets the color of the expression. |
void |
setExpression(java.lang.String expression)
sets the expression for the evaluator. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public ExpressionEvaluator()
public ExpressionEvaluator(java.lang.String expression)
throws ExpressionException
expression - the expression to evaluate| Method Detail |
public void setExpression(java.lang.String expression)
throws ExpressionException
ExpressionExceptionpublic java.lang.String getExpression()
public java.awt.Color getColor()
public void setColor(java.awt.Color newColor)
public VariableValues getVariables()
public double evaluate()
public void drawItem(GraphPlane graphPlane,
java.awt.Graphics g,
char variableChar)
drawItem in interface GraphPlaneItemgraphPlane - the GraphPlane on which to draw the expressiong - the Graphics object for graphPlanevariableChar - the varible in the expression for the X axis
(typically "x")public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||