From 78664472f3f2b95b487b496bc4ef79bf4998a6de Mon Sep 17 00:00:00 2001 From: mikhail Date: Tue, 5 May 2020 15:01:31 +0300 Subject: [PATCH 01/35] Add main window --- pom.xml | 106 ++++++++++++++++++++++++ src/main/java/Controller.java | 36 ++++++++ src/main/java/Main.java | 28 +++++++ src/main/java/PlanetCharacteristic.java | 9 ++ src/main/java/SystemCharacteristic.java | 65 +++++++++++++++ src/main/java/SystemParameters.fxml | 26 ++++++ 6 files changed, 270 insertions(+) create mode 100755 pom.xml create mode 100644 src/main/java/Controller.java create mode 100644 src/main/java/Main.java create mode 100644 src/main/java/PlanetCharacteristic.java create mode 100644 src/main/java/SystemCharacteristic.java create mode 100644 src/main/java/SystemParameters.fxml diff --git a/pom.xml b/pom.xml new file mode 100755 index 0000000..eb49208 --- /dev/null +++ b/pom.xml @@ -0,0 +1,106 @@ + + + 4.0.0 + + Main + planet + 1.0 + + + UTF-8 + 11 + ${maven.compiler.source} + 5.6.0 + + + + + org.junit.jupiter + junit-jupiter + ${junit.jupiter.version} + test + + + org.jetbrains + annotations + 13.0 + compile + + + org.apache.logging.log4j + log4j-api + 2.13.1 + + + org.apache.logging.log4j + log4j-core + 2.13.1 + + + junit + junit + 4.9 + test + + + args4j + args4j + 2.33 + + + org.openjfx + javafx-controls + 11.0.2 + + + org.openjfx + javafx-fxml + 11.0.2 + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + false + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + 11 + + + + org.apache.maven.plugins + maven-jar-plugin + 3.1.0 + + + + true + Main + + + + + + org.openjfx + javafx-maven-plugin + 0.0.3 + + Main + + + + + + \ No newline at end of file diff --git a/src/main/java/Controller.java b/src/main/java/Controller.java new file mode 100644 index 0000000..bbbf839 --- /dev/null +++ b/src/main/java/Controller.java @@ -0,0 +1,36 @@ +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.Slider; +import javafx.scene.control.TextField; +import javafx.scene.input.MouseEvent; +import javafx.stage.Stage; + +public class Controller { + + @FXML + private Button apply; + @FXML + private TextField weight; + @FXML + private TextField radius; + @FXML + private TextField distance; + @FXML + private Slider number; + + @FXML + public void initialize(){ + apply.addEventHandler(MouseEvent.MOUSE_CLICKED, mouseEvent -> { + SystemCharacteristic system = new SystemCharacteristic(); + system.setNumberOfPlanets(number.getValue()); + system.setWeightOfStar(weight.getText()); + system.setFocusDistance(distance.getText()); + system.setRadiusOfStar(radius.getText()); + + System.out.println(system.toString()); + Stage stage = (Stage) apply.getScene().getWindow(); + stage.close(); + }); + } + +} \ No newline at end of file diff --git a/src/main/java/Main.java b/src/main/java/Main.java new file mode 100644 index 0000000..786c9d0 --- /dev/null +++ b/src/main/java/Main.java @@ -0,0 +1,28 @@ +import javafx.application.Application; +import javafx.stage.Stage; +import javafx.scene.Scene; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; + +import java.io.File; + +public class Main extends Application{ + + public static void main(String[] args) { + Application.launch(args); + } + + @Override + public void start(Stage stage) throws Exception { + + FXMLLoader loader = new FXMLLoader(new File("src/main/java/SystemParameters.fxml").toURI().toURL()); + Parent root = loader.load(); + Scene scene = new Scene(root); + + stage.setScene(scene); + + stage.setTitle("Hello JavaFX"); + + stage.show(); + } +} \ No newline at end of file diff --git a/src/main/java/PlanetCharacteristic.java b/src/main/java/PlanetCharacteristic.java new file mode 100644 index 0000000..eb35a26 --- /dev/null +++ b/src/main/java/PlanetCharacteristic.java @@ -0,0 +1,9 @@ +public class PlanetCharacteristic { + String name; + int distance; + byte color; + int weight; + int radius; + int destinationToTheStar; + int position; +} diff --git a/src/main/java/SystemCharacteristic.java b/src/main/java/SystemCharacteristic.java new file mode 100644 index 0000000..db6e19d --- /dev/null +++ b/src/main/java/SystemCharacteristic.java @@ -0,0 +1,65 @@ +import java.util.ArrayList; + +public class SystemCharacteristic { + ArrayList planet = new ArrayList(); + double weightOfStar; + double radiusOfStar; + short numberOfPlanets; + double focusDistance; + + public void setWeightOfStar (String weight) { + double weightDouble; + try { + weightDouble = Double.parseDouble(weight.trim()); + } + catch (NumberFormatException e) { + //здесь будет вызов MessageManager + throw e; + } + weightOfStar = weightDouble; + } + + public void setNumberOfPlanets (double num) { + numberOfPlanets = (short) num; + for (int i = 1; i < numberOfPlanets; i++) { + + } + } + + public void setRadiusOfStar (String rad) { + double radius; + try { + radius = Double.parseDouble(rad.trim()); + } + catch (NumberFormatException e) { + //здесь будет вызов MessageManager + throw e; + } + if (radius > 100000) { + //здесь будет вызов MessageManager + } + radiusOfStar = radius; + } + + public void setFocusDistance (String foc) { + double focus; + try { + focus = Double.parseDouble(foc.trim()); + } + catch (NumberFormatException e) { + //здесь будет вызов MessageManager + throw e; + } + focusDistance = focus; + } + + public String toString() { + return "SystemCharacteristic{" + + "planet=" + planet + + ", weightOfStar=" + weightOfStar + + ", radiusOfStar=" + radiusOfStar + + ", numberOfPlanets=" + numberOfPlanets + + ", focusDistance=" + focusDistance + + '}'; + } +} diff --git a/src/main/java/SystemParameters.fxml b/src/main/java/SystemParameters.fxml new file mode 100644 index 0000000..f5fee3a --- /dev/null +++ b/src/main/java/SystemParameters.fxml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + +