public class BooleanControl extends DynamicControlParent
DynamicControl classes of type ControlType.BOOLEAN in a simple API.
BooleanControl objects with the same name and ControlScope will respond to a setValue(Boolean).
For example, consider two BooleanControls with the same ControlScope and name
BooleanControl control1 = new BooleanControl(this, "Read", false);
BooleanControl control2 = new BooleanControl(this, "Read", false) {
@Override
public void valueChanged(Boolean control_val) {
System.out.println("Read " + control_val);
}
};// End DynamicControl control2 code
control1.setValue(true); // Setting control1 will also set control2
valueChanged(Boolean) function to be called with the new value, causing Read true to be printed to standard output
setValue(Boolean, double) function. Eg: ControlScope and name, to true 1 second in the future
getValue()
If you require a handler on the class, override valueChanged(Boolean) function| Constructor and Description |
|---|
BooleanControl(java.lang.Object parent_sketch,
java.lang.String name,
java.lang.Boolean initial_value)
Constructor for abstract FloatControl.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Boolean |
getValue()
Get the value for the control
|
BooleanControl |
setControlScope(ControlScope new_scope)
Changed the
ControlScope the object has has. |
BooleanControl |
setDisplayType(DynamicControl.DISPLAY_TYPE display_type)
Change how to display object as
DynamicControl.DISPLAY_TYPE |
void |
setValue(java.lang.Boolean val)
set the value for the control.
|
void |
setValue(java.lang.Boolean val,
double scheduler_time)
Identical to the
setValue(Boolean) with the exception that the valueChanged(Boolean) event will be caused at the HBScheduler scheduled time passed in. |
void |
valueChanged(java.lang.Boolean control_val)
Fired event that occurs when the value for the control has been set.
|
addControlListener, addControlScopeListener, addControlTarget, addControlTarget, clearControlTargets, getDynamicControl, getSendingDevice, removeControlListener, removeControlScopeChangedListener, removeControlTarget, removeControlTarget, removeListeners, setControlTarget, setControlTargetpublic BooleanControl(java.lang.Object parent_sketch,
java.lang.String name,
java.lang.Boolean initial_value)
parent_sketch - The parent object for controlname - The name to Displayinitial_value - Initial value of the objectpublic java.lang.Boolean getValue()
BooleanControl control1 = new BooleanControl(this, "Read", false);
boolean val = control1.getValue(); // val will be false
control1.setValue(true);
val = control1.getValue(); // val will be true
public void valueChanged(java.lang.Boolean control_val)
DynamicControl with matching name, type and ControlScope and call valueChanged(Boolean).
The function must be implemented when creating objects
BooleanControl control1 = new BooleanControl(this, "Read", false);
BooleanControl control2 = new BooleanControl(this, "Read", false) {
@Override
public void valueChanged(Boolean control_val) {
System.out.println("Read " + control_val);
}
};// End DynamicControl control2 code
control1.setValue(true);// Setting control1 will also set control2
valueChanged(Boolean) function to be called with the new value, causing Read true to be printed to standard outputcontrol_val - The new value of the controlpublic void setValue(java.lang.Boolean val)
ControlScope. For example
BooleanControl control1 = new BooleanControl(this, "Read", false);
BooleanControl control2 = new BooleanControl(this, "Read", false) {
@Override
public void valueChanged(Boolean control_val) {
System.out.println("Read " + control_val);
}
};// End DynamicControl control2 code
control1.setValue(true); // Setting control1 will also set control2
valueChanged(Boolean) function to be called with the new value, causing Read true to be printed to standard output
setValue(Boolean, double) function.val - the value to set topublic void setValue(java.lang.Boolean val,
double scheduler_time)
setValue(Boolean) with the exception that the valueChanged(Boolean) event will be caused at the HBScheduler scheduled time passed in.
DynamicControl objects to respond 1 second in the future
BooleanControl control1 = new BooleanControl(this, "Read", false);
BooleanControl control2 = new BooleanControl(this, "Read", false) {
@Override
public void valueChanged(Boolean control_val) {
System.out.println("Read " + control_val);
}
};// End DynamicControl control2 code
control1.setValue(true, HB.getSchedulerTime() + 1000); // Setting control1 will also set control2
valueChanged(Boolean) function to be called with the new value one second in the future, causing Read true to be printed to standard output one second in the futureval - the value to set toscheduler_time - the scheduler time this is supposed to occur atpublic BooleanControl setControlScope(ControlScope new_scope)
ControlScope the object has has. It will update control map so the correct events will be generated based on its scopesetControlScope in class DynamicControlParentnew_scope - The new Control Scopepublic BooleanControl setDisplayType(DynamicControl.DISPLAY_TYPE display_type)
DynamicControl.DISPLAY_TYPEdisplay_type - The new Control Scope