Lukas Reichwein
6 years ago
8 changed files with 167 additions and 8 deletions
-
12src/main/java/com/ugsbo/gui/BasicGuiController.java
-
12src/main/java/com/ugsbo/gui/MainApp.java
-
39src/main/java/com/ugsbo/matrixcalc/MatrixCalcController.java
-
58src/main/java/com/ugsbo/matrixcalc/MatrixCalcMath.java
-
1src/main/java/module-info.java
-
2src/main/resources/com/ugsbo/gui/BasicGui.fxml
-
32src/main/resources/com/ugsbo/gui/matrixCalcGui.fxml
-
19src/test/java/com/ugsbo/matrixcalc/MatrixMultiplicationTest.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); |
|||
}); |
|||
} |
|||
|
|||
} |
@ -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; |
|||
} |
|||
} |
@ -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> |
@ -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); |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue