From 42235b57552fdd465c4a18aa934412051c985274 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?H=C3=A5vard=20Daleng?=
 <142524365+MrMarHVD@users.noreply.github.com>
Date: Tue, 26 Mar 2024 14:56:30 +0100
Subject: [PATCH] Ensured classes work such that work can begin on
 ChaosGame-class.

---
 .../java/edu/ntnu/stud/chaosgame/Main.java    | 33 ++++++++++++++++++-
 .../chaosgame/game/ChaosGameDescription.java  | 16 +++++++--
 .../chaosgame/game/ChaosGameFileHandler.java  |  2 +-
 .../chaosgame/model/handling/ChaosGame.java   | 11 +++++++
 .../descriptions/TestDescription.txt          |  6 ++++
 .../transformations/JuliaTransformTest.java   |  1 +
 6 files changed, 65 insertions(+), 4 deletions(-)
 create mode 100644 src/main/resources/descriptions/TestDescription.txt

diff --git a/src/main/java/edu/ntnu/stud/chaosgame/Main.java b/src/main/java/edu/ntnu/stud/chaosgame/Main.java
index b178c70..f864416 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 cd84e94..9416272 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 d8be744..96c8737 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 1e3f796..a6d63d8 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 0000000..1582699
--- /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 2ddc4f1..cb62cdc 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;
-- 
GitLab