Top Description Fields Constructors Methods
com.dlsc.unitfx

public Class QuantityInputField<Q extends Quantity<Q>>

extends QuantityInputControl<Q extends Quantity<Q>>
Class Inheritance
Imports
com.dlsc.unitfx.skins.QuantityInputFieldSkin, com.dlsc.unitfx.util.ControlsUtil, .QuantitiesUtil, javafx.beans.InvalidationListener, javafx.beans.property.BooleanProperty, .ObjectProperty, .ReadOnlyBooleanProperty, .ReadOnlyBooleanWrapper, .ReadOnlyObjectProperty, .ReadOnlyObjectWrapper, .SimpleBooleanProperty, .SimpleObjectProperty, javafx.collections.MapChangeListener, javafx.css.PseudoClass, javafx.scene.control.Skin, javax.measure.Quantity, .Unit, java.util.function.Predicate

Concrete implementation of QuantityInputControl that uses a Double > to let users enter values.

Field Summary

Modifier and TypeField and Description
private final BooleanProperty
private final BooleanProperty
private final ReadOnlyBooleanWrapper
private final ObjectProperty<Double>
private final ObjectProperty<Double>
private final ObjectProperty<Double>
private final ReadOnlyObjectWrapper<Quantity<Q>>
private final ObjectProperty<Unit<Q>>
private final ReadOnlyBooleanWrapper
private final ObjectProperty<Predicate<Double>>

Constructor Summary

AccessConstructor and Description
public
QuantityInputField()

Instances a new input field with no available units, null value and no precision.

Method Summary

Modifier and TypeMethod and Description
public final BooleanProperty

Returns:

The boolean property.
allowNegativesProperty
()

Boolean property that tells the control to allow introducing a negative quantity.

public final BooleanProperty

Returns:

The boolean property.
autoFixValueProperty
()

Boolean property used to automatically convert the valueProperty() when the unitProperty() is changed.

private void
private void
private void
protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public final Double
public final Double
public final Double
public final Quantity<Q>
public final Unit<Q>
public String
getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method.

public final Predicate<Double>
public final ReadOnlyBooleanProperty

Returns:

The property that holds the flag.
invalidProperty
()

Property that indicates when the value entered violates restrictions of minimum and maximum values.

public final boolean
public final boolean
public final boolean
public final boolean
private void
private void
public final ObjectProperty<Double>

Returns:

The maximum value.
maximumValueProperty
()

The maximum value that can be entered in this field.

public final ObjectProperty<Double>

Returns:

The minimum value.
minimumValueProperty
()

The minimum value that can be entered in this field.

public final ObjectProperty<Double>
precisionProperty()

Integer used to truncate the value entered by the user and calculate the quantity.

public final ReadOnlyObjectProperty<Quantity<Q>>

Returns:

The read only property storing the precision quantity.
precisionQuantityProperty
()

Represents the precision as combination of precisionProperty() ()} and precisionUnitProperty().

public final ObjectProperty<Unit<Q>>

Returns:

The base unit.
precisionUnitProperty
()

Represents the system base unit, which is the default one for the control.

public final void
restoreValueProperty()

Applies the valueQuantityProperty() to the valueProperty() simulating a restore operation.

public final void
setAllowNegatives(boolean allowNegatives)

public final void
setAutoFixValue(boolean autoFixValue)

private void
setInvalid(boolean invalid)

public final void
setMaximumValue(Double maximumValue)

public final void
setMinimumValue(Double minimumValue)

public final void
setPrecision(Double precision)

private void
setPrecisionQuantity(Quantity<Q> precisionQuantity)

public final void
setPrecisionUnit(Unit<Q> precisionUnit)

private void
setValueDirty(boolean valueDirty)

public final void
pack-priv void
pack-priv void
public final ReadOnlyBooleanProperty

Returns:

The boolean property.
valueDirtyProperty
()

Boolean property that indicates when the value and the valueQuantity are different because after a precision was applied.

public final ObjectProperty<Predicate<Double>>

Returns:

The property storing the validator predicate.
valueValidatorProperty
()

