public static FloatBinding toFloatBinding(ObservableValue<? extends Number> ov) { return new FloatBinding() { { bind(ov); } @Override protected float computeValue() { return ov.getValue() == null ? 0 : ov.getValue().floatValue(); } }; }
public FloatBinding selectFloat(Function<S, ? extends ObservableFloatValue> childPropertyAccessor) { return selectFloat(childPropertyAccessor, 0.0f); }
public FloatBinding selectFloat(Function<S, ? extends ObservableFloatValue> childPropertyAccessor, float defaultValue) { return new FloatBindingAdapter(new ChainBinding<>(rootProperty, childPropertyAccessor), defaultValue); }
public FloatBinding mapToFloat(Function<S, Float> childValueAccessor) { return mapToFloat(childValueAccessor, 0.0f); }
public FloatBinding mapToFloat(Function<S, Float> childValueAccessor, Float defaultValue) { return new FloatBindingAdapter(mapToObject(childValueAccessor), defaultValue); }
protected FloatBindingAssert(FloatBinding actual) { super(actual, FloatBindingAssert.class); }
@Test public void testFloatBinding(){ FloatProperty value = new SimpleFloatProperty(10f); final FloatBinding actual = value.add(20); assertThat(actual).hasValue(30f); assertThat(actual).hasSameValue(actual); }
/** * 建立包裝目前觀察值為浮點型態的繫節。 * * @param thiz 來源觀察值 * @param mapper 轉換目前觀察值為浮點型態的函數 * @return 浮點型態的繫節(依賴目前的觀察物件) */ default FloatBinding asFloat(Function<? super T, ? extends Float> mapper) { ObservableValue<T> thiz = (ObservableValue<T>) this; return Bindings.createFloatBinding(() -> mapper.apply(thiz.getValue()), thiz); }
/** * Binding for {@link java.lang.Math#abs(float)} * * @param a the argument whose absolute value is to be determined as observableValue * @return the absolute value of the argument. */ public static FloatBinding abs(final ObservableFloatValue a) { return createFloatBinding(() -> Math.abs(a.get()), a); }
/** * Binding for {@link java.lang.Math#copySign(float, float)} * * @param magnitude the parameter providing the magnitude of the result * @param sign the parameter providing the sign of the result * @return a value with the magnitude of {@code magnitude} * and the sign of {@code sign}. */ public static FloatBinding copySign(final ObservableFloatValue magnitude, ObservableFloatValue sign) { return createFloatBinding(() -> Math.copySign(magnitude.get(), sign.get()), magnitude, sign); }
/** * Binding for {@link java.lang.Math#copySign(float, float)} * * @param magnitude the parameter providing the magnitude of the result * @param sign the parameter providing the sign of the result * @return a value with the magnitude of {@code magnitude} * and the sign of {@code sign}. */ public static FloatBinding copySign(final float magnitude, ObservableFloatValue sign) { return createFloatBinding(() -> Math.copySign(magnitude, sign.get()), sign); }
/** * Binding for {@link java.lang.Math#copySign(float, float)} * * @param magnitude the parameter providing the magnitude of the result * @param sign the parameter providing the sign of the result * @return a value with the magnitude of {@code magnitude} * and the sign of {@code sign}. */ public static FloatBinding copySign(final ObservableFloatValue magnitude, float sign) { return createFloatBinding(() -> Math.copySign(magnitude.get(), sign), magnitude); }
/** * Binding for {@link java.lang.Math#max(float, float)} * * @param a an argument. * @param b another argument. * @return the larger of {@code a} and {@code b}. */ public static FloatBinding max(final ObservableFloatValue a, final ObservableFloatValue b) { return createFloatBinding(() -> Math.max(a.get(), b.get()), a, b); }
/** * Binding for {@link java.lang.Math#max(float, float)} * * @param a an argument. * @param b another argument. * @return the larger of {@code a} and {@code b}. */ public static FloatBinding max(final float a, final ObservableFloatValue b) { return createFloatBinding(() -> Math.max(a, b.get()), b); }
/** * Binding for {@link java.lang.Math#max(float, float)} * * @param a an argument. * @param b another argument. * @return the larger of {@code a} and {@code b}. */ public static FloatBinding max(final ObservableFloatValue a, final float b) { return createFloatBinding(() -> Math.max(a.get(), b), a); }
/** * Binding for {@link java.lang.Math#min(float, float)} * * @param a an argument. * @param b another argument. * @return the smaller of {@code a} and {@code b}. */ public static FloatBinding min(final ObservableFloatValue a, final ObservableFloatValue b) { return createFloatBinding(() -> Math.min(a.get(), b.get()), a, b); }
/** * Binding for {@link java.lang.Math#min(float, float)} * * @param a an argument. * @param b another argument. * @return the smaller of {@code a} and {@code b}. */ public static FloatBinding min(final float a, final ObservableFloatValue b) { return createFloatBinding(() -> Math.min(a, b.get()), b); }
/** * Binding for {@link java.lang.Math#min(float, float)} * * @param a an argument. * @param b another argument. * @return the smaller of {@code a} and {@code b}. */ public static FloatBinding min(final ObservableFloatValue a, final float b) { return createFloatBinding(() -> Math.min(a.get(), b), a); }
/** * Binding for {@link java.lang.Math#nextAfter(float, double)} * * @param start starting floating-point value * @param direction value indicating which of * {@code start}'s neighbors or {@code start} should * be returned * @return The floating-point number adjacent to {@code start} in the * direction of {@code direction}. */ public static FloatBinding nextAfter(final ObservableFloatValue start, final ObservableFloatValue direction) { return createFloatBinding(() -> Math.nextAfter(start.get(), direction.get()), start, direction); }
/** * Binding for {@link java.lang.Math#nextAfter(float, double)} * * @param start starting floating-point value * @param direction value indicating which of * {@code start}'s neighbors or {@code start} should * be returned * @return The floating-point number adjacent to {@code start} in the * direction of {@code direction}. */ public static FloatBinding nextAfter(final float start, final ObservableFloatValue direction) { return createFloatBinding(() -> Math.nextAfter(start, direction.get()), direction); }
/** * Binding for {@link java.lang.Math#nextAfter(float, double)} * * @param start starting floating-point value * @param direction value indicating which of * {@code start}'s neighbors or {@code start} should * be returned * @return The floating-point number adjacent to {@code start} in the * direction of {@code direction}. */ public static FloatBinding nextAfter(final ObservableFloatValue start, final float direction) { return createFloatBinding(() -> Math.nextAfter(start.get(), direction), start); }
/** * Binding for {@link java.lang.Math#nextDown(float)} * * @param f starting floating-point value * @return The adjacent floating-point value closer to negative * infinity. */ public static FloatBinding nextDown(final ObservableFloatValue f) { return createFloatBinding(() -> Math.nextDown(f.get()), f); }
/** * Binding for {@link java.lang.Math#nextUp(float)} * * @param f starting floating-point value * @return The adjacent floating-point value closer to positive * infinity. */ public static FloatBinding nextUp(final ObservableFloatValue f) { return createFloatBinding(() -> Math.nextUp(f.get()), f); }
/** * Binding for {@link java.lang.Math#scalb(float, int)} * * @param f number to be scaled by a power of two. * @param scaleFactor power of 2 used to scale {@code f} * @return {@code f} × 2<sup>{@code scaleFactor}</sup> */ public static FloatBinding scalb(final ObservableFloatValue f, final ObservableIntegerValue scaleFactor) { return createFloatBinding(()->Math.scalb(f.get(), scaleFactor.get()),f, scaleFactor); }
/** * Binding for {@link java.lang.Math#scalb(float, int)} * * @param f number to be scaled by a power of two. * @param scaleFactor power of 2 used to scale {@code f} * @return {@code f} × 2<sup>{@code scaleFactor}</sup> */ public static FloatBinding scalb(final float f, final ObservableIntegerValue scaleFactor) { return createFloatBinding(()->Math.scalb(f, scaleFactor.get()), scaleFactor); }
/** * Binding for {@link java.lang.Math#scalb(float, int)} * * @param f number to be scaled by a power of two. * @param scaleFactor power of 2 used to scale {@code f} * @return {@code f} × 2<sup>{@code scaleFactor}</sup> */ public static FloatBinding scalb(final ObservableFloatValue f, final int scaleFactor) { return createFloatBinding(()->Math.scalb(f.get(), scaleFactor),f); }
/** * Binding for {@link java.lang.Math#signum(float)} * * @param f the floating-point value whose signum is to be returned * @return the signum function of the argument */ public static FloatBinding signum(final ObservableFloatValue f) { return createFloatBinding(() -> Math.signum(f.get()), f); }
/** * Binding for {@link java.lang.Math#ulp(float)} * * @param f the floating-point value whose ulp is to be returned * @return the size of an ulp of the argument */ public static FloatBinding ulp(final ObservableFloatValue f) { return createFloatBinding(() -> Math.ulp(f.get()), f); }