From 112a80637310df04446bef57221399b545700002 Mon Sep 17 00:00:00 2001 From: shadowik Date: Tue, 29 Nov 2022 03:49:33 +0400 Subject: [PATCH] Choose style by Drag&Drop --- .../com/example/doubledeckerbus/ControllerBusConfig.java | 9 +++++---- .../java/com/example/doubledeckerbus/DrawingBus.java | 8 +++++++- .../com/example/doubledeckerbus/FormBusConfig.fxml | 3 +++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/DoubleDeckerBus/src/main/java/com/example/doubledeckerbus/ControllerBusConfig.java b/DoubleDeckerBus/src/main/java/com/example/doubledeckerbus/ControllerBusConfig.java index bcfe5c8..06fbd20 100644 --- a/DoubleDeckerBus/src/main/java/com/example/doubledeckerbus/ControllerBusConfig.java +++ b/DoubleDeckerBus/src/main/java/com/example/doubledeckerbus/ControllerBusConfig.java @@ -47,9 +47,6 @@ public class ControllerBusConfig { _bus.DrawTransport(gc); } - @FXML - private Button buttonCancel; - @FXML private Canvas canvasObject; @@ -104,9 +101,13 @@ public class ControllerBusConfig { case "labelModifiedObject" -> _bus = new DrawingDDB(spinnerSpeed.getValue(), spinnerWeight.getValue(), Color.WHITE, spinnerDoors.getValue(), Color.BLACK, checkBoxSecondStage.isSelected(), checkBoxLadder.isSelected()); + case "labelTriangle" -> _bus.ChangeDoor(new DrawingTriangleDoors()); + case "labelOval" -> _bus.ChangeDoor(new DrawingEllipsoidDoors()); + case "labelRect" -> _bus.ChangeDoor(new DrawingDoors()); } - event.consume(); DrawBus(); + event.consume(); + } @FXML diff --git a/DoubleDeckerBus/src/main/java/com/example/doubledeckerbus/DrawingBus.java b/DoubleDeckerBus/src/main/java/com/example/doubledeckerbus/DrawingBus.java index b3acbdc..8b96671 100644 --- a/DoubleDeckerBus/src/main/java/com/example/doubledeckerbus/DrawingBus.java +++ b/DoubleDeckerBus/src/main/java/com/example/doubledeckerbus/DrawingBus.java @@ -12,7 +12,7 @@ public class DrawingBus { int _speed; float _weight; Color _bodyColor; - int _countOfDoors; + int _countOfDoors = 3; private static final int _null = -1000; protected float _startPosX; @@ -42,6 +42,12 @@ public class DrawingBus { } + public void ChangeDoor(IDrawingDoors door) { + Doors = door; + Doors.setCountOfDoors(_countOfDoors); + } + + public DrawingBus(int speed, float weight, Color bodyColor) { Bus = new EntityBus(speed, weight, bodyColor); } diff --git a/DoubleDeckerBus/src/main/resources/com/example/doubledeckerbus/FormBusConfig.fxml b/DoubleDeckerBus/src/main/resources/com/example/doubledeckerbus/FormBusConfig.fxml index 41bee68..7b95532 100644 --- a/DoubleDeckerBus/src/main/resources/com/example/doubledeckerbus/FormBusConfig.fxml +++ b/DoubleDeckerBus/src/main/resources/com/example/doubledeckerbus/FormBusConfig.fxml @@ -54,6 +54,9 @@ +