/* * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package javafx.beans.property; import com.sun.javafx.binding.BidirectionalBinding; import com.sun.javafx.binding.ExpressionHelper; import javafx.beans.binding.Bindings; import javafx.beans.value.ObservableValue; import javafx.beans.value.WritableDoubleValue; import com.sun.javafx.binding.Logging; import javafx.beans.InvalidationListener; import javafx.beans.Observable; import javafx.beans.WeakInvalidationListener; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableDoubleValue; /** * This class defines a {@link Property} wrapping a {@code double} value. *
* The value of a {@code DoubleProperty} can be get and set with {@link #get()}, * {@link #getValue()}, {@link #set(double)}, and {@link #setValue(Number)}. *
* A property can be bound and unbound unidirectional with * {@link #bind(ObservableValue)} and {@link #unbind()}. Bidirectional bindings * can be created and removed with {@link #bindBidirectional(Property)} and * {@link #unbindBidirectional(Property)}. *
* The context of a {@code DoubleProperty} can be read with {@link #getBean()} * and {@link #getName()}. *
* Note: setting or binding this property to a null value will set the property to "0.0". See {@link #setValue(java.lang.Number) }.
*
* @see javafx.beans.value.ObservableDoubleValue
* @see javafx.beans.value.WritableDoubleValue
* @see ReadOnlyDoubleProperty
* @see Property
*
* @since JavaFX 2.0
*/
public abstract class DoubleProperty extends ReadOnlyDoubleProperty implements
Property
* This is very useful when bidirectionally binding an ObjectProperty<Double> and
* a DoubleProperty.
*
*
* Note: null values in the source property will be interpreted as 0.0
*
* @param property
* The source {@code Property}
* @return A {@code DoubleProperty} that wraps the
* {@code Property}
* @throws NullPointerException
* if {@code property} is {@code null}
* @see #asObject()
* @since JavaFX 8.0
*/
public static DoubleProperty doubleProperty(final Property
* Can be used for binding an ObjectProperty to DoubleProperty.
*
*
*
* Another approach is to convert the DoubleProperty to ObjectProperty using
* {@link #asObject()} method.
*
* DoubleProperty doubleProperty = new SimpleDoubleProperty(1.0);
* ObjectProperty<Double> objectProperty = new SimpleObjectProperty<>(2.0);
*
* // Need to keep the reference as bidirectional binding uses weak references
* DoubleProperty objectAsDouble = DoubleProperty.doubleProperty(objectProperty);
*
* doubleProperty.bindBidirectional(objectAsDouble);
*
*
*
* @return the new {@code ObjectProperty}
* @since JavaFX 8.0
*/
@Override
public ObjectProperty
* DoubleProperty doubleProperty = new SimpleDoubleProperty(1.0);
* ObjectProperty<Double> objectProperty = new SimpleObjectProperty<>(2.0);
*
* objectProperty.bind(doubleProperty.asObject());
*