diff --git a/pom.xml b/pom.xml
index b3c3356..e02aad9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,7 +75,7 @@
default-cli
- dmt.projectairbus/dmt.projectairbus.HelloApplication
+ dmt.projectairbus/dmt.projectairbus.ApplicationAirbus
app
app
app
diff --git a/src/main/java/dmt/projectairbus/ApplicationAirbus.java b/src/main/java/dmt/projectairbus/ApplicationAirbus.java
new file mode 100644
index 0000000..305d76d
--- /dev/null
+++ b/src/main/java/dmt/projectairbus/ApplicationAirbus.java
@@ -0,0 +1,30 @@
+package dmt.projectairbus;
+
+import javafx.application.Application;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.stage.Stage;
+
+import java.io.IOException;
+import java.util.Objects;
+
+public class ApplicationAirbus extends Application {
+ @Override
+ public void start(Stage stage) throws IOException {
+ FXMLLoader fxmlLoader = new FXMLLoader(ApplicationAirbus.class.getResource("View.fxml"));
+ Scene scene = new Scene(fxmlLoader.load(), 900, 500);
+
+ String stylesheet = Objects.requireNonNull(getClass().getResource("Style.css")).toExternalForm();
+ scene.getStylesheets().add(stylesheet);
+
+ stage.setTitle("Аэробус");
+ stage.setScene(scene);
+ stage.setResizable(false);
+
+ stage.show();
+ }
+
+ public static void main(String[] args) {
+ launch();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/dmt/projectairbus/DirectionType.java b/src/main/java/dmt/projectairbus/DirectionType.java
new file mode 100644
index 0000000..28aad43
--- /dev/null
+++ b/src/main/java/dmt/projectairbus/DirectionType.java
@@ -0,0 +1,36 @@
+package dmt.projectairbus;
+
+/**
+ * Направление перемещения
+ */
+public enum DirectionType {
+ /**
+ * Вверх
+ */
+ Up(1),
+
+ /**
+ * Вниз
+ */
+ Down(2),
+
+ /**
+ * Влево
+ */
+ Left(3),
+
+ /**
+ * Вправо
+ */
+ Right(4);
+
+ private final int value;
+
+ DirectionType(int value) {
+ this.value = value;
+ }
+
+ public int getValue() {
+ return value;
+ }
+}
diff --git a/src/main/java/dmt/projectairbus/DrawningAirbus.java b/src/main/java/dmt/projectairbus/DrawningAirbus.java
new file mode 100644
index 0000000..c2709e5
--- /dev/null
+++ b/src/main/java/dmt/projectairbus/DrawningAirbus.java
@@ -0,0 +1,162 @@
+package dmt.projectairbus;
+
+import javafx.scene.paint.Color;
+import java.awt.*;
+
+import javafx.scene.shape.*;
+import javafx.stage.Stage;
+import javafx.util.Duration;
+import javafx.scene.canvas.GraphicsContext;
+import javafx.scene.paint.Color;
+import java.awt.Stroke;
+
+public class DrawningAirbus {
+ private EntityAirbus entityAirbus;
+ private Integer pictureWidth;
+ private Integer pictureHeight;
+ private Integer startPosX;
+ private Integer startPosY;
+
+ private final int drawningAirbusWidth = 155;
+ private final int drawningAirbusHeight = 70;
+
+ public EntityAirbus getEntityAirbus() {
+ return entityAirbus;
+ }
+
+ public void Init(int speed, double weight, Color bodyColor, Color additionalColor, boolean passengerSection, boolean engines) {
+ entityAirbus = new EntityAirbus();
+ entityAirbus.Init(speed, weight, bodyColor, additionalColor, passengerSection, engines);
+ pictureWidth = null;
+ pictureHeight = null;
+ startPosX = null;
+ startPosY = null;
+ }
+
+ public boolean setPictureSize(int width, int height) {
+ if (drawningAirbusWidth <= width && drawningAirbusHeight <= height) {
+ pictureHeight = height;
+ pictureWidth = width;
+ if (startPosX != null && startPosY != null) {
+ if (startPosX + drawningAirbusWidth > pictureWidth) {
+ startPosX = pictureWidth - drawningAirbusWidth;
+ }
+ if (startPosY + drawningAirbusHeight > pictureHeight) {
+ startPosY = pictureHeight - drawningAirbusHeight;
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public void setPosition(int x, int y) {
+ if (pictureHeight == null || pictureWidth == null) {
+ return;
+ }
+
+ if (x + drawningAirbusWidth > pictureWidth) {
+ startPosX = pictureWidth - drawningAirbusWidth;
+ } else if (x < 0) {
+ startPosX = 0;
+ } else {
+ startPosX = x;
+ }
+
+ if (y + drawningAirbusHeight > pictureHeight) {
+ startPosY = pictureHeight - drawningAirbusHeight;
+ } else if (y < 0) {
+ startPosY = 0;
+ } else {
+ startPosY = y;
+ }
+ }
+
+ public boolean moveTransport(DirectionType direction) {
+ if (entityAirbus == null || startPosX == null || startPosY == null) {
+ return false;
+ }
+
+ switch (direction) {
+ case Left:
+ if (startPosX - entityAirbus.getStep() > 0) {
+ startPosX -= entityAirbus.getStep();
+ }
+ return true;
+ case Up:
+ if (startPosY - entityAirbus.getStep() > 0) {
+ startPosY -= entityAirbus.getStep();
+ }
+ return true;
+ case Right:
+ if (startPosX + entityAirbus.getStep() + drawningAirbusWidth < pictureWidth) {
+ startPosX += entityAirbus.getStep();
+ }
+ return true;
+ case Down:
+ if (startPosY + entityAirbus.getStep() + drawningAirbusHeight < pictureHeight) {
+ startPosY += entityAirbus.getStep();
+ }
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ public void drawTransport(GraphicsContext g) {
+ if (entityAirbus == null || startPosX == null || startPosY == null) {
+ return;
+ }
+
+ g.clearRect(0, 0, pictureWidth, pictureHeight);
+
+ g.setStroke(Color.BLACK);
+ g.setLineWidth(3);
+ g.setFill(entityAirbus.getAdditionalColor());
+
+ double[] pointsSectionX = { startPosX + 45, startPosX + 65, startPosX + 95, startPosX + 115 };
+ double[] pointsSectionY = { startPosY + 30, startPosY + 20, startPosY + 20, startPosY + 30 };
+
+ if (entityAirbus.getPassengerSection()) {
+ g.fillPolygon(pointsSectionX, pointsSectionY, pointsSectionX.length);
+ g.strokePolygon(pointsSectionX, pointsSectionY, pointsSectionX.length);
+ }
+
+ double[] pointsWingX = { startPosX + 1, startPosX + 1, startPosX + 45, startPosX + 45, startPosX + 25 };
+ double[] pointsWingY = { startPosY + 1, startPosY + 44, startPosY + 44, startPosY + 33, startPosY + 33 };
+
+ double[] pointsWindowX = { startPosX + 115, startPosX + 115, startPosX + 155 };
+ double[] pointsWindowY = { startPosY + 33, startPosY + 40, startPosY + 40 };
+
+ g.strokeLine(startPosX, startPosY, startPosX, startPosY + 47);
+ g.strokeLine(startPosX, startPosY + 30, startPosX + 90, startPosY + 30);
+ g.strokeLine(startPosX + 25, startPosY + 30, startPosX, startPosY);
+ g.strokeArc(startPosX, startPosY + 30, 152, 32, -170, 250, ArcType.OPEN);
+
+ g.setFill(entityAirbus.getBodyColor());
+ g.fillOval(startPosX + 1, startPosY + 31, 149, 29);
+ g.fillPolygon(pointsWingX, pointsWingY, pointsWingX.length);
+ g.strokeLine(startPosX + 45, startPosY + 55, startPosX + 100, startPosY + 55);
+
+ /// Шасси
+ g.strokeLine(startPosX + 35, startPosY + 60, startPosX + 35, startPosY + 70);
+ g.strokeLine(startPosX + 110, startPosY + 60, startPosX + 110, startPosY + 70);
+ g.strokeRect(startPosX + 26, startPosY + 68, 8, 8);
+ g.strokeRect(startPosX + 36, startPosY + 68, 8, 8);
+ g.strokeRect(startPosX + 101, startPosY + 68, 8, 8);
+ g.strokeRect(startPosX + 111, startPosY + 68, 8, 8);
+
+ /// Окно
+ g.setFill(Color.LIGHTBLUE);
+ g.fillPolygon(pointsWindowX, pointsWindowY, pointsWindowX.length);
+ g.strokeLine(startPosX + 115, startPosY + 33, startPosX + 115, startPosY + 40);
+ g.strokeLine(startPosX + 115, startPosY + 40, startPosX + 150, startPosY + 40);
+ g.strokeLine(startPosX + 150, startPosY + 40, startPosX + 115, startPosY + 33);
+
+ if (entityAirbus.getEngines()) {
+ g.fillOval(startPosX, startPosY + 30, 35, 15);
+ g.strokeOval(startPosX, startPosY + 30, 35, 15);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/dmt/projectairbus/EntityAirbus.java b/src/main/java/dmt/projectairbus/EntityAirbus.java
new file mode 100644
index 0000000..754b3c5
--- /dev/null
+++ b/src/main/java/dmt/projectairbus/EntityAirbus.java
@@ -0,0 +1,81 @@
+package dmt.projectairbus;
+
+import javafx.scene.paint.Color;
+
+/**
+ * Класс-сущность "Аэробус"
+ */
+public class EntityAirbus {
+ /**
+ * Скорость
+ */
+ private int speed;
+ public int getSpeed() {
+ return speed;
+ }
+
+ /**
+ * Вес
+ */
+ private double weight;
+ public double getWeight() {
+ return weight;
+ }
+
+ /**
+ * Основной цвет
+ */
+ private Color bodyColor;
+ public Color getBodyColor() {
+ return bodyColor;
+ }
+
+ /**
+ * Дополнительный цвет (для опциональных элементов)
+ */
+ private Color additionalColor;
+ public Color getAdditionalColor() {
+ return additionalColor;
+ }
+
+ /**
+ * Признак(опция) наличия доп. пассажирского отсека
+ */
+ private boolean passengerSection;
+ public boolean getPassengerSection() {
+ return passengerSection;
+ }
+
+ /**
+ * Признак(опция) наличия доп. двигателей
+ */
+ private boolean engines;
+ public boolean getEngines() {
+ return engines;
+ }
+
+ /**
+ * Шаг перемещения аэробуса
+ */
+ public int getStep() {
+ return (int)(speed * 100 / weight);
+ }
+
+ /**
+ * Инициализация полей объекта-класса аэробус
+ * @param speed Скорость
+ * @param weight Вес аэробуса
+ * @param bodyColor Основной цвет
+ * @param additionalColor Дополнительный цвет
+ * @param passengerSection Признак(опция) наличия доп. пассажирского отсека
+ * @param engines Признак(опция) наличия доп. двигателей
+ */
+ public void Init(int speed, double weight, Color bodyColor, Color additionalColor, boolean passengerSection, boolean engines) {
+ this.speed = speed;
+ this.weight = weight;
+ this.bodyColor = bodyColor;
+ this.additionalColor = additionalColor;
+ this.passengerSection = passengerSection;
+ this.engines = engines;
+ }
+}
diff --git a/src/main/java/dmt/projectairbus/FormAirbus.java b/src/main/java/dmt/projectairbus/FormAirbus.java
new file mode 100644
index 0000000..b9c0169
--- /dev/null
+++ b/src/main/java/dmt/projectairbus/FormAirbus.java
@@ -0,0 +1,64 @@
+package dmt.projectairbus;
+
+import javafx.event.ActionEvent;
+import javafx.fxml.FXML;
+import javafx.scene.canvas.Canvas;
+import javafx.scene.canvas.GraphicsContext;
+import javafx.scene.control.Button;
+import javafx.scene.paint.Color;
+
+import java.util.Random;
+
+public class FormAirbus {
+ private DrawningAirbus drawningAirbus;
+ private GraphicsContext graphicsContext;
+ private Random random;
+
+ @FXML
+ private Canvas mainCanvas;
+
+ @FXML
+ private void initialize() {
+ drawningAirbus = new DrawningAirbus();
+ graphicsContext = mainCanvas.getGraphicsContext2D();
+ graphicsContext.setImageSmoothing(false);
+
+ random = new Random();
+ }
+
+ private void Draw(){
+ drawningAirbus.drawTransport(graphicsContext);
+ }
+
+ @FXML
+ protected void buttonCreate_Click() {
+ drawningAirbus.Init(
+ random.nextInt(100, 300), random.nextInt(1000, 3000),
+ Color.rgb(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
+ Color.rgb(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
+ random.nextBoolean(), random.nextBoolean()
+ );
+ drawningAirbus.setPictureSize((int) mainCanvas.getWidth(), (int) mainCanvas.getHeight());
+ drawningAirbus.setPosition(random.nextInt(10, 100), random.nextInt(10, 100));
+
+ Draw();
+ }
+
+ @FXML
+ protected void buttonMove_Click(ActionEvent event) {
+ String name = ((Button) event.getSource()).getId();
+
+ boolean result = switch (name) {
+ case "buttonUp" -> drawningAirbus.moveTransport(DirectionType.Up);
+ case "buttonDown" -> drawningAirbus.moveTransport(DirectionType.Down);
+ case "buttonLeft" -> drawningAirbus.moveTransport(DirectionType.Left);
+ case "buttonRight" -> drawningAirbus.moveTransport(DirectionType.Right);
+ default -> false;
+ };
+
+ if (result)
+ {
+ Draw();
+ }
+ }
+}
diff --git a/src/main/java/dmt/projectairbus/HelloApplication.java b/src/main/java/dmt/projectairbus/HelloApplication.java
deleted file mode 100644
index d13ff23..0000000
--- a/src/main/java/dmt/projectairbus/HelloApplication.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package dmt.projectairbus;
-
-import javafx.application.Application;
-import javafx.fxml.FXMLLoader;
-import javafx.scene.Scene;
-import javafx.stage.Stage;
-
-import java.io.IOException;
-
-public class HelloApplication extends Application {
- @Override
- public void start(Stage stage) throws IOException {
- FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
- Scene scene = new Scene(fxmlLoader.load(), 320, 240);
- stage.setTitle("Hello!");
- stage.setScene(scene);
- stage.show();
- }
-
- public static void main(String[] args) {
- launch();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/dmt/projectairbus/HelloController.java b/src/main/java/dmt/projectairbus/HelloController.java
deleted file mode 100644
index 3ea3d5c..0000000
--- a/src/main/java/dmt/projectairbus/HelloController.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package dmt.projectairbus;
-
-import javafx.fxml.FXML;
-import javafx.scene.control.Label;
-
-public class HelloController {
- @FXML
- private Label welcomeText;
-
- @FXML
- protected void onHelloButtonClick() {
- welcomeText.setText("Welcome to JavaFX Application!");
- }
-}
\ No newline at end of file
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
index 25c7cfe..eed46fe 100644
--- a/src/main/java/module-info.java
+++ b/src/main/java/module-info.java
@@ -4,6 +4,7 @@ module dmt.projectairbus {
requires org.controlsfx.controls;
requires com.dlsc.formsfx;
+ requires java.desktop;
opens dmt.projectairbus to javafx.fxml;
exports dmt.projectairbus;
diff --git a/src/main/resources/dmt/projectairbus/Style.css b/src/main/resources/dmt/projectairbus/Style.css
new file mode 100644
index 0000000..086bfbb
--- /dev/null
+++ b/src/main/resources/dmt/projectairbus/Style.css
@@ -0,0 +1,31 @@
+#buttonLeft
+{
+ -fx-background-image: url("arrowLeft.png");
+ -fx-background-size: 85%;
+ -fx-background-position: center;
+ -fx-background-repeat: space;
+}
+
+#buttonUp
+{
+ -fx-background-image: url("arrowUp.png");
+ -fx-background-size: 85%;
+ -fx-background-position: center;
+ -fx-background-repeat: space;
+}
+
+#buttonDown
+{
+ -fx-background-image: url("arrowDown.png");
+ -fx-background-size: 85%;
+ -fx-background-position: center;
+ -fx-background-repeat: space;
+}
+
+#buttonRight
+{
+ -fx-background-image: url("arrowRight.png");
+ -fx-background-size: 85%;
+ -fx-background-position: center;
+ -fx-background-repeat: space;
+}
\ No newline at end of file
diff --git a/src/main/resources/dmt/projectairbus/View.fxml b/src/main/resources/dmt/projectairbus/View.fxml
new file mode 100644
index 0000000..6cb6c36
--- /dev/null
+++ b/src/main/resources/dmt/projectairbus/View.fxml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/dmt/projectairbus/arrowDown.png b/src/main/resources/dmt/projectairbus/arrowDown.png
new file mode 100644
index 0000000..24ac497
Binary files /dev/null and b/src/main/resources/dmt/projectairbus/arrowDown.png differ
diff --git a/src/main/resources/dmt/projectairbus/arrowLeft.png b/src/main/resources/dmt/projectairbus/arrowLeft.png
new file mode 100644
index 0000000..c880974
Binary files /dev/null and b/src/main/resources/dmt/projectairbus/arrowLeft.png differ
diff --git a/src/main/resources/dmt/projectairbus/arrowRight.png b/src/main/resources/dmt/projectairbus/arrowRight.png
new file mode 100644
index 0000000..d170a9f
Binary files /dev/null and b/src/main/resources/dmt/projectairbus/arrowRight.png differ
diff --git a/src/main/resources/dmt/projectairbus/arrowUp.png b/src/main/resources/dmt/projectairbus/arrowUp.png
new file mode 100644
index 0000000..91c151d
Binary files /dev/null and b/src/main/resources/dmt/projectairbus/arrowUp.png differ
diff --git a/src/main/resources/dmt/projectairbus/hello-view.fxml b/src/main/resources/dmt/projectairbus/hello-view.fxml
deleted file mode 100644
index c4af6b3..0000000
--- a/src/main/resources/dmt/projectairbus/hello-view.fxml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-