Creates a JavaFX binding, giving the angle from the gradient given - Java JavaFX

Java examples for JavaFX:Bindable Properties

Description

Creates a JavaFX binding, giving the angle from the gradient given

Demo Code


    //package com.java2s;
    import javafx.beans.binding.Bindings;
    import javafx.beans.binding.DoubleBinding;

    public class Main {
        /**/*from   w  w  w  .  ja  va 2  s . c o m*/
         * Creates a binding, giving the angle from the gradient given
         * 
         * @param x
         *            x distance
         * @param y
         *            y distance
         * @return new double binding bound to the angle of rotation to align with
         *         the given numbers
         */
        public static DoubleBinding degreesAngle(DoubleBinding x, DoubleBinding y) {
   return Bindings.createDoubleBinding(
         () -> (x.get() < 0 ? -180 : 0) + Math.atan(y.get() / x.get()) * 180 / Math.PI, x, y);
}
    }

Related Tutorials