Module javafx.base

Class DoubleExpression

    • Constructor Detail

      • DoubleExpression

        public DoubleExpression()
    • Method Detail

      • doubleExpression

        public static DoubleExpression doubleExpression​(ObservableDoubleValue value)
        Returns a DoubleExpression that wraps a ObservableDoubleValue. If the ObservableDoubleValue is already a DoubleExpression, it will be returned. Otherwise a new DoubleBinding is created that is bound to the ObservableDoubleValue.
        Parameters:
        value - The source ObservableDoubleValue
        Returns:
        A DoubleExpression that wraps the ObservableDoubleValue if necessary
        Throws:
        NullPointerException - if value is null
      • doubleExpression

        public static <T extends NumberDoubleExpression doubleExpression​(ObservableValue<T> value)
        Returns a DoubleExpression that wraps an ObservableValue. If the ObservableValue is already a DoubleExpression, it will be returned. Otherwise a new DoubleBinding is created that is bound to the ObservableValue.

        Note: this method can be used to convert an ObjectExpression or ObjectProperty of specific number type to DoubleExpression, which is essentially an ObservableValue<Number>. See sample below.

           DoubleProperty doubleProperty = new SimpleDoubleProperty(1.0);
           ObjectProperty<Double> objectProperty = new SimpleObjectProperty<>(2.0);
           BooleanBinding binding = doubleProperty.greaterThan(DoubleExpression.doubleExpression(objectProperty));
         
        Note: null values will be interpreted as 0.0
        Type Parameters:
        T - The type of Number to be wrapped
        Parameters:
        value - The source ObservableValue
        Returns:
        A DoubleExpression that wraps the ObservableValue if necessary
        Throws:
        NullPointerException - if value is null
        Since:
        JavaFX 8.0
      • asObject

        public ObjectExpression<Double> asObject()
        Creates an ObjectExpression that holds the value of this DoubleExpression. If the value of this DoubleExpression changes, the value of the ObjectExpression will be updated automatically.
        Returns:
        the new ObjectExpression
        Since:
        JavaFX 8.0