Skip to content
Snippets Groups Projects
Commit c74fe184 authored by Hans Lawrence Pettersen's avatar Hans Lawrence Pettersen
Browse files

Fixed bug: this.steps was not updated for julia transformations

parent 7a894552
No related branches found
No related tags found
1 merge request!7#23 juli bug
Pipeline #280372 passed
......@@ -92,6 +92,7 @@ public class Fractal {
}
public void createAffineImage(int steps, boolean color) {
this.steps = steps;
this.colorIteration = color;
fractalCanvas.clearCanvas();
runSteps(steps);
......@@ -118,6 +119,7 @@ public class Fractal {
}
public void createJuliaImage(int steps) {
this.steps = steps;
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = image.createGraphics();
Transform2D c = description.getTransformations().getFirst();
......@@ -151,6 +153,7 @@ public class Fractal {
}
public void createMandelImage(int steps) {
this.steps = steps;
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = image.createGraphics();
......@@ -203,11 +206,13 @@ public class Fractal {
}
}
public void updateImage() {
// Update the image and notify observers (create methods give notification)
public void updateImageAndNotify() {
switch (description.getTransformationType()) {
case "Affine2D" -> createAffineImage(steps, colorIteration);
case "Julia" -> createJuliaImage(steps);
case "Mandel" -> createMandelImage(steps);
default -> notifyObservers();
}
}
......@@ -239,8 +244,7 @@ public class Fractal {
fractalCanvas.setMinCoords(new Vector2D(xMinMap, yMinMap));
fractalCanvas.setMaxCoords(new Vector2D(xMaxMap, yMaxMap));
updateImage();
notifyObservers();
updateImageAndNotify();
}
public void zoomOut() {
......@@ -264,8 +268,7 @@ public class Fractal {
fractalCanvas.setMaxCoords(new Vector2D(xMaxMap, yMaxMap));
fractalCanvas.setMinCoords(new Vector2D(xMinMap, yMinMap));
updateImage();
notifyObservers();
updateImageAndNotify();
}
public void centerCanvas(double xNorm, double yNorm) {
......@@ -275,15 +278,13 @@ public class Fractal {
fractalCanvas.centerCanvasJulia(xNorm, yNorm);
}
updateDescriptionAndCanvas();
updateImage();
notifyObservers();
updateImageAndNotify();
}
public void reset() {
fractalCanvas.resetCoordinates();
updateDescriptionAndCanvas();
updateImage();
notifyObservers();
updateImageAndNotify();
}
public void updateDescriptionAndCanvas() {
......@@ -295,12 +296,12 @@ public class Fractal {
public void setSteps(int steps) {
this.steps = steps;
updateImage();
updateImageAndNotify();
}
public void setColorIteration(boolean colorIteration) {
this.colorIteration = colorIteration;
updateImage();
updateImageAndNotify();
}
public void setZoomFactor(double zoomFactor) {
......
......@@ -28,8 +28,8 @@ public class FractalCanvas {
this.canvas = new int[height][width]; // Initialize canvas array
this.minCoords = minCoords;
this.maxCoords = maxCoords;
this.limitMin = minCoords;
this.limitMax = maxCoords;
this.limitMin = this.minCoords;
this.limitMax = this.maxCoords;
}
/**
......
......@@ -24,13 +24,12 @@ public class Footer extends HBox {
private Button[] zoomButtons;
private ComboBox<String> zoomFactor;
private ComboBox<String> juliaSetMenu;
private VBox affineSliderBox;
private VBox juliaSliderBox;
private VBox toggleColorBox;
private VBox affiSliderBox;
private VBox juliSliderBox;
private VBox affiColBox;
private HBox zoomBox;
private VBox juliaSetBox;
private VBox juliSetBox;
private HBox tipBox;
private TipButton footerTip;
private TipButton startTip;
public Footer() {
......@@ -42,10 +41,10 @@ public class Footer extends HBox {
DropShadow shadow = new DropShadow();
setEffect(shadow);
affineSliderBox = createAffineSlider();
juliaSliderBox = createJuliaSlider();
juliaSetBox = createJuliaSetBox();
toggleColorBox = createToggleColorBox();
affiSliderBox = createAffineSlider();
juliSliderBox = createJuliaSlider();
juliSetBox = createJuliaSetBox();
affiColBox = createToggleColorBox();
zoomBox = createZoomBox();
tipBox = createTooltip();
......@@ -74,19 +73,19 @@ public class Footer extends HBox {
public void affineMode() {
getChildren().clear();
getChildren().addAll(toggleColorBox, affineSliderBox, tipBox, zoomBox);
getChildren().addAll(affiColBox, affiSliderBox, tipBox, zoomBox);
configureLayout();
}
public void juliaMode() {
getChildren().clear();
getChildren().addAll(juliaSetBox, juliaSliderBox, tipBox, zoomBox);
getChildren().addAll(juliSetBox, juliSliderBox, tipBox, zoomBox);
configureLayout();
}
public void mandelMode() {
getChildren().clear();
getChildren().addAll(juliaSliderBox, tipBox, zoomBox);
getChildren().addAll(juliSliderBox, tipBox, zoomBox);
configureLayout();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment