FloatControlpublic abstract class FloatControl extends Control A FloatControl object provides control over a range of
floating-point values. Float controls are often
represented in graphical user interfaces by continuously
adjustable objects such as sliders or rotary knobs. Concrete subclasses
of FloatControl implement controls, such as gain and pan, that
affect a line's audio signal in some way that an application can manipulate.
The {@link FloatControl.Type}
inner class provides static instances of types that are used to
identify some common kinds of float control.
The FloatControl abstract class provides methods to set and get
the control's current floating-point value. Other methods obtain the possible
range of values and the control's resolution (the smallest increment between
returned values). Some float controls allow ramping to a
new value over a specified period of time. FloatControl also
includes methods that return string labels for the minimum, maximum, and midpoint
positions of the control. |
Fields Summary |
---|
private float | minimumThe minimum supported value. | private float | maximumThe maximum supported value. | private float | precisionThe control's precision. | private int | updatePeriodThe smallest time increment in which a value change
can be effected during a value shift, in microseconds. | private final String | unitsA label for the units in which the control values are expressed,
such as "dB" for decibels. | private final String | minLabelA label for the minimum value, such as "Left." | private final String | maxLabelA label for the maximum value, such as "Right." | private final String | midLabelA label for the mid-point value, such as "Center." | private float | valueThe current value. |
Constructors Summary |
---|
protected FloatControl(Type type, float minimum, float maximum, float precision, int updatePeriod, float initialValue, String units, String minLabel, String midLabel, String maxLabel)Constructs a new float control object with the given parameters
super(type);
this.minimum = minimum;
this.maximum = maximum;
this.precision = precision;
this.updatePeriod = updatePeriod;
this.value = initialValue;
this.units = units;
this.minLabel = ( (minLabel == null) ? "" : minLabel);
this.midLabel = ( (midLabel == null) ? "" : midLabel);
this.maxLabel = ( (maxLabel == null) ? "" : maxLabel);
| protected FloatControl(Type type, float minimum, float maximum, float precision, int updatePeriod, float initialValue, String units)Constructs a new float control object with the given parameters.
The labels for the minimum, maximum, and mid-point values are set
to zero-length strings.
this(type, minimum, maximum, precision, updatePeriod, initialValue, units, "", "", "");
|
Methods Summary |
---|
public java.lang.String | getMaxLabel()Obtains the label for the maximum value, such as "Right" or "Full."
return maxLabel;
| public float | getMaximum()Obtains the maximum value permitted.
return maximum;
| public java.lang.String | getMidLabel()Obtains the label for the mid-point value, such as "Center" or "Default."
return midLabel;
| public java.lang.String | getMinLabel()Obtains the label for the minimum value, such as "Left" or "Off."
return minLabel;
| public float | getMinimum()Obtains the minimum value permitted.
return minimum;
| public float | getPrecision()Obtains the resolution or granularity of the control, in the units
that the control measures.
The precision is the size of the increment between discrete valid values
for this control, over the set of supported floating-point values.
return precision;
| public java.lang.String | getUnits()Obtains the label for the units in which the control's values are expressed,
such as "dB" or "frames per second."
return units;
| public int | getUpdatePeriod()Obtains the smallest time interval, in microseconds, over which the control's value can
change during a shift. The update period is the inverse of the frequency with which
the control updates its value during a shift. If the implementation does not support value shifting over
time, it should set the control's value to the final value immediately
and return -1 from this method.
return updatePeriod;
| public float | getValue()Obtains this control's current value.
return value;
| public void | setValue(float newValue)Sets the current value for the control. The default implementation
simply sets the value as indicated. If the value indicated is greater
than the maximum value, or smaller than the minimum value, an
IllegalArgumentException is thrown.
Some controls require that their line be open before they can be affected
by setting a value.
if (newValue > maximum) {
throw new IllegalArgumentException("Requested value " + newValue + " exceeds allowable maximum value " + maximum + ".");
}
if (newValue < minimum) {
throw new IllegalArgumentException("Requested value " + newValue + " smaller than allowable minimum value " + minimum + ".");
}
value = newValue;
| public void | shift(float from, float to, int microseconds)Changes the control value from the initial value to the final
value linearly over the specified time period, specified in microseconds.
This method returns without blocking; it does not wait for the shift
to complete. An implementation should complete the operation within the time
specified. The default implementation simply changes the value
to the final value immediately.
setValue(to);
| public java.lang.String | toString()Provides a string representation of the control
return new String(getType() + " with current value: " + getValue() + " " + units +
" (range: " + minimum + " - " + maximum + ")");
|
|