diff --git a/src/main/java/edu/ntnu/stud/chaosgame/controller/game/GuiButtonController.java b/src/main/java/edu/ntnu/stud/chaosgame/controller/game/GuiButtonController.java index bee579520d85416b4d9da7253dd2bfab2a3efa03..f0b78e1b717e7bc4f9c6ad6fc0895536077ac803 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/controller/game/GuiButtonController.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/controller/game/GuiButtonController.java @@ -298,6 +298,7 @@ public class GuiButtonController { */ public void startGame() { timeline.play(); + gui.getStartButton().setText("Start"); } /** @@ -305,6 +306,7 @@ public class GuiButtonController { */ public void stopGame() { timeline.stop(); + gui.getStartButton().setText("Resume"); } /** @@ -380,6 +382,4 @@ public class GuiButtonController { game = new ChaosGame(description, chaosCanvas); game.setUseColor(gui.getColorCheckBox().isSelected()); } - - } \ No newline at end of file diff --git a/src/main/java/edu/ntnu/stud/chaosgame/controller/utility/ChaosGameFileHandler.java b/src/main/java/edu/ntnu/stud/chaosgame/controller/utility/ChaosGameFileHandler.java index d39db5ca87d65e9c6a9f675d7ecd58c92043815a..e48f77999d284514127f025ec033c57a8ef3b0b8 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/controller/utility/ChaosGameFileHandler.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/controller/utility/ChaosGameFileHandler.java @@ -46,7 +46,7 @@ public class ChaosGameFileHandler { name = scanner.next().trim(); - if (firstLine.equals("Affine2D") && !Formatter.canConvertToFloat(name)) { + if (firstLine.equals("Affine2D") && Formatter.canConvertToFloat(name)) { // Read the minimum vector if (scanner.hasNextDouble()) { double x0min = scanner.nextDouble(); @@ -80,7 +80,7 @@ public class ChaosGameFileHandler { Transform2D transform2D = new AffineTransform2D(matrix2x2, vector2D); transforms.add(transform2D); - }} else if(firstLine.equals("Julia") && !Formatter.canConvertToFloat(name)){ + }} else if(firstLine.equals("Julia") && Formatter.canConvertToFloat(name)){ // Read the minimum vector if (scanner.hasNextDouble()) { double x0min = scanner.nextDouble(); diff --git a/src/main/java/edu/ntnu/stud/chaosgame/controller/utility/Formatter.java b/src/main/java/edu/ntnu/stud/chaosgame/controller/utility/Formatter.java index 2f6f776b519b209af5d4418c19dea3980d636809..89aa26817e72508f53ab66d639716ef07c056eac 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/controller/utility/Formatter.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/controller/utility/Formatter.java @@ -79,6 +79,6 @@ public class Formatter { canConvert = true; } catch (NumberFormatException ignored) { } - return canConvert; + return !canConvert; } } diff --git a/src/main/java/edu/ntnu/stud/chaosgame/controller/PopupManager.java b/src/main/java/edu/ntnu/stud/chaosgame/controller/utility/PopupManager.java similarity index 90% rename from src/main/java/edu/ntnu/stud/chaosgame/controller/PopupManager.java rename to src/main/java/edu/ntnu/stud/chaosgame/controller/utility/PopupManager.java index 5cec0d70fb9bdae39e0a65d2c60a3ff15e90b09c..67852062d7c91d14a46273ab62ceb0de4a4bbdd0 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/controller/PopupManager.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/controller/utility/PopupManager.java @@ -1,4 +1,4 @@ -package edu.ntnu.stud.chaosgame.controller; +package edu.ntnu.stud.chaosgame.controller.utility; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; diff --git a/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameImageView.java b/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameImageView.java index e956a4f580081ca591abdba502bf203d5e644846..bdc3d284e2885ab6f236a98555a533f86f15d805 100644 --- a/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameImageView.java +++ b/src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameImageView.java @@ -1,6 +1,6 @@ package edu.ntnu.stud.chaosgame.view; -import edu.ntnu.stud.chaosgame.controller.PopupManager; +import edu.ntnu.stud.chaosgame.controller.utility.PopupManager; import javafx.scene.image.ImageView; import javafx.scene.input.ScrollEvent; import javafx.scene.transform.Affine; @@ -21,13 +21,14 @@ public class ChaosGameImageView extends ImageView { */ private final Affine transform = new Affine(); - private double centreX; - private double centreY; - /** - * The starting x and y positions upon a mouse event. + * The starting position of the mouse cursor when dragging. */ private double startX; + + /** + * The starting position of the mouse cursor when dragging. + */ private double startY; /** @@ -74,7 +75,7 @@ public class ChaosGameImageView extends ImageView { * @param event the event. */ private synchronized void userZoom(ScrollEvent event) { - double newZoomFactor = event.getDeltaY() > 0 ? 1.10 : 1 / 1.05; + double newZoomFactor = event.getDeltaY() > 0 ? 1.05 : 1 / 1.05; try { // Get the old values double oldScaleX = transform.getMxx(); @@ -103,38 +104,6 @@ public class ChaosGameImageView extends ImageView { } } - public void fixedZoom(double newZoomFactor) { - try { - // Get the old values - double oldScaleX = transform.getMxx(); - double oldScaleY = transform.getMyy(); - double oldTranslateX = transform.getTx(); - double oldTranslateY = transform.getTy(); - - // Compute the new values - double newScaleX = oldScaleX * newZoomFactor; - double newScaleY = oldScaleY * newZoomFactor; - double newTranslateX = oldTranslateX - (this.getWidth() / 2 * (newScaleX - oldScaleX)); - double newTranslateY = oldTranslateY - (this.getHeight() / 2 * (newScaleY - oldScaleY)); - - // Update the transform - transform.setMxx(newScaleX); - transform.setMyy(newScaleY); - transform.setTx(newTranslateX); - transform.setTy(newTranslateY); - - this.zoomFactor *= newZoomFactor; - this.zoomLevel = (int) (Math.log(this.zoomFactor) / Math.log(4)); // Update zoom level. - - } catch (Exception e) { - PopupManager.displayError("Zoom error", e.getMessage()); - } - } -// TODO: remove if unused - private void updateController() { - this.controller.updateDetail(this.zoomLevel, this.centreX, this.centreY); - } - /** * Gets mouse cursor position data when mouse button is pressed. *