Class FloatControl
- java.lang.Object
-
- de.xima.fc.gui.model.value_descriptor_form.Control
-
- de.xima.fc.gui.model.value_descriptor_form.ValueReferencingControl
-
- de.xima.fc.gui.model.value_descriptor_form.EditableControl<Number>
-
- de.xima.fc.gui.model.value_descriptor_form.FloatControl
-
- All Implemented Interfaces:
Serializable
public final class FloatControl extends EditableControl<Number>
AControlfor float values that must conform to aIFloatValueDescriptor.- Since:
- 8.5.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FloatControl(IValueAccessor<?> root, String path, IFloatValueDescriptor descriptor)Creates a new float control.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected NumbercoerceValue(Object value)Coerces the given value to conform to the restrictions imposed by the value descriptor.DoublegetDoubleValue()Gets the field's current value as a double.doublegetMax()Gets the maximum allowed value, if any.doublegetMin()Gets the minimum allowed value, if any.booleanisHasMax()Checks whether a maximum value is set.booleanisHasMin()Checks whether a minimum value is set.voidsetDoubleValue(Double value)Sets the field's value as a double.voidsetRange(com.google.common.collect.Range<Double> range)Sets the allowed value range.-
Methods inherited from class de.xima.fc.gui.model.value_descriptor_form.EditableControl
getDescription, getLabel, getValue, isFcPlaceholders, isRequired, setDescription, setFcPlaceholders, setLabel, setRequired, setValue
-
Methods inherited from class de.xima.fc.gui.model.value_descriptor_form.ValueReferencingControl
readValue, writeValue
-
-
-
-
Constructor Detail
-
FloatControl
public FloatControl(IValueAccessor<?> root, String path, IFloatValueDescriptor descriptor)
Creates a new float control.- Parameters:
root- The root object against which the path is evaluated.path- The JSON path expression that references the value.descriptor- The descriptor that describes the float value being edited.
-
-
Method Detail
-
getDoubleValue
public Double getDoubleValue()
Gets the field's current value as a double. If the value is null, returns 0.- Returns:
- The field's current value as a double.
-
setDoubleValue
public void setDoubleValue(Double value)
Sets the field's value as a double.- Parameters:
value- The new value to set.
-
getMax
public double getMax()
Gets the maximum allowed value, if any. If no maximum is set, returnsDouble.POSITIVE_INFINITY.- Returns:
- The maximum allowed value, or
Double.POSITIVE_INFINITYif no maximum is set.
-
getMin
public double getMin()
Gets the minimum allowed value, if any. If no minimum is set, returnsDouble.NEGATIVE_INFINITY.- Returns:
- The minimum allowed value, or
Double.NEGATIVE_INFINITYif no minimum is set.
-
isHasMax
public boolean isHasMax()
Checks whether a maximum value is set.- Returns:
- true if a maximum value is set, false otherwise.
-
isHasMin
public boolean isHasMin()
Checks whether a minimum value is set.- Returns:
- true if a minimum value is set, false otherwise.
-
setRange
public void setRange(com.google.common.collect.Range<Double> range)
Sets the allowed value range. If the range has no lower bound, the minimum is set toDouble.NEGATIVE_INFINITY. If the range has no upper bound, the maximum is set toDouble.POSITIVE_INFINITY.- Parameters:
range- The allowed value range, or null to allow all values.
-
coerceValue
protected Number coerceValue(Object value)
Description copied from class:EditableControlCoerces the given value to conform to the restrictions imposed by the value descriptor. This method is called byEditableControl.getValue()andEditableControl.setValue(Object)to ensure that the value is always valid.- Specified by:
coerceValuein classEditableControl<Number>- Parameters:
value- The value to coerce.- Returns:
- The coerced value.
-
-