Stores a validator object for the value converted from text entered.

Inherited from com.dlsc.unitfx.QuantityInputControl:
baseUnitPropertygetAvailableUnitsgetBaseUnitgetNumberOfDecimalsgetNumberOfIntegersgetUnitgetUnitStringConvertergetValuegetValueQuantityisReadOnlynumberOfDecimalsPropertynumberOfIntegersPropertyreadOnlyPropertysetBaseUnitsetNumberOfDecimalssetNumberOfIntegerssetReadOnlysetUnitsetUnitStringConvertersetValuesetValueQuantityunitPropertyunitStringConverterPropertyvaluePropertyvalueQuantityProperty

Field Detail

allowNegativesback to summary
private final BooleanProperty allowNegatives
autoFixValueback to summary
private final BooleanProperty autoFixValue
invalidback to summary
private final ReadOnlyBooleanWrapper invalid
maximumValueback to summary
private final ObjectProperty<Double> maximumValue
minimumValueback to summary
private final ObjectProperty<Double> minimumValue
precisionback to summary
private final ObjectProperty<Double> precision
precisionQuantityback to summary
private final ReadOnlyObjectWrapper<Quantity<Q>> precisionQuantity
precisionUnitback to summary
private final ObjectProperty<Unit<Q>> precisionUnit
valueDirtyback to summary
private final ReadOnlyBooleanWrapper valueDirty
valueValidatorback to summary
private final ObjectProperty<Predicate<Double>> valueValidator

Constructor Detail

QuantityInputFieldback to summary
public QuantityInputField()

Instances a new input field with no available units, null value and no precision.

Method Detail

allowNegativesPropertyback to summary
public final BooleanProperty allowNegativesProperty()

Boolean property that tells the control to allow introducing a negative quantity.

Returns:BooleanProperty

The boolean property.

autoFixValuePropertyback to summary
public final BooleanProperty autoFixValueProperty()

Boolean property used to automatically convert the valueProperty() when the unitProperty() is changed.

Returns:BooleanProperty

The boolean property.

bindPrecisionQuantityPropertyback to summary
private void bindPrecisionQuantityProperty()
bindQuantityValuePropertyback to summary
private void bindQuantityValueProperty()

Hides com.dlsc.unitfx.QuantityInputControl.bindQuantityValueProperty.

bindValueDirtyPropertyback to summary
private void bindValueDirtyProperty()
createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Returns:Skin<?>

new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.

Annotations
@Override
getMaximumValueback to summary
public final Double getMaximumValue()
getMinimumValueback to summary
public final Double getMinimumValue()
getPrecisionback to summary
public final Double getPrecision()
getPrecisionQuantityback to summary
public final Quantity<Q> getPrecisionQuantity()
getPrecisionUnitback to summary
public final Unit<Q> getPrecisionUnit()
getUserAgentStylesheetback to summary
public String getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

Doc from javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. These styles are used in addition to whatever user-agent stylesheets are in use. This provides a mechanism for third parties to introduce styles for custom controls.

The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath.

Subclasses overriding this method should not assume any particular implementation approach as to the number and frequency with which it is called. For this reason, attempting any kind of dynamic implementation (i.e. returning different user agent stylesheet values) based on some state change is highly discouraged, as there is no guarantee when, or even if, this method will be called. Some JavaFX CSS implementations may choose to cache this response for an indefinite period of time, and therefore there should be no expectation around when this method is called.



