Class ChaosGame
java.lang.Object
edu.ntnu.stud.chaosgame.controller.game.ChaosGame
Class representing the chaos game, responsible for managing its progression.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ChaosCanvas
The ChaosCanvas for this ChaosGame.private Vector2D
The current point in the chaos game.private ChaosGameDescription
The chaos game description.private final int
Number of transforms.private ArrayList
<ChaosGameObserver> Observers monitoring this ChaosGame.private final Random
The random number generator for the chaos game. -
Constructor Summary
ConstructorsConstructorDescriptionChaosGame
(ChaosGameDescription description, ChaosCanvas canvas) Basic parameterised constructor. -
Method Summary
Modifier and TypeMethodDescriptionfindValidPoint
(Vector2D point) If the point is out of bounds, iterate until it is within bounds.Get the canvas of this chaos game.Get the current point in the chaos game.Get the description for this choas game.void
runSteps
(int n) Run the chaos game for n iterations.void
setDescription
(ChaosGameDescription description) Get the chaos game description.
-
Field Details
-
canvas
The ChaosCanvas for this ChaosGame. -
description
The chaos game description. -
observers
Observers monitoring this ChaosGame. -
currentPoint
The current point in the chaos game. -
random
The random number generator for the chaos game. -
numOfTransforms
private final int numOfTransformsNumber of transforms.
-
-
Constructor Details
-
ChaosGame
Basic parameterised constructor.- Parameters:
description
- the ChaosGameDescription.canvas
- the ChaosCanvas.
-
-
Method Details
-
getCanvas
Get the canvas of this chaos game.- Returns:
- the canvas.
-
getCurrentPoint
Get the current point in the chaos game.- Returns:
- the point.
-
getDescription
Get the description for this choas game.- Returns:
- the description.
-
setDescription
Get the chaos game description.- Parameters:
description
- the description to set.
-
runSteps
public void runSteps(int n) Run the chaos game for n iterations.- Parameters:
n
- the number of iterations.
-
findValidPoint
If the point is out of bounds, iterate until it is within bounds. If the method fails to find a valid point within 100 iterations, it returns the original point.- Parameters:
point
- the starting point.- Returns:
- the resulting valid point within bounds, or the original point if no valid point is found.
-