Module javafx.base

Class DoubleExpression

java.lang.Object
javafx.beans.binding.NumberExpressionBase
javafx.beans.binding.DoubleExpression
All Implemented Interfaces:
NumberExpression, Observable, ObservableDoubleValue, ObservableNumberValue, ObservableValue<Number>
Direct Known Subclasses:
DoubleBinding, ReadOnlyDoubleProperty

public abstract class DoubleExpression
extends NumberExpressionBase
implements ObservableDoubleValue
DoubleExpression is an ObservableDoubleValue plus additional convenience methods to generate bindings in a fluent style.

A concrete sub-class of DoubleExpression has to implement the method ObservableDoubleValue.get(), which provides the actual value of this expression.

Since:
JavaFX 2.0
  • Constructor Details

    • DoubleExpression

      public DoubleExpression()
      Creates a default DoubleExpression.
  • Method Details

    • 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 Number> DoubleExpression 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
    • negate

      public DoubleBinding negate()
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the negation of NumberExpression.
      Specified by:
      negate in interface NumberExpression
      Returns:
      the new NumberBinding
    • add

      public DoubleBinding add​(ObservableNumberValue other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the sum of this NumberExpression and another ObservableNumberValue.
      Specified by:
      add in interface NumberExpression
      Parameters:
      other - the second ObservableNumberValue
      Returns:
      the new NumberBinding
    • add

      public DoubleBinding add​(double other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the sum of this NumberExpression and a constant value.
      Specified by:
      add in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • add

      public DoubleBinding add​(float other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the sum of this NumberExpression and a constant value.
      Specified by:
      add in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • add

      public DoubleBinding add​(long other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the sum of this NumberExpression and a constant value.
      Specified by:
      add in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • add

      public DoubleBinding add​(int other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the sum of this NumberExpression and a constant value.
      Specified by:
      add in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • subtract

      public DoubleBinding subtract​(ObservableNumberValue other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the difference of this NumberExpression and another ObservableNumberValue.
      Specified by:
      subtract in interface NumberExpression
      Parameters:
      other - the second ObservableNumberValue
      Returns:
      the new NumberBinding
    • subtract

      public DoubleBinding subtract​(double other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the difference of this NumberExpression and a constant value.
      Specified by:
      subtract in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • subtract

      public DoubleBinding subtract​(float other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the difference of this NumberExpression and a constant value.
      Specified by:
      subtract in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • subtract

      public DoubleBinding subtract​(long other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the difference of this NumberExpression and a constant value.
      Specified by:
      subtract in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • subtract

      public DoubleBinding subtract​(int other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the difference of this NumberExpression and a constant value.
      Specified by:
      subtract in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • multiply

      public DoubleBinding multiply​(ObservableNumberValue other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the product of this NumberExpression and another ObservableNumberValue.
      Specified by:
      multiply in interface NumberExpression
      Parameters:
      other - the second ObservableNumberValue
      Returns:
      the new NumberBinding
    • multiply

      public DoubleBinding multiply​(double other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the product of this NumberExpression and a constant value.
      Specified by:
      multiply in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • multiply

      public DoubleBinding multiply​(float other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the product of this NumberExpression and a constant value.
      Specified by:
      multiply in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • multiply

      public DoubleBinding multiply​(long other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the product of this NumberExpression and a constant value.
      Specified by:
      multiply in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • multiply

      public DoubleBinding multiply​(int other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the product of this NumberExpression and a constant value.
      Specified by:
      multiply in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • divide

      public DoubleBinding divide​(ObservableNumberValue other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the division of this NumberExpression and another ObservableNumberValue.
      Specified by:
      divide in interface NumberExpression
      Parameters:
      other - the second ObservableNumberValue
      Returns:
      the new NumberBinding
    • divide

      public DoubleBinding divide​(double other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the division of this NumberExpression and a constant value.
      Specified by:
      divide in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • divide

      public DoubleBinding divide​(float other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the division of this NumberExpression and a constant value.
      Specified by:
      divide in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • divide

      public DoubleBinding divide​(long other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the division of this NumberExpression and a constant value.
      Specified by:
      divide in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • divide

      public DoubleBinding divide​(int other)
      Description copied from interface: NumberExpression
      Creates a new NumberBinding that calculates the division of this NumberExpression and a constant value.
      Specified by:
      divide in interface NumberExpression
      Parameters:
      other - the constant value
      Returns:
      the new NumberBinding
    • 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