JavaFX Bildansicht echte Koordinaten translateX und translateY
Und warum ist translateX und translateY in meiner Szene schlecht positioniert? Ich beginne mit der Koordinate x = 100 y = 200 in reell meine reelle Koordinate y = -24,8 ... warum? Ich brauche echte Koordinaten, wann ist mein ImageView?
primaryStage.setTitle("Title");
Group root = new Group();
Scene scene = new Scene(root, 800, 600, Color.WHITE);
// border.prefHeightProperty().bind(scene.heightProperty());
//border.prefWidthProperty().bind(scene.widthProperty());
Image im = new Image("Images/universe.jpg", 800, 600, true, true);
ImageView iv = new ImageView(im);
Image iv1 = new Image("Images/Asteroid.png", 60, 50, false, false);
ImageView iv2 = new ImageView(iv1);
iv2.setX(100);
iv2.setY(200);
Path p = new Path();
p.getElements().add(new MoveTo(100, 200));
p.getElements().add(new LineTo(200, 400));
PathTransition pt = new PathTransition(Duration.millis(10000), p);
pt.setNode(iv2);
root.getChildren().add(iv2);
DoubleProperty xValue = new SimpleDoubleProperty();
xValue.bind(iv2.translateXProperty());
xValue.addListener(new ChangeListener() {
@Override
public void changed(ObservableValue ov, Object t, Object t1) {
// System.out.println((double) t1);
}
});
DoubleProperty yValue = new SimpleDoubleProperty();
yValue.bind(iv2.translateYProperty());
yValue.addListener(new ChangeListener() {
@Override
public void changed(ObservableValue ov, Object t, Object t1) {
System.out.println((double) t1);
}
});
pt.play();
primaryStage.setScene(scene);
primaryStage.show();
}