Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import javafx.fxml.FXML;
import javafx.scene.Group;
import javafx.scene.control.TreeItem;
import javafx.scene.control.Tooltip;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
Expand All @@ -20,6 +21,7 @@
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.Pane;
import javafx.scene.transform.Scale;
import javafx.util.Duration;

@SuppressWarnings("PMD.UnusedPrivateMethod")
public class FieldDisplayController {
Expand All @@ -45,7 +47,14 @@ private void initialize() {
field = ProjectPreferences.getInstance().getField();
Image image = field.getImage();
backgroundImage.setImage(image);
topPane.getStyleClass().add("pane");
Tooltip tooltip = new Tooltip();
Tooltip.install(topPane, tooltip);
tooltip.setShowDelay(Duration.seconds(0.0));
tooltip.setHideDelay(Duration.seconds(999999.0));
drawPane.setOnMouseMoved(e -> {
tooltip.setText("X: " + roundToString(e.getX()) + " / Y: " + roundToString(e.getY()));
tooltip.show(topPane, e.getSceneX(), e.getSceneY());
});
Scale scale = new Scale();
scale.xProperty().bind(Bindings.createDoubleBinding(() ->
Math.min(topPane.getWidth() / image.getWidth(), topPane.getHeight() / image.getHeight()),
Expand Down Expand Up @@ -172,4 +181,9 @@ public boolean checkBounds(double x, double y) {
//Convert waypoint convention to JavaFX
return drawPane.getLayoutBounds().contains(x, -y);
}

private String roundToString(Double number) {
number = Math.round(number * 100.0) / 100.0;
return String.valueOf(number);
}
}