com.numobjects.mathbeans.awt
Class CalcField

com.numobjects.mathbeans.awt.CalcField

public class CalcField
implements java.io.Serializable

Class CalcField (Calculator enabled field bean) provides the following functionality: it is a text field in which the user can enter any constant mathematical expression and press Enter. If the syntax of the expression is correct, it gets computed and displayed in the same field. The user can set parameters that control the format of the output. The field has an optional cyclic history buffer controlled by up/down keys.

An example of a constant expression is e.g.

18562*113-34/3

or

0.5 - sin (PI/3) + exp (sqrt(3.654))

An expression like

sin(x)

or

t+1

or

y=2+2

is NOT constant since it contains variables. See Expression syntax and available functions for a full description of syntax, available functions and procedures.

See Also:
CalcPanel, CalcGraphPanel, Serialized Form

Constructor Summary
CalcField()
          Constructs a new CalcField
CalcField(java.lang.String text)
          Constructs a new CalcField
 
Method Summary
 void error()
          Sets error
 int getBufferSize()
          Gets expression history buffer size
 int getPrecision()
          Gets precision
 int getRounding()
          Gets rounding
 java.lang.String getValue(boolean translate)
          Gets value
 void setBufferSize(int bufferSize)
          Sets expression history buffer size; range >= 0, default value 6, 0 means expressions not memorized
 void setPrecision(int value)
          Sets precision (the number of significant digits in the calculation); range 1 - 15, default precision is 6
 void setRounding(int value)
          Sets rounding (the number of digits displayed after the decimal dot); range -1 - 15, default rounding is -1 (no rounding)
 void setValue(java.lang.String value, boolean translate)
          Sets value
 

Constructor Detail

CalcField

public CalcField()
Constructs a new CalcField

CalcField

public CalcField(java.lang.String text)
Constructs a new CalcField
Parameters:
initial - text
Method Detail

setPrecision

public void setPrecision(int value)
Sets precision (the number of significant digits in the calculation); range 1 - 15, default precision is 6
Parameters:
value - precision to set

getPrecision

public int getPrecision()
Gets precision
Returns:
precision value (the number of significant digits in the calculation)

setRounding

public void setRounding(int value)
Sets rounding (the number of digits displayed after the decimal dot); range -1 - 15, default rounding is -1 (no rounding)
Parameters:
value - rounding

getRounding

public int getRounding()
Gets rounding
Returns:
rounding value (the number of digits displayed after the decimal dot)

setBufferSize

public void setBufferSize(int bufferSize)
Sets expression history buffer size; range >= 0, default value 6, 0 means expressions not memorized
Parameters:
bufferSize - buffer size to set

getBufferSize

public int getBufferSize()
Gets expression history buffer size
Returns:
buffer size

error

public void error()
Sets error

getValue

public java.lang.String getValue(boolean translate)
Gets value
Parameters:
translate - translation flag

setValue

public void setValue(java.lang.String value,
                     boolean translate)
Sets value
Parameters:
value - value string
translate - translation flag