Browse Source

Added MatrixCalcGui and some dummy Methodes

featureMatrixCalculator
Lukas Reichwein 5 years ago
parent
commit
7cba186f82
  1. 8
      src/main/java/com/ugsbo/gui/BasicGuiController.java
  2. 12
      src/main/java/com/ugsbo/gui/MainApp.java
  3. 39
      src/main/java/com/ugsbo/matrixcalc/MatrixCalcController.java
  4. 58
      src/main/java/com/ugsbo/matrixcalc/MatrixCalcMath.java
  5. 1
      src/main/java/module-info.java
  6. 2
      src/main/resources/com/ugsbo/gui/BasicGui.fxml
  7. 32
      src/main/resources/com/ugsbo/gui/matrixCalcGui.fxml
  8. 19
      src/test/java/com/ugsbo/matrixcalc/MatrixMultiplicationTest.java

8
src/main/java/com/ugsbo/gui/BasicGuiController.java

@ -7,7 +7,7 @@ public class BasicGuiController {
// Hier werden die fx:id Attribute verknuepft.
@FXML
private Button app1; //Fuer ToDoManager.
private Button matrixCalc;
@FXML
private Button app2;
@FXML
@ -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);

12
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");
}
}

39
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);
});
}
}

58
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;
}
}

1
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;

2
src/main/resources/com/ugsbo/gui/BasicGui.fxml

@ -27,7 +27,7 @@
</AnchorPane>
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="300.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="150.0" AnchorPane.rightAnchor="150.0" AnchorPane.topAnchor="50.0">
<children>
<Button fx:id="app1" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="30.0" prefWidth="260.0" text="ToDoListe" textAlignment="CENTER" AnchorPane.leftAnchor="19.0" AnchorPane.rightAnchor="19.0" AnchorPane.topAnchor="15.0" />
<Button fx:id="matrixCalc" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="30.0" prefWidth="260.0" text="Matrix Calculator" textAlignment="CENTER" AnchorPane.leftAnchor="19.0" AnchorPane.rightAnchor="19.0" AnchorPane.topAnchor="15.0" />
<Button fx:id="app2" maxHeight="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="30.0" prefWidth="260.0" text="App2" textAlignment="CENTER" AnchorPane.leftAnchor="19.0" AnchorPane.rightAnchor="19.0" AnchorPane.topAnchor="60.0" />
<Button fx:id="app3" maxHeight="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="30.0" prefWidth="260.0" text="App3" textAlignment="CENTER" AnchorPane.leftAnchor="19.0" AnchorPane.rightAnchor="19.0" AnchorPane.topAnchor="105.0" />
<Button fx:id="app4" maxHeight="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" prefHeight="30.0" prefWidth="260.0" text="App4" textAlignment="CENTER" AnchorPane.leftAnchor="19.0" AnchorPane.rightAnchor="19.0" AnchorPane.topAnchor="150.0" />

32
src/main/resources/com/ugsbo/gui/matrixCalcGui.fxml

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.ugsbo.matrixcalc.MatrixCalcController">
<children>
<AnchorPane prefHeight="200.0" prefWidth="200.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<TextArea fx:id="matrixATextArea" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" />
</children>
</AnchorPane>
<AnchorPane layoutX="200.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="200.0" AnchorPane.leftAnchor="200.0" AnchorPane.rightAnchor="200.0" AnchorPane.topAnchor="0.0">
<children>
<Button fx:id="multiplyButton" layoutX="14.0" layoutY="27.0" mnemonicParsing="false" text="multiply" AnchorPane.leftAnchor="15.0" AnchorPane.topAnchor="27.0" />
<Button fx:id="addButton" layoutX="14.0" layoutY="62.0" mnemonicParsing="false" text="add" AnchorPane.leftAnchor="15.0" AnchorPane.topAnchor="67.0" />
<Button fx:id="substractButton" layoutX="99.0" layoutY="62.0" mnemonicParsing="false" text="Substract" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="67.0" />
<Button fx:id="transposeButton" layoutX="97.0" layoutY="27.0" mnemonicParsing="false" text="Transpose" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="27.0" />
<Button fx:id="swapInputButton" layoutX="14.0" layoutY="95.0" mnemonicParsing="false" text="Swap Input" AnchorPane.leftAnchor="15.0" AnchorPane.topAnchor="107.0" />
<Text fx:id="errorText" layoutX="14.0" layoutY="113.0" strokeType="OUTSIDE" strokeWidth="0.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="100.0" />
</children>
</AnchorPane>
<AnchorPane layoutX="400.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<TextArea fx:id="matrixBTextArea" layoutX="-15.0" layoutY="30.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0" />
</children>
</AnchorPane>
<Text fx:id="outputText" layoutX="14.0" layoutY="242.0" strokeType="OUTSIDE" strokeWidth="0.0" wrappingWidth="554.7294921875" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="210.0" />
</children>
</AnchorPane>

19
src/test/java/com/ugsbo/matrixcalc/MatrixMultiplicationTest.java

@ -0,0 +1,19 @@
package com.ugsbo.matrixcalc;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
/**
* Testet die Matrix Multiplication funkionalität
*/
public class MatrixMultiplicationTest {
/**
* This Test only tests that the assertTrue funktion works like expected.
*/
@Test
public void shouldAlwaysBeTrue() {
//TODO replace this test through a real one!!
assertTrue("The JUnit setup is not correct, this test only assertTrue.", true);
}
}
Loading…
Cancel
Save