Example usage for javafx.beans.binding DoubleBinding get

List of usage examples for javafx.beans.binding DoubleBinding get

Introduction

In this page you can find the example usage for javafx.beans.binding DoubleBinding get.

Prototype

@Override
public final double get() 

Source Link

Document

Returns the result of #computeValue() .

Usage

From source file:Main.java

public static void main(String[] args) {
    final DoubleProperty radius = new SimpleDoubleProperty(2);

    DoubleBinding volumeOfSphere = new DoubleBinding() {
        {//from   w  w  w  . jav a2s .  co m
            super.bind(radius);
        }

        @Override
        protected double computeValue() {
            return radius.get() + 4;
        }
    };

    System.out.println(radius.get());
    System.out.println(volumeOfSphere.get());

    radius.set(50);
    System.out.println(radius.get());
    System.out.println(volumeOfSphere.get());
}

From source file:Main.java

public static void main(String[] args) {
    DoubleProperty a = new SimpleDoubleProperty(0);
    DoubleProperty b = new SimpleDoubleProperty(0);

    DoubleBinding s = a.add(b).divide(2.0D);

    final DoubleBinding aBinding = new When(a.add(b).greaterThan(b).and(a.add(a).greaterThan(b)))
            .then(s.multiply(s.subtract(a)).multiply(s.subtract(b))).otherwise(0.0D);

    a.set(3);/* w  w  w  .j ava  2s .c om*/
    b.set(4);
    System.out.println(a.get());
    System.out.println(b.get());
    System.out.println(aBinding.get());

    a.set(2);
    b.set(2);
    System.out.println(a.get());
    System.out.println(b.get());
    System.out.println(aBinding.get());

}

From source file:Main.java

public static void main(String[] args) {
    final DoubleProperty x = new SimpleDoubleProperty(null, "x", 2.0);
    final DoubleProperty y = new SimpleDoubleProperty(null, "y", 3.0);
    DoubleBinding area = new DoubleBinding() {
        {//from w w w.  j a  va  2s  .com
            super.bind(x, y);
        }

        @Override
        protected double computeValue() {
            System.out.println("computeValue() is called.");
            return x.get() * y.get();
        }
    };
    System.out.println("area.get() = " + area.get());
    x.set(5);
    y.set(7);
    System.out.println("area.get() = " + area.get());
}

From source file:Main.java

public static void main(String[] args) {
    final DoubleProperty x = new SimpleDoubleProperty(null, "x", 2.0);
    final DoubleProperty y = new SimpleDoubleProperty(null, "y", 3.0);
    DoubleBinding area = new DoubleBinding() {
        private double value;

        {/*from   www.  jav  a  2s .c  om*/
            super.bind(x, y);
        }

        @Override
        protected double computeValue() {
            System.out.println("computeValue() is called.");
            return x.get() * y.get();
        }
    };
    System.out.println("area.get() = " + area.get());
    x.set(5);
    y.set(7);
    System.out.println("area.get() = " + area.get());
}

From source file:Main.java

public static void main(String[] args) {
    final DoubleProperty a = new SimpleDoubleProperty(0);
    final DoubleProperty b = new SimpleDoubleProperty(0);
    final DoubleProperty c = new SimpleDoubleProperty(0);

    DoubleBinding area = new DoubleBinding() {
        {/*  w  w w  .j av  a2  s.c om*/
            super.bind(a, b, c);
        }

        @Override
        protected double computeValue() {
            double a0 = a.get();
            double b0 = b.get();
            double c0 = c.get();

            return a0 * b0 * c0;

        }
    };

    a.set(2);
    b.set(2);
    c.set(2);
    System.out.println(area.get());
}