diff --git a/src/main/java/projekt/enigma/App.java b/src/main/java/projekt/enigma/App.java new file mode 100644 index 0000000000000000000000000000000000000000..f53dcdf988f86a5bedf676f34009bdcaf9fcf9d5 --- /dev/null +++ b/src/main/java/projekt/enigma/App.java @@ -0,0 +1,66 @@ +package projekt.enigma; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +import java.io.IOException; + +/** + * JavaFX App + */ +public class App extends Application { + + /** + * TODO Dokumentieren + */ + private static Scene scene; + + /** + * TODO Dokumentieren + * + * @param fxml + * @throws IOException + */ + static void setRoot(String fxml) throws IOException { + scene.setRoot(loadFXML(fxml)); + } + + /** + * TODO Dokumentieren + * + * @param fxml + * @return + * @throws IOException + */ + private static Parent loadFXML(String fxml) throws IOException { + FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource(fxml + ".fxml")); + return fxmlLoader.load(); + } + + /** + * TODO Dokumentieren + * + * @param args + */ + public static void main(String[] args) { + Application.launch(); + } + + /** + * TODO Dokumentieren + * + * @param stage + * @throws IOException + */ + @Override + public void start(Stage stage) throws IOException { + scene = new Scene(loadFXML("kenngruppe")); + stage.setScene(scene); + stage.setResizable(true); + stage.show(); + } + +} diff --git a/src/main/java/projekt/enigma/KenngruppeController.java b/src/main/java/projekt/enigma/KenngruppeController.java index 79ed1a081019f57c7970c721171b445873fa48e7..57d0be7a5a771caed15905594803cff20cb2d973 100644 --- a/src/main/java/projekt/enigma/KenngruppeController.java +++ b/src/main/java/projekt/enigma/KenngruppeController.java @@ -1,56 +1,39 @@ package projekt.enigma; -import java.awt.event.ActionEvent; import java.io.IOException; import javafx.fxml.FXML; -import javafx.scene.Node; -import javafx.scene.Scene; -import javafx.scene.control.Button; import javafx.scene.control.TextField; -import javafx.stage.Stage; import projekt.enigma.model.Codierer; - public class KenngruppeController { private Codierer cod = new Codierer(); - private Stage stage; - - @FXML private TextField tfKenngruppe; - @FXML - private Button btnswitch; - -// @FXML -// private void switchToPrimary() throws IOException { -// if (tfKenngruppe.getText().length() <= 8) { -// for (char c : tfKenngruppe.getText().toCharArray()) { -// if (c == 'a' || c == 'b' || c == 'c' || c == 'd' || c == 'e' || c == 'f' || c == 'g' || c == 'h' || c == 'i' || c == 'j' || c == 'k' || c == 'l' || c == 'm' || c == 'n' || c == 'o' || c == 'p' || c == 'q' || c == 'r' || c == 's' || c == 't' || c == 'u' || c == 'v' || c == 'w' || c == 'x' || c == 'y' || c == 'z') { -// cod.setKenngruppe(tfKenngruppe.getText()); -// -// App.setRoot("gui"); -// } -// } -// } else { -// tfKenngruppe.setStyle("-fx-background-color:#FF0000"); -// tfKenngruppe.setText("Fehlerhafte Kenngruppe!"); -// } -// } - private Scene secondScene; - - public void setSecondScene(Scene scene){ - secondScene=scene; - } + //TODO: Doku + /** + * Beim drücken der Taste wird überprüft ob die eingegebene Kenngruppe weniger als 9 Zeichen hat und ob die + * eingegebenen Zeichen nur Buchstaben sind. + * Bei einer gültigen Eingabe wird die eingegebene Kenngruppe gespeichert und die Enigma-Anwendung gestartet + * @throws IOException : + */ @FXML - private void switchToPrimary(ActionEvent ae) throws IOException { - Stage primaryStage = (Stage)((Node)ae.getSource()).getScene().getWindow(); - primaryStage.setScene(secondScene); + private void btnGui() throws IOException { + if (tfKenngruppe.getText().length() <9) { + for (char c : tfKenngruppe.getText().toCharArray()) { + if (c == 'a' || c == 'b' || c == 'c' || c == 'd' || c == 'e' || c == 'f' || c == 'g' || c == 'h' || c == 'i' || c == 'j' || c == 'k' || c == 'l' || c == 'm' || c == 'n' || c == 'o' || c == 'p' || c == 'q' || c == 'r' || c == 's' || c == 't' || c == 'u' || c == 'v' || c == 'w' || c == 'x' || c == 'y' || c == 'z'||c == 'A' || c == 'B' || c == 'C' || c == 'D' || c == 'E' || c == 'F' || c == 'G' || c == 'H' || c == 'I' || c == 'J' || c == 'K' || c == 'L' || c == 'M' || c == 'N' || c == 'O' || c == 'P' || c == 'Q' || c == 'R' || c == 'S' || c == 'T' || c == 'U' || c == 'V' || c == 'W' || c == 'X' || c == 'Y' || c == 'Z') { + cod.setKenngruppe(tfKenngruppe.getText()); + + //setzt + App.setRoot("gui"); + } + } + } else { + tfKenngruppe.setStyle("-fx-background-color:#FF0000"); + tfKenngruppe.setText("Fehlerhafte Kenngruppe!"); + } } - - - } diff --git a/src/main/resources/projekt/enigma/gui.fxml b/src/main/resources/projekt/enigma/gui.fxml index 6e28fe1c37b7a09e80b5a9367fbfd409598af45b..541232d5cffb09e2bcd7a2c7d5a910faed867ba6 100644 --- a/src/main/resources/projekt/enigma/gui.fxml +++ b/src/main/resources/projekt/enigma/gui.fxml @@ -7,26 +7,14 @@ <?import javafx.scene.control.TextField?> <?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.ColumnConstraints?> -<?import javafx.scene.layout.FlowPane?> <?import javafx.scene.layout.GridPane?> <?import javafx.scene.layout.RowConstraints?> -<?import javafx.scene.layout.VBox?> <?import javafx.scene.shape.Circle?> <?import javafx.scene.text.Font?> <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="677.0" prefWidth="962.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="projekt.enigma.GuiController"> <children> - <AnchorPane layoutX="241.0" layoutY="130.0" prefHeight="111.0" prefWidth="487.0" AnchorPane.leftAnchor="241.0" AnchorPane.rightAnchor="240.0"> - <children> - <VBox layoutX="72.0" layoutY="-89.0" prefHeight="210.0" prefWidth="377.0" AnchorPane.bottomAnchor="-10.0" AnchorPane.leftAnchor="72.0" AnchorPane.rightAnchor="37.0" AnchorPane.topAnchor="-89.0"> - <children> - <TextField fx:id="tfKlartext" editable="false" prefHeight="80.0" prefWidth="377.0" /> - <Label prefHeight="17.0" prefWidth="385.0" /> - <TextField fx:id="tfCodiert" editable="false" prefHeight="79.0" prefWidth="377.0" /> - <Label prefHeight="17.0" prefWidth="385.0" /> - </children> - </VBox> - </children></AnchorPane> + <AnchorPane layoutX="207.0" layoutY="-111.0" prefHeight="111.0" prefWidth="487.0" AnchorPane.leftAnchor="207.0" AnchorPane.rightAnchor="274.0" /> <GridPane layoutX="23.0" layoutY="60.0" prefHeight="158.0" prefWidth="237.0" AnchorPane.leftAnchor="23.0" AnchorPane.topAnchor="60.0"> <columnConstraints> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> @@ -92,13 +80,6 @@ </MenuButton> </children> </GridPane> - <FlowPane layoutX="736.0" layoutY="51.0" prefHeight="173.0" prefWidth="195.0" AnchorPane.rightAnchor="36.0" AnchorPane.topAnchor="51.0"> - <children> - <Button fx:id="btnEmpfangen" mnemonicParsing="false" onAction="#gedrueckteTaste" prefHeight="80.0" prefWidth="195.0" text="Funkspruch empfangen" /> - <Label prefHeight="17.0" prefWidth="195.0" /> - <Button fx:id="btnSenden" mnemonicParsing="false" onAction="#gedrueckteTaste" prefHeight="80.0" prefWidth="195.0" text="An Funker senden" /> - </children> - </FlowPane> <GridPane layoutX="23.0" layoutY="222.0" prefHeight="60.0" prefWidth="270.0" AnchorPane.leftAnchor="23.0" AnchorPane.topAnchor="222.0"> <columnConstraints> <ColumnConstraints hgrow="SOMETIMES" maxWidth="206.0" minWidth="10.0" prefWidth="102.0" /> @@ -690,5 +671,34 @@ </Label> </children> </GridPane> + <Label layoutX="684.0" layoutY="-164.0" prefHeight="17.0" prefWidth="195.0" /> + <GridPane layoutX="297.0" layoutY="64.0" prefHeight="168.0" prefWidth="585.0"> + <columnConstraints> + <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> + <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> + </columnConstraints> + <rowConstraints> + <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> + <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> + </rowConstraints> + <children> + <TextField fx:id="tfKlartext" editable="false" prefHeight="70.0" prefWidth="293.0"> + <GridPane.margin> + <Insets /> + </GridPane.margin> + </TextField> + <TextField fx:id="tfCodiert" editable="false" prefHeight="70.0" prefWidth="293.0" GridPane.rowIndex="1" /> + <Button fx:id="btnSenden" alignment="CENTER" contentDisplay="RIGHT" mnemonicParsing="false" onAction="#gedrueckteTaste" prefHeight="70.0" prefWidth="195.0" text="An Funker senden" textAlignment="CENTER" GridPane.columnIndex="1"> + <GridPane.margin> + <Insets left="80.0" /> + </GridPane.margin> + </Button> + <Button fx:id="btnEmpfangen" mnemonicParsing="false" onAction="#gedrueckteTaste" prefHeight="70.0" prefWidth="195.0" text="Funkspruch empfangen" GridPane.columnIndex="1" GridPane.rowIndex="1"> + <GridPane.margin> + <Insets left="80.0" /> + </GridPane.margin> + </Button> + </children> + </GridPane> </children> </AnchorPane> diff --git a/src/main/resources/projekt/enigma/kenngruppe.fxml b/src/main/resources/projekt/enigma/kenngruppe.fxml index 8beeef733c27bdb39769eb2c544cbf3696c55a9a..019c9c177e31b671dfd904d3396474510999c159 100644 --- a/src/main/resources/projekt/enigma/kenngruppe.fxml +++ b/src/main/resources/projekt/enigma/kenngruppe.fxml @@ -14,7 +14,7 @@ <Label prefHeight="62.0" prefWidth="209.0" /> <TextField fx:id="tfKenngruppe" /> <Label prefHeight="39.0" prefWidth="209.0" /> - <Button fx:id="btnswitch" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" onAction="#switchToPrimary" prefHeight="25.0" prefWidth="212.0" text="Kenngruppe setzen!" /> + <Button maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" onAction="#btnGui" prefHeight="25.0" prefWidth="212.0" text="Kenngruppe setzen!" /> </children> </VBox> </children>