Logo Search packages:      
Sourcecode: wims version File versions  Download package

edu::hws::jcm::awt::VariableInput Class Reference

Inheritance diagram for edu::hws::jcm::awt::VariableInput:

edu::hws::jcm::awt::InputObject edu::hws::jcm::awt::Tieable edu::hws::jcm::data::Value

List of all members.


Detailed Description

A VariableInput is an input box into which the user can type a real number value, which becomes the value of an associated Variable. The value of the Variable can change only when the VariableInput's checkInput() method is called (usually by a Controller). See the Controller class for more information.

Whenever checkInput is called, an error of type JCMError might be generated. If throwErrors is true, this error is thrown; if it is false, the error is caught, the value of the variable is set to Double.NaN, and no error is thrown. The error message associated with the error can be retrieved by calling getErrorMessage(), if desired. (This value is null if no error occurred the last time checkInput was called.)

A VariableInput is a Value, so it can be used directly where a Value object is needed.

An VariableInput will ordinarily be registered with a Controller in TWO ways: It's added to a Controller with the Controller's add() method. This makes the Controller call the VariableInput's checkInput() method during the Controller's compute() method. Secondly, a Controller is set as the "onUserAction" property. This causes the Controller's compute() method to be called when the user presses return in the VariableInput box. This is optional-- you might, for example, only want the Controller to compute() when a Compute button is pressed. You can also set the VariableInput's onTextChange property to a Controller that you want to compute every time the text in the box changes.

After the VariableInput is created, it is possible to specify the largest and smallest allowed values for the variable. It is also possible to specify what sytle of input is allowed. The style can be to allow any constant expression, constant real numbers only, or integers only. Set these parameters with setMin(), setMax(), and setInputStyle(). For setInputStyle(), the legal parameter values are VariableInput.EXPRESSION, VariableInput.REAL, and VariableInput.INTEGER. The default input style is EXPRESSION.

Definition at line 73 of file VariableInput.java.


Public Member Functions

void addTo (Parser p)
void checkInput ()
String getErrorMessage ()
int getInputStyle ()
double getMax ()
double getMin ()
Controller getOnTextChange ()
Controller getOnUserAction ()
long getSerialNumber ()
boolean getThrowErrors ()
double getVal ()
Variable getVariable ()
void notifyControllerOnChange (Controller c)
void processActionEvent (ActionEvent evt)
void processKeyEvent (KeyEvent evt)
void processTextEvent (TextEvent evt)
void setInputStyle (int style)
void setMax (double max)
void setMin (double min)
void setName (String name)
void setOnTextChange (Controller c)
void setOnUserAction (Controller c)
void setText (String text)
void setThrowErrors (boolean throwErrors)
void setVal (double d)
void sync (Tie tie, Tieable newest)
 VariableInput (String name, String initialString, Parser parser)
 VariableInput (String name, String initialString)
 VariableInput ()
JCMPanel withLabel (Color back, Color fore)
JCMPanel withLabel ()

Static Public Attributes

static final int EXPRESSION = 0
static final int INTEGER = 2
static final int REAL = 1

Protected Member Functions

double convertInput (String num)

Protected Attributes

String errorMessage
boolean hasChanged
int inputStyle = 0
double maxValue = Double.MAX_VALUE
double minValue = -Double.MAX_VALUE
long serialNumber
boolean throwErrors
VI variable

Private Member Functions

void justSetText (String text)

Private Attributes

transient Parser constantParser
Controller onTextChange
Controller onUserAction

Classes

class  VI

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index