From a24bf4cc728bc28bc1bf801a5c69343f6eca4e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Daleng?= <142524365+MrMarHVD@users.noreply.github.com> Date: Mon, 1 Apr 2024 15:08:53 +0200 Subject: [PATCH] Reorganised file structure and added placeholder for ChaosGameObserver. --- src/main/java/edu/ntnu/stud/chaosgame/Main.java | 3 ++- .../stud/chaosgame/controller/ChaosGameObserver.java | 12 ++++++++++++ .../stud/chaosgame/model/{ => data}/Complex.java | 4 ++-- .../stud/chaosgame/model/{ => data}/Matrix2x2.java | 2 +- .../stud/chaosgame/model/{ => data}/Vector2D.java | 2 +- .../ntnu/stud/chaosgame/model/game/ChaosCanvas.java | 4 ++-- .../ntnu/stud/chaosgame/model/game/ChaosGame.java | 2 +- .../chaosgame/model/game/ChaosGameDescription.java | 3 +-- .../chaosgame/model/game/ChaosGameFileHandler.java | 6 +++--- .../model/transformations/AffineTransform2D.java | 4 ++-- .../model/transformations/JuliaTransform.java | 4 ++-- .../chaosgame/model/transformations/Transform2D.java | 2 +- .../chaosgame/game/ChaosGameDescriptionTest.java | 6 +++--- .../transformations/AffineTransform2DTest.java | 4 ++-- .../transformations/JuliaTransformTest.java | 6 +++--- 15 files changed, 38 insertions(+), 26 deletions(-) create mode 100644 src/main/java/edu/ntnu/stud/chaosgame/controller/ChaosGameObserver.java rename src/main/java/edu/ntnu/stud/chaosgame/model/{ => data}/Complex.java (85%) rename src/main/java/edu/ntnu/stud/chaosgame/model/{ => data}/Matrix2x2.java (97%) rename src/main/java/edu/ntnu/stud/chaosgame/model/{ => data}/Vector2D.java (96%) diff --git a/src/main/java/edu/ntnu/stud/chaosgame/Main.java b/src/main/java/edu/ntnu/stud/chaosgame/Main.java index a6e8cc0..befa3b7 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/Main.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/Main.java @@ -34,10 +34,11 @@ public class Main { System.out.println(e.getMessage()); // TODO: Alter error game } + /* Test whether factory successfully instantiates descriptions. ChaosGameDescriptionFactory factory = new ChaosGameDescriptionFactory(); for (ChaosGameDescription desc : factory.getDescriptions()) { System.out.println(desc); - } + }*/ boolean exit = false; diff --git a/src/main/java/edu/ntnu/stud/chaosgame/controller/ChaosGameObserver.java b/src/main/java/edu/ntnu/stud/chaosgame/controller/ChaosGameObserver.java new file mode 100644 index 0000000..d558acb --- /dev/null +++ b/src/main/java/edu/ntnu/stud/chaosgame/controller/ChaosGameObserver.java @@ -0,0 +1,12 @@ +package edu.ntnu.stud.chaosgame.controller; + +import edu.ntnu.stud.chaosgame.model.game.ChaosCanvas; +import edu.ntnu.stud.chaosgame.model.game.ChaosGameDescription; + +/** + * Observer class for monitoring changes to the active + * ChaosGameDescription {@link ChaosGameDescription} or the canvas {@link ChaosCanvas} + */ +public class ChaosGameObserver { +// TODO: Create class +} diff --git a/src/main/java/edu/ntnu/stud/chaosgame/model/Complex.java b/src/main/java/edu/ntnu/stud/chaosgame/model/data/Complex.java similarity index 85% rename from src/main/java/edu/ntnu/stud/chaosgame/model/Complex.java rename to src/main/java/edu/ntnu/stud/chaosgame/model/data/Complex.java index 8c71216..a926323 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/model/Complex.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/model/data/Complex.java @@ -1,9 +1,9 @@ -package edu.ntnu.stud.chaosgame.model; +package edu.ntnu.stud.chaosgame.model.data; /** * Class representing a complex number. */ -public class Complex extends Vector2D{ +public class Complex extends Vector2D { /** * Create a new complex number. diff --git a/src/main/java/edu/ntnu/stud/chaosgame/model/Matrix2x2.java b/src/main/java/edu/ntnu/stud/chaosgame/model/data/Matrix2x2.java similarity index 97% rename from src/main/java/edu/ntnu/stud/chaosgame/model/Matrix2x2.java rename to src/main/java/edu/ntnu/stud/chaosgame/model/data/Matrix2x2.java index caab08e..8b5e1de 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/model/Matrix2x2.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/model/data/Matrix2x2.java @@ -1,4 +1,4 @@ -package edu.ntnu.stud.chaosgame.model; +package edu.ntnu.stud.chaosgame.model.data; import edu.ntnu.stud.chaosgame.model.game.ChaosGameDescription; diff --git a/src/main/java/edu/ntnu/stud/chaosgame/model/Vector2D.java b/src/main/java/edu/ntnu/stud/chaosgame/model/data/Vector2D.java similarity index 96% rename from src/main/java/edu/ntnu/stud/chaosgame/model/Vector2D.java rename to src/main/java/edu/ntnu/stud/chaosgame/model/data/Vector2D.java index 2c0ad6c..fce55dd 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/model/Vector2D.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/model/data/Vector2D.java @@ -1,4 +1,4 @@ -package edu.ntnu.stud.chaosgame.model; +package edu.ntnu.stud.chaosgame.model.data; /** * Class representing a 2D vector. diff --git a/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosCanvas.java b/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosCanvas.java index 530564c..f8826be 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosCanvas.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosCanvas.java @@ -1,7 +1,7 @@ package edu.ntnu.stud.chaosgame.model.game; -import edu.ntnu.stud.chaosgame.model.Matrix2x2; -import edu.ntnu.stud.chaosgame.model.Vector2D; +import edu.ntnu.stud.chaosgame.model.data.Matrix2x2; +import edu.ntnu.stud.chaosgame.model.data.Vector2D; import edu.ntnu.stud.chaosgame.model.transformations.AffineTransform2D; diff --git a/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGame.java b/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGame.java index 4ab7c9d..26d2f5f 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGame.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGame.java @@ -1,6 +1,6 @@ package edu.ntnu.stud.chaosgame.model.game; -import edu.ntnu.stud.chaosgame.model.Vector2D; +import edu.ntnu.stud.chaosgame.model.data.Vector2D; import java.util.Random; /** diff --git a/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGameDescription.java b/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGameDescription.java index 519aa88..31034c6 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGameDescription.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGameDescription.java @@ -1,10 +1,9 @@ package edu.ntnu.stud.chaosgame.model.game; -import edu.ntnu.stud.chaosgame.model.Vector2D; +import edu.ntnu.stud.chaosgame.model.data.Vector2D; import edu.ntnu.stud.chaosgame.model.transformations.Transform2D; import java.util.List; -import javax.xml.crypto.dsig.Transform; /** * Description of the chaos game. diff --git a/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGameFileHandler.java b/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGameFileHandler.java index e28929b..47300b2 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGameFileHandler.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/model/game/ChaosGameFileHandler.java @@ -1,8 +1,8 @@ package edu.ntnu.stud.chaosgame.model.game; -import edu.ntnu.stud.chaosgame.model.Complex; -import edu.ntnu.stud.chaosgame.model.Matrix2x2; -import edu.ntnu.stud.chaosgame.model.Vector2D; +import edu.ntnu.stud.chaosgame.model.data.Complex; +import edu.ntnu.stud.chaosgame.model.data.Matrix2x2; +import edu.ntnu.stud.chaosgame.model.data.Vector2D; import edu.ntnu.stud.chaosgame.model.transformations.AffineTransform2D; import edu.ntnu.stud.chaosgame.model.transformations.JuliaTransform; import edu.ntnu.stud.chaosgame.model.transformations.Transform2D; diff --git a/src/main/java/edu/ntnu/stud/chaosgame/model/transformations/AffineTransform2D.java b/src/main/java/edu/ntnu/stud/chaosgame/model/transformations/AffineTransform2D.java index 7f04ea7..65a871d 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/model/transformations/AffineTransform2D.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/model/transformations/AffineTransform2D.java @@ -1,7 +1,7 @@ package edu.ntnu.stud.chaosgame.model.transformations; -import edu.ntnu.stud.chaosgame.model.Matrix2x2; -import edu.ntnu.stud.chaosgame.model.Vector2D; +import edu.ntnu.stud.chaosgame.model.data.Matrix2x2; +import edu.ntnu.stud.chaosgame.model.data.Vector2D; import edu.ntnu.stud.chaosgame.model.game.ChaosGameFileHandler; /** diff --git a/src/main/java/edu/ntnu/stud/chaosgame/model/transformations/JuliaTransform.java b/src/main/java/edu/ntnu/stud/chaosgame/model/transformations/JuliaTransform.java index 5f4dbd2..c6cf7e0 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/model/transformations/JuliaTransform.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/model/transformations/JuliaTransform.java @@ -1,7 +1,7 @@ package edu.ntnu.stud.chaosgame.model.transformations; -import edu.ntnu.stud.chaosgame.model.Complex; -import edu.ntnu.stud.chaosgame.model.Vector2D; +import edu.ntnu.stud.chaosgame.model.data.Complex; +import edu.ntnu.stud.chaosgame.model.data.Vector2D; import edu.ntnu.stud.chaosgame.model.game.ChaosGameFileHandler; public class JuliaTransform extends Transform2D { diff --git a/src/main/java/edu/ntnu/stud/chaosgame/model/transformations/Transform2D.java b/src/main/java/edu/ntnu/stud/chaosgame/model/transformations/Transform2D.java index be9aae7..d3bf3ca 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/model/transformations/Transform2D.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/model/transformations/Transform2D.java @@ -1,6 +1,6 @@ package edu.ntnu.stud.chaosgame.model.transformations; -import edu.ntnu.stud.chaosgame.model.Vector2D; +import edu.ntnu.stud.chaosgame.model.data.Vector2D; /** * Abstract class representing transformations in a 2D-plane. diff --git a/src/test/java/edu/ntnu/stud/chaosgame/game/ChaosGameDescriptionTest.java b/src/test/java/edu/ntnu/stud/chaosgame/game/ChaosGameDescriptionTest.java index 15b98d0..027010f 100644 --- a/src/test/java/edu/ntnu/stud/chaosgame/game/ChaosGameDescriptionTest.java +++ b/src/test/java/edu/ntnu/stud/chaosgame/game/ChaosGameDescriptionTest.java @@ -1,8 +1,8 @@ package edu.ntnu.stud.chaosgame.game; -import edu.ntnu.stud.chaosgame.model.Complex; -import edu.ntnu.stud.chaosgame.model.Matrix2x2; -import edu.ntnu.stud.chaosgame.model.Vector2D; +import edu.ntnu.stud.chaosgame.model.data.Complex; +import edu.ntnu.stud.chaosgame.model.data.Matrix2x2; +import edu.ntnu.stud.chaosgame.model.data.Vector2D; import edu.ntnu.stud.chaosgame.model.game.ChaosGameDescription; import edu.ntnu.stud.chaosgame.model.transformations.AffineTransform2D; import edu.ntnu.stud.chaosgame.model.transformations.JuliaTransform; diff --git a/src/test/java/edu/ntnu/stud/chaosgame/transformations/AffineTransform2DTest.java b/src/test/java/edu/ntnu/stud/chaosgame/transformations/AffineTransform2DTest.java index 5ff7732..c166b36 100644 --- a/src/test/java/edu/ntnu/stud/chaosgame/transformations/AffineTransform2DTest.java +++ b/src/test/java/edu/ntnu/stud/chaosgame/transformations/AffineTransform2DTest.java @@ -1,7 +1,7 @@ package edu.ntnu.stud.chaosgame.transformations; -import edu.ntnu.stud.chaosgame.model.Matrix2x2; -import edu.ntnu.stud.chaosgame.model.Vector2D; +import edu.ntnu.stud.chaosgame.model.data.Matrix2x2; +import edu.ntnu.stud.chaosgame.model.data.Vector2D; import edu.ntnu.stud.chaosgame.model.transformations.AffineTransform2D; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/edu/ntnu/stud/chaosgame/transformations/JuliaTransformTest.java b/src/test/java/edu/ntnu/stud/chaosgame/transformations/JuliaTransformTest.java index cb62cdc..4a2ca54 100644 --- a/src/test/java/edu/ntnu/stud/chaosgame/transformations/JuliaTransformTest.java +++ b/src/test/java/edu/ntnu/stud/chaosgame/transformations/JuliaTransformTest.java @@ -1,8 +1,8 @@ package edu.ntnu.stud.chaosgame.transformations; -import edu.ntnu.stud.chaosgame.model.Complex; -import edu.ntnu.stud.chaosgame.model.Matrix2x2; -import edu.ntnu.stud.chaosgame.model.Vector2D; +import edu.ntnu.stud.chaosgame.model.data.Complex; +import edu.ntnu.stud.chaosgame.model.data.Matrix2x2; +import edu.ntnu.stud.chaosgame.model.data.Vector2D; import edu.ntnu.stud.chaosgame.model.transformations.JuliaTransform; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; -- GitLab