From 7cba186f82a72eedf2aed1135edd8fb833d7ed7a Mon Sep 17 00:00:00 2001 From: Lukas Reichwein Date: Wed, 26 Jun 2019 16:21:41 +0200 Subject: [PATCH 01/30] Added MatrixCalcGui and some dummy Methodes --- .../com/ugsbo/gui/BasicGuiController.java | 12 ++-- src/main/java/com/ugsbo/gui/MainApp.java | 12 +++- .../matrixcalc/MatrixCalcController.java | 39 +++++++++++++ .../com/ugsbo/matrixcalc/MatrixCalcMath.java | 58 +++++++++++++++++++ src/main/java/module-info.java | 1 + .../resources/com/ugsbo/gui/BasicGui.fxml | 2 +- .../com/ugsbo/gui/matrixCalcGui.fxml | 32 ++++++++++ .../matrixcalc/MatrixMultiplicationTest.java | 19 ++++++ 8 files changed, 167 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/ugsbo/matrixcalc/MatrixCalcController.java create mode 100644 src/main/java/com/ugsbo/matrixcalc/MatrixCalcMath.java create mode 100644 src/main/resources/com/ugsbo/gui/matrixCalcGui.fxml create mode 100644 src/test/java/com/ugsbo/matrixcalc/MatrixMultiplicationTest.java diff --git a/src/main/java/com/ugsbo/gui/BasicGuiController.java b/src/main/java/com/ugsbo/gui/BasicGuiController.java index 6a313df..5e66758 100644 --- a/src/main/java/com/ugsbo/gui/BasicGuiController.java +++ b/src/main/java/com/ugsbo/gui/BasicGuiController.java @@ -5,9 +5,9 @@ import javafx.scene.control.*; public class BasicGuiController { - //Hier werden die fx:id Attribute verknuepft. + // Hier werden die fx:id Attribute verknuepft. @FXML - private Button app1; //Fuer ToDoManager. + private Button matrixCalc; @FXML private Button app2; @FXML @@ -19,7 +19,7 @@ public class BasicGuiController { * Konstructor is called before initialize() */ public BasicGuiController() { - //Setup of some Fields could be defined here. + // Setup of some Fields could be defined here. } /** @@ -28,9 +28,9 @@ public class BasicGuiController { */ @FXML public void initialize() { - app1.setOnMouseClicked((event) -> { - //MainApp.startToDoMainGui(); - System.out.println(event); + matrixCalc.setOnMouseClicked((event) -> { + MainApp.startMatrixCalcGUI(); + // System.out.println(event); }); app2.setOnMouseClicked((event) -> { System.out.println(event); diff --git a/src/main/java/com/ugsbo/gui/MainApp.java b/src/main/java/com/ugsbo/gui/MainApp.java index 7da8f02..f420ab7 100644 --- a/src/main/java/com/ugsbo/gui/MainApp.java +++ b/src/main/java/com/ugsbo/gui/MainApp.java @@ -35,7 +35,7 @@ public class MainApp extends Application { /** * Loades the FXML file and the Default CSS. * - * @param stage The Stage will be passed over from fxml + * @param stage The Stage will be passed over from JavaFx * @param fxmlFileName Only the Filename of the fxml file wich sould be loaded */ private void createStageFromFXML(Stage stage, String fxmlFileName) { @@ -58,4 +58,14 @@ public class MainApp extends Application { } stage.show(); } + + /** + * Startet eine Instanz der MatrixCalcGui. + */ + public static void startMatrixCalcGUI() { + Stage stage = new Stage(); + MainApp app = new MainApp(); + app.createStageFromFXML(stage, "matrixCalcGui"); + } + } diff --git a/src/main/java/com/ugsbo/matrixcalc/MatrixCalcController.java b/src/main/java/com/ugsbo/matrixcalc/MatrixCalcController.java new file mode 100644 index 0000000..2c2acf0 --- /dev/null +++ b/src/main/java/com/ugsbo/matrixcalc/MatrixCalcController.java @@ -0,0 +1,39 @@ +package com.ugsbo.matrixcalc; + +import javafx.fxml.FXML; +import javafx.scene.control.*; +import javafx.scene.text.Text; + +public class MatrixCalcController { + + // Hier werden die fx:id Attribute verknuepft. + @FXML + private Button multiplyButton, addButton, swapInputButton, substractButton, transposeButton; + @FXML + private Text errorText, outputText; + @FXML + private TextArea matrixATextArea, matrixBTextArea; + + /** + * Konstructor is called before initialize() + */ + public MatrixCalcController() { + // Setup of some Fields could be defined here. + } + + /** + * Initializes the controller class. This method is automatically called after + * the fxml file has been loaded. + */ + @FXML + public void initialize() { + multiplyButton.setOnMouseClicked((event) -> { + // TODO matrixATextArea and matrixBTextArea need to be parsed to Double[][] do + // this in an extern Methode maybe an extern class. + // MatrixCalcMath math = new MatrixCalcMath(); + // math.matrixMultiplication(matrixATextArea, matrixATextArea); + System.out.println(event); + }); + } + +} \ No newline at end of file diff --git a/src/main/java/com/ugsbo/matrixcalc/MatrixCalcMath.java b/src/main/java/com/ugsbo/matrixcalc/MatrixCalcMath.java new file mode 100644 index 0000000..4725418 --- /dev/null +++ b/src/main/java/com/ugsbo/matrixcalc/MatrixCalcMath.java @@ -0,0 +1,58 @@ +package com.ugsbo.matrixcalc; + +/** + * Contains all basic matrix math calculations. + */ +public class MatrixCalcMath { + + /** + * Mutliplys matrixA and matrixB. + * + * @param matrixA The Inputmatrix A (right TextArea in the GUI) + * @param matrixB The Inputmatrix B (left TextArea in the GUI) + * @return The Matrixproduct of the matricies A and B + */ + public Double[][] matrixMultiplication(Double[][] matrixA, Double[][] matrixB) { + // TODO Matrix Multiplication + return null; + } + + /** + * checks if matrixA and matrixB are linked to know if it is possible to + * multiply them. If they are linked it is possible. + * + * @param matrixA The Inputmatrix A (right TextArea in the GUI) + * @param matrixB The Inputmatrix B (left TextArea in the GUI) + * @return true if you can Muliply A with B false if not. + */ + public boolean checkIfMatriciesAreLinked(Double[][] matrixA, Double[][] matrixB) { + // TODO Check if the number of Rows of Matrix A equal to the coulums of Matrix B + return false; + } + + /** + * Adds two matroices A and B. Adding matrix A to matrix B is the same as adding + * B to A. + * + * @param matrixA The Inputmatrix A (right TextArea in the GUI) + * @param matrixB The Inputmatrix B (left TextArea in the GUI) + * @return The Matrixsum of matrix A and matrix B + */ + public Double[][] matrixAddition(Double[][] matrixA, Double[][] matrixB) { + // TODO Sum each Element of matrix A to the corrosponding elem in B + return null; + } + + /** + * In order to adding two Matricies they must have the same Dimensions. This + * Methode checks if this is the case. + * + * @param matrixA The Inputmatrix A (right TextArea in the GUI) + * @param matrixB The Inputmatrix B (left TextArea in the GUI) + * @return true if the Dimensions of Matrix A equals the Dimensions Matrix B + */ + public boolean checkIfMatriciesAreTheSameDimension(Double[][] matrixA, Double[][] matrixB) { + // TODO Dimension check. + return false; + } +} \ No newline at end of file diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index a48c156..b859978 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -2,6 +2,7 @@ module UGSBO { requires javafx.controls; requires javafx.fxml; + opens com.ugsbo.matrixcalc to javafx.fxml; opens com.ugsbo.gui to javafx.fxml; exports com.ugsbo.gui; diff --git a/src/main/resources/com/ugsbo/gui/BasicGui.fxml b/src/main/resources/com/ugsbo/gui/BasicGui.fxml index 0fcd44d..d591c5a 100644 --- a/src/main/resources/com/ugsbo/gui/BasicGui.fxml +++ b/src/main/resources/com/ugsbo/gui/BasicGui.fxml @@ -27,7 +27,7 @@ -