/* * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package javafx.beans.property; import com.sun.javafx.binding.BidirectionalBinding; import javafx.beans.binding.Bindings; import javafx.beans.value.ObservableValue; import javafx.beans.value.WritableFloatValue; import com.sun.javafx.binding.Logging; /** * This class defines a {@link Property} wrapping a {@code float} value. *
* The value of a {@code FloatProperty} can be get and set with {@link #get()}, * {@link #getValue()}, {@link #set(float)}, 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 FloatProperty} 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.ObservableFloatValue
* @see javafx.beans.value.WritableFloatValue
* @see ReadOnlyFloatProperty
* @see Property
*
* @since JavaFX 2.0
*/
public abstract class FloatProperty extends ReadOnlyFloatProperty implements
Property
* This is very useful when bidirectionally binding an ObjectProperty
* Note: null values in the source property will be interpreted as 0f
*
* @param property
* The source {@code Property}
* @return A {@code FloatProperty} that wraps the
* {@code Property}
* @throws NullPointerException
* if {@code property} is {@code null}
* @see #asObject()
* @since JavaFX 8.0
*/
public static FloatProperty floatProperty(final Property
* Can be used for binding an ObjectProperty to FloatProperty.
*
*
*
* Another approach is to convert the FloatProperty to ObjectProperty using
* {@link #asObject()} method.
*
*
* FloatProperty floatProperty = new SimpleFloatProperty(1.0f);
* ObjectProperty<Float> objectProperty = new SimpleObjectProperty<>(2.0f);
*
* // Need to keep the reference as bidirectional binding uses weak references
* FloatProperty objectAsFloat = FloatProperty.floatProperty(objectProperty);
*
* floatProperty.bindBidirectional(objectAsFloat);
*
*
*
* @return the new {@code ObjectProperty}
* @since JavaFX 8.0
*/
@Override
public ObjectProperty
* FloatProperty floatProperty = new SimpleFloatProperty(1.0f);
* ObjectProperty<Float> objectProperty = new SimpleObjectProperty<>(2.0f);
*
* objectProperty.bind(floatProperty.asObject());
*