List of usage examples for javafx.beans.property DoubleProperty set
void set(double value);
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); b.set(4);//from w w w. j a v a 2 s. c om 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 radius = new SimpleDoubleProperty(2); DoubleBinding volumeOfSphere = new DoubleBinding() { {/*from ww w .j a va2 s . 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) { 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. ja va2s . c o 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
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 w w w . j a va2s . c o 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
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 a va2 s . com 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
@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 a va 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:com.sunkur.springjavafxcontroller.screen.ScreensContoller.java
private boolean swapScreen(final Parent root) { final Group rootGroup = getScreenRoot(); final DoubleProperty opacity = rootGroup.opacityProperty(); if (!isScreenEmpty()) { Timeline fade = new Timeline(new KeyFrame(Duration.ZERO, new KeyValue(opacity, 1.0)), new KeyFrame(new Duration(250), new EventHandler<ActionEvent>() { @Override//from w ww . ja v a 2 s . c o m public void handle(ActionEvent t) { rootGroup.getChildren().remove(0); rootGroup.getChildren().add(0, root); Timeline fadeIn = new Timeline(new KeyFrame(Duration.ZERO, new KeyValue(opacity, 0.0)), new KeyFrame(new Duration(350), new KeyValue(opacity, 1.0))); fadeIn.play(); } }, new KeyValue(opacity, 0.0))); fade.play(); return true; } else { opacity.set(0.0); rootGroup.getChildren().add(0, root); Timeline fadeIn = new Timeline(new KeyFrame(Duration.ZERO, new KeyValue(opacity, 0.0)), new KeyFrame(new Duration(350), new KeyValue(opacity, 1.0))); fadeIn.play(); } if (!this.stage.isShowing()) { this.stage.show(); } return true; }
From source file:fr.amap.lidar.amapvox.gui.MainFrameController.java
private void showImage(File file) { try {/*from w ww . j av a 2 s.co m*/ 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); } }