summaryrefslogtreecommitdiff
path: root/src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Dwarf.java
diff options
context:
space:
mode:
authorAndriy Cherniy <qugalet@m0e.space>2024-06-17 05:10:58 +0300
committerAndriy Cherniy <qugalet@m0e.space>2024-06-17 05:10:58 +0300
commit943bc45a13256d57c82ed58f22aa2cb802292744 (patch)
treeada8c6d5eefa3e4034504bfcc5eb03ab84597ebe /src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Dwarf.java
parent3401d742ca53dce6bb1464cc12f94d107cfc285d (diff)
downloadoop-kursach-master.tar.gz
oop-kursach-master.zip
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEADmaster
Diffstat (limited to 'src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Dwarf.java')
-rw-r--r--src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Dwarf.java41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Dwarf.java b/src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Dwarf.java
index daaa9c5..a36f66a 100644
--- a/src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Dwarf.java
+++ b/src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Dwarf.java
@@ -4,6 +4,7 @@ import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Platform;
+import javafx.geometry.Bounds;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.util.Duration;
@@ -139,16 +140,44 @@ public class Dwarf extends Immigrant {
}).findFirst().orElse(null);
}
+// public Coordinates getCoordinatesToWorkstation(Workstation workstation) {
+// double workstationX = workstation.getGroup().getLayoutX() + workstation.getGroup().getBoundsInParent().getWidth() - this.getGroup().getBoundsInParent().getWidth();
+// double workstationY = workstation.getGroup().getLayoutY() + workstation.getGroup().getBoundsInParent().getHeight() - this.getGroup().getBoundsInParent().getHeight();
+// return new Coordinates(workstationX, workstationY);
+// }
public Coordinates getCoordinatesToWorkstation(Workstation workstation) {
- double workstationX = workstation.getGroup().getLayoutX() + workstation.getGroup().getBoundsInParent().getWidth() - this.getGroup().getBoundsInParent().getWidth();
- double workstationY = workstation.getGroup().getLayoutY() + workstation.getGroup().getBoundsInParent().getHeight() - this.getGroup().getBoundsInParent().getHeight();
+ // Отримання меж групи робочої станції в координатах сцени
+ Bounds workstationBoundsInScene = workstation.getGroup().localToScene(workstation.getGroup().getBoundsInLocal());
+
+ // Отримання меж кореневої групи в координатах сцени
+ Bounds rootBoundsInScene = this.getGroup().getScene().getRoot().localToScene(this.getGroup().getScene().getRoot().getBoundsInLocal());
+
+ // Обчислення відносних координат робочої станції відносно кореневої групи
+ double workstationX = workstationBoundsInScene.getMinX() - rootBoundsInScene.getMinX();
+ double workstationY = workstationBoundsInScene.getMinY() - rootBoundsInScene.getMinY();
+
return new Coordinates(workstationX, workstationY);
}
- public Coordinates getCoordinatesToThroneRoom(ThroneRoom throneRoom) {
- double throneRoomX = throneRoom.getGroup().getLayoutX() + throneRoom.getGroup().getBoundsInParent().getWidth() / 2 + this.getGroup().getBoundsInParent().getWidth();
- double throneRoomY = throneRoom.getGroup().getLayoutY() + throneRoom.getGroup().getBoundsInParent().getHeight() / 2 + this.getGroup().getBoundsInParent().getHeight();
- return new Coordinates(throneRoomX, throneRoomY);
+
+// public Coordinates getCoordinatesToThroneRoom(ThroneRoom throneRoom) {
+// double throneRoomX = throneRoom.getGroup().getLayoutX() + throneRoom.getGroup().getBoundsInParent().getWidth() / 2 + this.getGroup().getBoundsInParent().getWidth();
+// double throneRoomY = throneRoom.getGroup().getLayoutY() + throneRoom.getGroup().getBoundsInParent().getHeight() / 2 + this.getGroup().getBoundsInParent().getHeight();
+// return new Coordinates(throneRoomX, throneRoomY);
+// }
+
+ public Coordinates getCoordinatesToThroneRoom(ThroneRoom workstation) {
+ // Отримання меж групи робочої станції в координатах сцени
+ Bounds workstationBoundsInScene = workstation.getGroup().localToScene(workstation.getGroup().getBoundsInLocal());
+
+ // Отримання меж кореневої групи в координатах сцени
+ Bounds rootBoundsInScene = this.getGroup().getScene().getRoot().localToScene(this.getGroup().getScene().getRoot().getBoundsInLocal());
+
+ // Обчислення відносних координат робочої станції відносно кореневої групи
+ double workstationX = workstationBoundsInScene.getMinX() - rootBoundsInScene.getMinX();
+ double workstationY = workstationBoundsInScene.getMinY() - rootBoundsInScene.getMinY();
+
+ return new Coordinates(workstationX, workstationY);
}
public void free() {