Skip to content
Snippets Groups Projects
Commit 42235b57 authored by Håvard Daleng's avatar Håvard Daleng
Browse files

Ensured classes work such that work can begin on ChaosGame-class.

parent 78782cf8
No related branches found
No related tags found
No related merge requests found
package edu.ntnu.stud.chaosgame; 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. * Main class for the Chaos Game application.
*/ */
public class Main { public class Main {
public static void main(String[] args) { 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
...@@ -6,9 +6,20 @@ import edu.ntnu.stud.chaosgame.model.transformations.Transform2D; ...@@ -6,9 +6,20 @@ import edu.ntnu.stud.chaosgame.model.transformations.Transform2D;
import java.util.List; import java.util.List;
import javax.xml.crypto.dsig.Transform; import javax.xml.crypto.dsig.Transform;
/**
* Description of the chaos game.
*/
public class ChaosGameDescription { 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. * The affine transforms for this chaos game description.
...@@ -37,6 +48,7 @@ public class ChaosGameDescription { ...@@ -37,6 +48,7 @@ public class ChaosGameDescription {
public List<Transform2D> getTransforms(){ public List<Transform2D> getTransforms(){
return transforms; return transforms;
} }
/** /**
* Getter method for minimum coordinates. * Getter method for minimum coordinates.
* @return Returns a Vector2D containing the minimum coordinates. * @return Returns a Vector2D containing the minimum coordinates.
......
...@@ -84,7 +84,7 @@ public class ChaosGameFileHandler { ...@@ -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 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. * @param path A String describing the path to the file that should be written to.
*/ */
......
package edu.ntnu.stud.chaosgame.model.handling; package edu.ntnu.stud.chaosgame.model.handling;
import edu.ntnu.stud.chaosgame.game.ChaosGameDescription;
import edu.ntnu.stud.chaosgame.model.Vector2D; import edu.ntnu.stud.chaosgame.model.Vector2D;
import java.util.Random; import java.util.Random;
...@@ -13,6 +14,11 @@ public class ChaosGame { ...@@ -13,6 +14,11 @@ public class ChaosGame {
*/ */
private ChaosCanvas canvas; private ChaosCanvas canvas;
/**
* The chaos game description.
*/
private ChaosGameDescription description;
/** /**
* The description for this ChaosGame * The description for this ChaosGame
*/ */
...@@ -28,4 +34,9 @@ public class ChaosGame { ...@@ -28,4 +34,9 @@ public class ChaosGame {
*/ */
public Random random; public Random random;
public ChaosGame(ChaosGameDescription description, ChaosCanvas canvas) {
this.canvas = canvas;
this.description = description;
}
} }
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
...@@ -3,6 +3,7 @@ package edu.ntnu.stud.chaosgame.transformations; ...@@ -3,6 +3,7 @@ package edu.ntnu.stud.chaosgame.transformations;
import edu.ntnu.stud.chaosgame.model.Complex; import edu.ntnu.stud.chaosgame.model.Complex;
import edu.ntnu.stud.chaosgame.model.Matrix2x2; import edu.ntnu.stud.chaosgame.model.Matrix2x2;
import edu.ntnu.stud.chaosgame.model.Vector2D; 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.BeforeEach;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment