|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuchicago.src.sim.math.CEquation
public class CEquation
A user specifiable evaluatable equation. This class will evaluate a specified equation replacing the variables in the equation with values from a specified object. The result of the equation evaluation will then be written to the object.
When evaluated a CEquation will replace the variables in the specified equation with those read from a specified object. For example, if the equation is "x + 1 * z", then evaluation will replace x and z in the equation with the results of calling getX() and getZ() on the object. The result of this evaluation will be assigned to the a resultVar in a similar manner. For example, if the resultVar is "y", then on assignment the result of the equation evaluation will be assigned to the object via the object's setY(double) method.
The variable "t" can also be used. "t" is replaced by the value of the current tick count. Similarly, the variable "dt" can be used. It will be set to the delta of the current tick count and the tick count at which the last evaluation occured. Evaluation is performed using the
evaluate method and assignment is
performed using the assign method.
| Constructor Summary | |
|---|---|
CEquation(java.lang.Object target,
TickCounter counter,
java.lang.String equation,
java.lang.String resultVar)
Creates a CEquation from the specified parameters. |
|
CEquation(java.lang.Object target,
TickCounter counter,
java.lang.String equation,
java.lang.String resultVar,
double initialDTValue)
Creates a CEquation from the specified parameters. |
|
| Method Summary | |
|---|---|
void |
assign()
Assigns the result of the last call to evaluate to the result variable of the
target specified in the constructor. |
void |
evaluate()
Evaluates the equation encapsulated by this CEquation. |
void |
evaluateAndAssign()
Evaluates the currently encapsulated equation and assigns the result to the result variable. |
java.lang.String |
getEquation()
|
void |
setEquation(java.lang.String equation)
Sets the equation to evalute. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CEquation(java.lang.Object target,
TickCounter counter,
java.lang.String equation,
java.lang.String resultVar)
The variable "t" can also be used. "t" is replaced by the value of the current tick count. Similarly, the variable "dt" can be used. It will be set to the delta of the current tick count and the tick count at which the last evaluation occured. dt defaults to a value of 0 on the first evaluation. Use the alternate constructor to specify a different initial value. Evaluation is performed using the
evaluate method and assignment is
performed using the assign method.
target - the target from which the equations variable values are read and to which the
result is assignedcounter - a TickCounter from which the value of the "t" variable can be setequation - the equation to evaluate.resultVar - the name of the variable to assign the result to
public CEquation(java.lang.Object target,
TickCounter counter,
java.lang.String equation,
java.lang.String resultVar,
double initialDTValue)
The variable "t" can also be used. "t" is replaced by the value of the current tick count. Similarly, the variable "dt" can be used. It will be set to the delta of the current tick count and the tick count at which the last evaluation occured. Evaluation is performed using the
evaluate method and assignment is
performed using the assign method.
target - the target from which the equations variable values are read and to which the
result is assignedcounter - a TickCounter from which the value of the "t" variable can be setequation - the equation to evaluate.resultVar - the name of the variable to assign the result toinitialDTValue - the initial value of dt to use on the first evaluation when
it would otherwise be set to 0| Method Detail |
|---|
public void evaluate()
evaluate() call with
a call to assign() or alternatively call evaluateAndAssign().
assign(),
evaluateAndAssign()public void assign()
evaluate to the result variable of the
target specified in the constructor.
public void evaluateAndAssign()
public java.lang.String getEquation()
public void setEquation(java.lang.String equation)
equation -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||