public class FloatControl extends DynamicControlParent
DynamicControl
classes of type ControlType.FLOAT
in a simple API
FloatControl
controls with the same name and ControlScope
will respond to a message send. For example:
For example, consider two FloatControl
objects with the same ControlScope
and name
valueChanged(double)
)} listener that is implemented when the class is created.
FloatControl control1 = new FloatControl(this, "Read", 1.0); FloatControl control2 = new FloatControl(this, "Read", 1.0){ @Override public void valueChanged(double new_value){ System.out.println("Read "+ new_value); } } // Setting the value of control1 will cause any objects listening to control1 or control2 to receive the action. EG control1.setValue(2.0); // This will also set the value of control2reflected in its
valueChanged(double)
function, causing Read 2.0 to be printed to standard output.
setValue(double, double)
function. Eg
ControlScope
and name, to true 1 second in the future
If you require a handler on the class, use the valueChanged(double)
classConstructor and Description |
---|
FloatControl(java.lang.Object parent_sketch,
java.lang.String name,
double initial_value)
Constructor for abstract FloatControl.
|
FloatControl(java.lang.Object parent_sketch,
java.lang.String name,
double initial_value,
double min_val,
double max_val,
DynamicControl.DISPLAY_TYPE display_type)
Constructor for abstract FloatControl.
|
Modifier and Type | Method and Description |
---|---|
double |
getValue()
Get the value for the control
|
FloatControl |
setControlScope(ControlScope new_scope)
Changed the
ControlScope the object has has. |
FloatControl |
setDisplayRange(double minimum,
double maximum,
DynamicControl.DISPLAY_TYPE display_type)
Set how we want this control displayed
|
FloatControl |
setDisplayType(DynamicControl.DISPLAY_TYPE display_type)
Change how to display object
We must do this in subclass
|
void |
setValue(double val)
Set the value for the control.
|
void |
setValue(double val,
double scheduler_time)
Identical to the
setValue(double) with the exception that the valueChanged(double) event will be caused at the HBScheduler scheduled time passed in. |
void |
valueChanged(double control_val)
When the control receives the value, it will be passed through to the valueChanged(double) listener that is implemented when the class is created. |
addControlListener, addControlScopeListener, addControlTarget, addControlTarget, clearControlTargets, getDynamicControl, getSendingDevice, removeControlListener, removeControlScopeChangedListener, removeControlTarget, removeControlTarget, removeListeners, setControlTarget, setControlTarget
public FloatControl(java.lang.Object parent_sketch, java.lang.String name, double initial_value, double min_val, double max_val, DynamicControl.DISPLAY_TYPE display_type)
parent_sketch
- The parent object for controlname
- The name to Displayinitial_value
- Initial value of the objectmin_val
- Minimum value to display on Slidermax_val
- Maximum value to display on Sliderdisplay_type
- The way we want object displayedpublic FloatControl(java.lang.Object parent_sketch, java.lang.String name, double initial_value)
parent_sketch
- The parent object for controlname
- The name to Displayinitial_value
- Initial value of the objectpublic double getValue()
FloatControl control1 = new FloatControl(this, "Read", 1.0); double val = control1.getValue(); // val will be 1.0 control1.setValue(2.0); val = control1.getValue(); // val will be 2.0
public void valueChanged(double control_val)
valueChanged(double)
listener that is implemented when the class is created.
FloatControl control1 = new FloatControl(this, "Read", 1.0); FloatControl control2 = new FloatControl(this, "Read", 1.0){ @Override public void valueChanged(double new_value){ System.out.println("Read "+ new_value); } } // Setting the value of control1 will cause any objects listening to control1 or control2 to receive the action. EG control1.setValue(2.0); // This will also set the value of control2reflected in its
valueChanged(double)
function, causing Read 2.0 to be printed to standard output.
control_val
- the value receivedpublic void setValue(double val)
DynamicControl
with matching name, type and ControlScope
and call valueChanged(double)
.
FloatControl
controls with the same name and ControlScope
will respond to a message send. For example:
* For example, consider two FloatControl
objects with the same ControlScope
and name
FloatControl control1 = new FloatControl(this, "Read", 1.0); FloatControl control2 = new FloatControl(this, "Read", 1.0){ @Override public void valueChanged(double new_value){ System.out.println("Read "+ new_value); } } // Setting the value of control1 will cause any objects listening to control1 or control2 to receive the action. EG control1.setValue(2.0); // This will also set the value of control2reflected in its
valueChanged(double)
function, causing Read 2.0 to be printed to standard output.val
- the value to set the control topublic void setValue(double val, double scheduler_time)
setValue(double)
with the exception that the valueChanged(double)
event will be caused at the HBScheduler
scheduled time passed in.
DynamicControl
objects to respond 1 second in the future
FloatControl control1 = new FloatControl(this, "Read", 1.0); FloatControl control2 = new FloatControl(this, "Read", 1.0){ @Override public void valueChanged(double new_value){ System.out.println("Read "+ new_value); } } // Setting the value of control1 will cause any objects listening to control1 or control2 to receive the action. EG control1.setValue(2.0, HB.getSchedulerTime() + 1000); // This will also set the value of control2
val
- the value to set toscheduler_time
- the HBScheduler
time this is supposed to occur atpublic FloatControl setDisplayType(DynamicControl.DISPLAY_TYPE display_type)
display_type
- The new Control Scopepublic FloatControl 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 DynamicControlParent
new_scope
- The new Control Scopepublic FloatControl setDisplayRange(double minimum, double maximum, DynamicControl.DISPLAY_TYPE display_type)
minimum
- minimum display value on slidermaximum
- maximum display value on sliderdisplay_type
- the type of display