Example usage for javafx.beans.property DoubleProperty get

List of usage examples for javafx.beans.property DoubleProperty get

Introduction

In this page you can find the example usage for javafx.beans.property DoubleProperty get.

Prototype

double get();

Source Link

Document

Returns the current value of this ObservableDoubleValue .

Usage

From source file:Main.java

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

    DoubleBinding volumeOfSphere = new DoubleBinding() {
        {/*  w  ww.j  a  v a  2  s .c o  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) {
    final DoubleProperty a = new SimpleDoubleProperty(0);
    final DoubleProperty b = new SimpleDoubleProperty(0);
    final DoubleProperty c = new SimpleDoubleProperty(0);

    DoubleBinding area = new DoubleBinding() {
        {//from   w w  w  .  jav a2 s  .co m
            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());
}

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  ww  w  .j a v  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) {
    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);/*from   ww  w  .java  2 s.com*/
    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() {
        private double value;

        {/*from   ww  w.jav  a  2s.  co m*/
            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

@Override
public void start(Stage stage) throws Exception {
    ImageView imageView = new ImageView();
    ScrollPane scrollPane = new ScrollPane();
    DoubleProperty zoomProperty = new SimpleDoubleProperty(200);

    zoomProperty.addListener(new InvalidationListener() {
        @Override/*from  w  w w  . j  av  a 2  s .c o  m*/
        public void invalidated(Observable arg0) {
            imageView.setFitWidth(zoomProperty.get() * 2);
            imageView.setFitHeight(zoomProperty.get() * 3);
        }
    });
    scrollPane.addEventFilter(ScrollEvent.ANY, new EventHandler<ScrollEvent>() {
        @Override
        public void handle(ScrollEvent event) {
            if (event.getDeltaY() > 0) {
                zoomProperty.set(zoomProperty.get() * 1.2);
            } else if (event.getDeltaY() < 0) {
                zoomProperty.set(zoomProperty.get() / 1.1);
            }
        }
    });
    imageView.setImage(new Image("http://yourImageURL"));
    imageView.preserveRatioProperty().set(true);
    scrollPane.setContent(imageView);
    stage.setScene(new Scene(scrollPane, 400, 300));
    stage.show();
}

From source file:fr.amap.lidar.amapvox.gui.MainFrameController.java

private void showImage(File file) {

    try {//from  www  .j ava2  s  .  c  om
        ImageView iv = new ImageView(new Image(file.toURI().toURL().toString()));
        iv.setPreserveRatio(true);
        Stage stage = new Stage();

        final DoubleProperty zoomProperty = new SimpleDoubleProperty(200);

        zoomProperty.addListener(new InvalidationListener() {
            @Override
            public void invalidated(javafx.beans.Observable observable) {
                iv.setFitWidth(zoomProperty.get() * 4);
                iv.setFitHeight(zoomProperty.get() * 3);
            }
        });

        ScrollPane sp = new ScrollPane(iv);
        stage.addEventFilter(ScrollEvent.ANY, new EventHandler<ScrollEvent>() {
            @Override
            public void handle(ScrollEvent event) {
                if (event.getDeltaY() > 0) {
                    zoomProperty.set(zoomProperty.get() * 1.1);
                } else if (event.getDeltaY() < 0) {
                    zoomProperty.set(zoomProperty.get() / 1.1);
                }
            }
        });

        stage.setScene(new Scene(new Group(sp)));

        stage.sizeToScene();
        stage.show();
    } catch (IOException ex) {
        showErrorDialog(ex);
    }

}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param iNumZone numro de la zone/*w w w  . j  a v a  2  s.c o m*/
 * @param cercle cercle concern
 * @return ancres cercles
 */
private static ObservableList<AncreForme> olCreeAncresPourCercle(int iNumZone, Circle cercle) {
    ObservableList<AncreForme> olAnchors = FXCollections.observableArrayList();

    DoubleProperty xProperty1 = new SimpleDoubleProperty(cercle.getCenterX());
    DoubleProperty yProperty1 = new SimpleDoubleProperty(cercle.getCenterY());
    olAnchors.add(new AncreForme(Color.GOLD, xProperty1, yProperty1));
    DoubleProperty xProperty2 = new SimpleDoubleProperty(cercle.getCenterX() + cercle.getRadius());
    DoubleProperty yProperty2 = new SimpleDoubleProperty(cercle.getCenterY());
    final AncreForme ancRayon = new AncreForme(Color.BLUEVIOLET, xProperty2, yProperty2);
    olAnchors.add(ancRayon);
    xProperty1.addListener((ObservableValue<? extends Number> ov, Number oldX, Number x) -> {
        double dX = (double) x - cercle.getCenterX();
        double rayon = Math.sqrt(Math.pow(cercle.getCenterX() - xProperty2.get(), 2.d)
                + Math.pow(cercle.getCenterY() - yProperty2.get(), 2.d));
        cercle.setCenterX((double) x);
        ancRayon.setCenterX(ancRayon.getCenterX() + dX);
        String chaine = Math.round(cercle.getCenterX() * 10) / 10 + ","
                + Math.round(cercle.getCenterY() * 10) / 10 + "," + Math.round(rayon * 10) / 10;
        zones[iNumZone].setStrCoordonneesZone(chaine);

    });

    yProperty1.addListener((ObservableValue<? extends Number> ov, Number oldY, Number y) -> {
        double dY = -cercle.getCenterY() + (double) y;
        double rayon = Math.sqrt(Math.pow(cercle.getCenterX() - xProperty2.get(), 2.d)
                + Math.pow(cercle.getCenterY() - yProperty2.get(), 2.d));
        cercle.setCenterY((double) y);
        ancRayon.setCenterY(ancRayon.getCenterY() + dY);
        String chaine = Math.round(cercle.getCenterX() * 10) / 10 + ","
                + Math.round(cercle.getCenterY() * 10) / 10 + "," + Math.round(rayon * 10) / 10;
        zones[iNumZone].setStrCoordonneesZone(chaine);
    });
    xProperty2.addListener((ObservableValue<? extends Number> ov, Number oldX, Number x) -> {
        double rayon = Math.sqrt(Math.pow(cercle.getCenterX() - (double) x, 2.d)
                + Math.pow(cercle.getCenterY() - yProperty2.get(), 2.d));
        cercle.setRadius(rayon);
        String chaine = Math.round(cercle.getCenterX() * 10) / 10 + ","
                + Math.round(cercle.getCenterY() * 10) / 10 + "," + Math.round(rayon * 10) / 10;
        zones[iNumZone].setStrCoordonneesZone(chaine);
    });

    yProperty2.addListener((ObservableValue<? extends Number> ov, Number oldY, Number y) -> {
        double rayon = Math.sqrt(Math.pow(cercle.getCenterX() - xProperty2.get(), 2.d)
                + Math.pow(cercle.getCenterY() - (double) y, 2.d));
        cercle.setRadius(rayon);
        String chaine = Math.round(cercle.getCenterX() * 10) / 10 + ","
                + Math.round(cercle.getCenterY() * 10) / 10 + "," + Math.round(rayon * 10) / 10;
        zones[iNumZone].setStrCoordonneesZone(chaine);
    });

    return olAnchors;
}