< prev index next >

modules/javafx.base/src/main/java/javafx/beans/binding/DoubleExpression.java

Print this page




 116      * Returns a {@code DoubleExpression} that wraps an
 117      * {@link javafx.beans.value.ObservableValue}. If the
 118      * {@code ObservableValue} is already a {@code DoubleExpression}, it
 119      * will be returned. Otherwise a new
 120      * {@link javafx.beans.binding.DoubleBinding} is created that is bound to
 121      * the {@code ObservableValue}.
 122      *
 123      * <p>
 124      * Note: this method can be used to convert an {@link ObjectExpression} or
 125      * {@link javafx.beans.property.ObjectProperty} of specific number type to DoubleExpression, which
 126      * is essentially an {@code ObservableValue<Number>}. See sample below.
 127      *
 128      * <blockquote><pre>
 129      *   DoubleProperty doubleProperty = new SimpleDoubleProperty(1.0);
 130      *   ObjectProperty&lt;Double&gt; objectProperty = new SimpleObjectProperty&lt;&gt;(2.0);
 131      *   BooleanBinding binding = doubleProperty.greaterThan(DoubleExpression.doubleExpression(objectProperty));
 132      * </pre></blockquote>
 133      *
 134      * Note: null values will be interpreted as 0.0
 135      *

 136      * @param value
 137      *            The source {@code ObservableValue}
 138      * @return A {@code DoubleExpression} that wraps the
 139      *         {@code ObservableValue} if necessary
 140      * @throws NullPointerException
 141      *             if {@code value} is {@code null}
 142      * @since JavaFX 8.0
 143      */
 144     public static <T extends Number> DoubleExpression doubleExpression(final ObservableValue<T> value) {
 145         if (value == null) {
 146             throw new NullPointerException("Value must be specified.");
 147         }
 148         return (value instanceof DoubleExpression) ? (DoubleExpression) value
 149                 : new DoubleBinding() {
 150             {
 151                 super.bind(value);
 152             }
 153 
 154             @Override
 155             public void dispose() {




 116      * Returns a {@code DoubleExpression} that wraps an
 117      * {@link javafx.beans.value.ObservableValue}. If the
 118      * {@code ObservableValue} is already a {@code DoubleExpression}, it
 119      * will be returned. Otherwise a new
 120      * {@link javafx.beans.binding.DoubleBinding} is created that is bound to
 121      * the {@code ObservableValue}.
 122      *
 123      * <p>
 124      * Note: this method can be used to convert an {@link ObjectExpression} or
 125      * {@link javafx.beans.property.ObjectProperty} of specific number type to DoubleExpression, which
 126      * is essentially an {@code ObservableValue<Number>}. See sample below.
 127      *
 128      * <blockquote><pre>
 129      *   DoubleProperty doubleProperty = new SimpleDoubleProperty(1.0);
 130      *   ObjectProperty&lt;Double&gt; objectProperty = new SimpleObjectProperty&lt;&gt;(2.0);
 131      *   BooleanBinding binding = doubleProperty.greaterThan(DoubleExpression.doubleExpression(objectProperty));
 132      * </pre></blockquote>
 133      *
 134      * Note: null values will be interpreted as 0.0
 135      *
 136      * @param <T> The type of Number to be wrapped
 137      * @param value
 138      *            The source {@code ObservableValue}
 139      * @return A {@code DoubleExpression} that wraps the
 140      *         {@code ObservableValue} if necessary
 141      * @throws NullPointerException
 142      *             if {@code value} is {@code null}
 143      * @since JavaFX 8.0
 144      */
 145     public static <T extends Number> DoubleExpression doubleExpression(final ObservableValue<T> value) {
 146         if (value == null) {
 147             throw new NullPointerException("Value must be specified.");
 148         }
 149         return (value instanceof DoubleExpression) ? (DoubleExpression) value
 150                 : new DoubleBinding() {
 151             {
 152                 super.bind(value);
 153             }
 154 
 155             @Override
 156             public void dispose() {


< prev index next >