package com.example.javafx.app;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class MyApp extends Application {

    @Override public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        scene.getStylesheets().add("/com/example/javafx/app/mystyles.css");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
For additional information about using CSS with the scene graph, see the CSS Reference Guide.
Returns:String

A string URL

Annotations
@Override
getValueValidatorback to summary
public final Predicate<Double> getValueValidator()
invalidPropertyback to summary
public final ReadOnlyBooleanProperty invalidProperty()

Property that indicates when the value entered violates restrictions of minimum and maximum values.

Returns:ReadOnlyBooleanProperty

The property that holds the flag.

isAllowNegativesback to summary
public final boolean isAllowNegatives()
isAutoFixValueback to summary
public final boolean isAutoFixValue()
isInvalidback to summary
public final boolean isInvalid()
isValueDirtyback to summary
public final boolean isValueDirty()
listenForAutoFixPropertyback to summary
private void listenForAutoFixProperty()
listenForInvalidChangesback to summary
private void listenForInvalidChanges()
maximumValuePropertyback to summary
public final ObjectProperty<Double> maximumValueProperty()

The maximum value that can be entered in this field. If this property is set, once the user enters a number greater than this minimum the field becomes invalid and the valueProperty() is set to null.

Returns:ObjectProperty<Double>

The maximum value.

minimumValuePropertyback to summary
public final ObjectProperty<Double> minimumValueProperty()

The minimum value that can be entered in this field. If this property is set, once the user enters a number lower than this minimum the field becomes invalid and the valueProperty() is set to null.

Returns:ObjectProperty<Double>

The minimum value.

precisionPropertyback to summary
public final ObjectProperty<Double> precisionProperty()

Integer used to truncate the value entered by the user and calculate the quantity. Default precision is '1' which means no truncation. Bellow some examples:

  • Value=340
  • Unit=Metre
  • Precision=100
  • ValueQuantity=300 Metre
precisionQuantityPropertyback to summary
public final ReadOnlyObjectProperty<Quantity<Q>> precisionQuantityProperty()

Represents the precision as combination of precisionProperty() ()} and precisionUnitProperty(). This value is calculated automatically by the control. It is refreshed every time the precision or the precision unit change.

Returns:ReadOnlyObjectProperty<Quantity<Q>>

The read only property storing the precision quantity.

precisionUnitPropertyback to summary
public final ObjectProperty<Unit<Q>> precisionUnitProperty()

Represents the system base unit, which is the default one for the control. If the unit selected is different to the base unit, the control will indicate visually (colored) that ambiguity. If no base unit is set, not color effect will be applied in the skin.

Returns:ObjectProperty<Unit<Q>>

The base unit.

restoreValuePropertyback to summary
public final void restoreValueProperty()

Applies the valueQuantityProperty() to the valueProperty() simulating a restore operation. This method not only cleans the value but also cleans the valueDirtyProperty().

setAllowNegativesback to summary
public final void setAllowNegatives(boolean allowNegatives)
setAutoFixValueback to summary
public final void setAutoFixValue(boolean autoFixValue)
setInvalidback to summary
private void setInvalid(boolean invalid)
setMaximumValueback to summary
public final void setMaximumValue(Double maximumValue)
setMinimumValueback to summary
public final void setMinimumValue(Double minimumValue)
setPrecisionback to summary
public final void setPrecision(Double precision)
setPrecisionQuantityback to summary
private void setPrecisionQuantity(Quantity<Q> precisionQuantity)
setPrecisionUnitback to summary
public final void setPrecisionUnit(Unit<Q> precisionUnit)
setValueDirtyback to summary
private void setValueDirty(boolean valueDirty)
setValueValidatorback to summary
public final void setValueValidator(Predicate<Double> valueValidator)
updateDefaultUnitback to summary
pack-priv void updateDefaultUnit(Unit<Q> baseUnit)

Overrides com.dlsc.unitfx.QuantityInputControl.updateDefaultUnit.

Annotations
@Override
updateValueQuantityback to summary
pack-priv void updateValueQuantity()

Overrides com.dlsc.unitfx.QuantityInputControl.updateValueQuantity.

Annotations
@Override
valueDirtyPropertyback to summary
public final ReadOnlyBooleanProperty valueDirtyProperty()

Boolean property that indicates when the value and the valueQuantity are different because after a precision was applied.

Returns:ReadOnlyBooleanProperty

The boolean property.

valueValidatorPropertyback to summary
public final ObjectProperty<Predicate<Double>> valueValidatorProperty()

Stores a validator object for the value converted from text entered. If the value entered is not valid, a pseudo class is added to the field, called ":invalid". This can be used for styling the field to indicate invalid inputs.

Returns:ObjectProperty<Predicate<Double>>

The property storing the validator predicate.