diff --git a/src/main/java/edu/ntnu/stud/chaosgame/Main.java b/src/main/java/edu/ntnu/stud/chaosgame/Main.java index b178c7055e787c9b76cb9fd021398b65f57a3301..f864416da0e757d2a30e37bd5b3dbd647c8ed798 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/Main.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/Main.java @@ -1,11 +1,42 @@ package edu.ntnu.stud.chaosgame; +import edu.ntnu.stud.chaosgame.game.ChaosGameDescription; +import edu.ntnu.stud.chaosgame.game.ChaosGameFileHandler; +import edu.ntnu.stud.chaosgame.model.Matrix2x2; +import edu.ntnu.stud.chaosgame.model.Vector2D; +import edu.ntnu.stud.chaosgame.model.transformations.AffineTransform2D; +import edu.ntnu.stud.chaosgame.model.transformations.Transform2D; +import java.util.ArrayList; +import java.util.List; + /** * Main class for the Chaos Game application. */ public class Main { public static void main(String[] args) { - System.out.println("Hello world!"); + System.out.println("Hi"); + String path = "src/main/resources/descriptions/TestDescription.txt"; + + Vector2D minCoords = new Vector2D(0, 0); + Vector2D maxCoords = new Vector2D(1, 1); + Matrix2x2 transformMatrix = new Matrix2x2(0, 0.5, 0, 0.5); + Vector2D translationVector = new Vector2D(0.5, 0); + + AffineTransform2D affineTransform = new AffineTransform2D(transformMatrix, translationVector); + List<Transform2D> transforms = new ArrayList<>(); + transforms.add(affineTransform); + + try { + //ChaosGameDescription description = new ChaosGameFileHandler().readFromFile(path); + ChaosGameDescription description = new ChaosGameDescription(minCoords, maxCoords, transforms); + System.out.println("MaxCoords-object of description: " + description.getMaxCoords()); + } catch (Exception e) { + System.out.println(e.getMessage()); // TODO: Alter error handling + } + + + + } } \ No newline at end of file diff --git a/src/main/java/edu/ntnu/stud/chaosgame/game/ChaosGameDescription.java b/src/main/java/edu/ntnu/stud/chaosgame/game/ChaosGameDescription.java index cd84e94f77e17fc196da981ac14da9c89750c191..9416272abea06b3cee8c9dbfb3b8e3b0d30bf6b6 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/game/ChaosGameDescription.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/game/ChaosGameDescription.java @@ -6,9 +6,20 @@ import edu.ntnu.stud.chaosgame.model.transformations.Transform2D; import java.util.List; import javax.xml.crypto.dsig.Transform; +/** + * Description of the chaos game. + */ public class ChaosGameDescription { - private final Vector2D minCoords; - private final Vector2D maxCoords; + + /** + * The minimum coordinates. + */ + private final Vector2D minCoords; + + /** + * The maximum coordinates. + */ + private final Vector2D maxCoords; /** * The affine transforms for this chaos game description. @@ -37,6 +48,7 @@ public class ChaosGameDescription { public List<Transform2D> getTransforms(){ return transforms; } + /** * Getter method for minimum coordinates. * @return Returns a Vector2D containing the minimum coordinates. diff --git a/src/main/java/edu/ntnu/stud/chaosgame/game/ChaosGameFileHandler.java b/src/main/java/edu/ntnu/stud/chaosgame/game/ChaosGameFileHandler.java index d8be744741a5d88647115fd2fa4f90cd4f1f6db3..96c873772faa3153e7cdc274e05f1a78edd83217 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/game/ChaosGameFileHandler.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/game/ChaosGameFileHandler.java @@ -84,7 +84,7 @@ public class ChaosGameFileHandler { } /** - * Reads from a file + * Writes to a file * @param description A {@link ChaosGameDescription} description of the chaos game that should be written to file. * @param path A String describing the path to the file that should be written to. */ diff --git a/src/main/java/edu/ntnu/stud/chaosgame/model/handling/ChaosGame.java b/src/main/java/edu/ntnu/stud/chaosgame/model/handling/ChaosGame.java index 1e3f7967d0fbe31f34720c666db6c5a6a66981fd..a6d63d8eb30610f3839e65d0277e67b2c1493896 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/model/handling/ChaosGame.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/model/handling/ChaosGame.java @@ -1,5 +1,6 @@ package edu.ntnu.stud.chaosgame.model.handling; +import edu.ntnu.stud.chaosgame.game.ChaosGameDescription; import edu.ntnu.stud.chaosgame.model.Vector2D; import java.util.Random; @@ -13,6 +14,11 @@ public class ChaosGame { */ private ChaosCanvas canvas; + /** + * The chaos game description. + */ + private ChaosGameDescription description; + /** * The description for this ChaosGame */ @@ -28,4 +34,9 @@ public class ChaosGame { */ public Random random; + public ChaosGame(ChaosGameDescription description, ChaosCanvas canvas) { + this.canvas = canvas; + this.description = description; + } + } diff --git a/src/main/resources/descriptions/TestDescription.txt b/src/main/resources/descriptions/TestDescription.txt new file mode 100644 index 0000000000000000000000000000000000000000..15826998ba790f8310f103ae4f9a2f6afe967741 --- /dev/null +++ b/src/main/resources/descriptions/TestDescription.txt @@ -0,0 +1,6 @@ +Affine2D +0.0,0.0 +1.0,1.0 +1.0,0.0,0.0,1.0,0.0,0.0 +0.0,1.0,1.0,0.0,0.0,0.0 +0.5,0.5,0.5,0.5,0.0,0.0 \ No newline at end of file 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 2ddc4f172bf80290126a5a41f9ff04283efb92e3..cb62cdc698315c67d8f5e36c181b468a088d7898 100644 --- a/src/test/java/edu/ntnu/stud/chaosgame/transformations/JuliaTransformTest.java +++ b/src/test/java/edu/ntnu/stud/chaosgame/transformations/JuliaTransformTest.java @@ -3,6 +3,7 @@ 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.transformations.JuliaTransform; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested;