Skip to content
Snippets Groups Projects
Commit 2270c3b5 authored by Edvard Granheim Harbo's avatar Edvard Granheim Harbo
Browse files

Merge branch 'Reset_View' into 'dev'

Fixed reset view button

See merge request !42
parents 2ae1b4a0 f3f73901
No related branches found
No related tags found
2 merge requests!54Final release,!42Fixed reset view button
......@@ -125,4 +125,16 @@ public class GameController {
public void emptyChaosGame() {
ChaosGame.getInstance().setDescription(null);
}
public void resetCanvasCoordinates() {
ChaosGameDescription description = ChaosGame.getInstance().getDescription();
Vector2D initialMin = description.getInitialMinCoords();
Vector2D initialMax = description.getInitialMaxCoords();
description.setMinCoords(initialMin);
description.setMaxCoords(initialMax);
ChaosGame.getInstance().setDescription(description);
}
}
......@@ -18,6 +18,8 @@ public class ChaosGameDescription {
// The maximum of the x and y coordinates of the game area
private Vector2D maxCoords;
private Vector2D initialMinCoords;
private Vector2D initialMaxCoords;
// The list of transforms
private List<Transform2D> transforms;
......@@ -37,6 +39,8 @@ public class ChaosGameDescription {
this.maxCoords = maxCoords;
this.transforms = transforms;
this.isWeighted = false;
this.initialMinCoords = new Vector2D(minCoords.getX0(), minCoords.getX1());
this.initialMaxCoords = new Vector2D(maxCoords.getX0(), maxCoords.getX1());
}
public ChaosGameDescription(List<Pair<Transform2D, Double>> weightedTransforms, Vector2D minCoords, Vector2D maxCoords, boolean isWeighted){
......@@ -45,6 +49,8 @@ public class ChaosGameDescription {
this.weightedTransforms = weightedTransforms;
this.transforms = weightedTransforms.stream().map(Pair::getKey).collect(Collectors.toList());
this.isWeighted = isWeighted;
this.initialMinCoords = new Vector2D(minCoords.getX0(), minCoords.getX1());
this.initialMaxCoords = new Vector2D(maxCoords.getX0(), maxCoords.getX1());
}
/**
......@@ -101,4 +107,13 @@ public class ChaosGameDescription {
}
this.maxCoords = maxCoords;
}
public Vector2D getInitialMinCoords() {
return initialMinCoords;
}
public Vector2D getInitialMaxCoords() {
return initialMaxCoords;
}
}
\ No newline at end of file
......@@ -49,13 +49,13 @@ public class ExtraUserOptions extends VBox {
extraUserOptionsLabel();
Label rotationLabel = new Label("Rotate the view");
rotationLabel.setStyle("-fx-font-size: 14px; ");
rotationLabel.setStyle("-fx-font-size: 14px; -fx-font-weight: bold;");
Label zoomLabel = new Label("Zoom");
zoomLabel.setStyle("-fx-font-size: 14px; ");
zoomLabel.setStyle("-fx-font-size: 14px; -fx-font-weight: bold;");
Label navigateLabel = new Label("Navigate");
navigateLabel.setStyle("-fx-font-size: 14px; ");
navigateLabel.setStyle("-fx-font-size: 14px; -fx-font-weight: bold;");
HBox zoomControls = new HBox(zoomInButton, zoomOutButton);
zoomControls.setAlignment(Pos.CENTER);
......@@ -100,6 +100,9 @@ public class ExtraUserOptions extends VBox {
private void resetZoomButton() {
resetViewButton.setOnAction(event -> {
gameController.resetCanvasCoordinates();
gameController.setChaosCanvas();
gameController.runTransformation();
node.getTransforms().clear();
node.setTranslateX(0);
node.setTranslateY(0);
......
......@@ -18,11 +18,12 @@ public class InformationButton extends Button {
String contentText = "Fractals use 3 primary colors to show hit density:\n" +
"Red: Top 33% hit most\nBlue: Mid 33%\nGreen: Bottom 33%\n\n" +
"Right side: Main menu - create, select, edit fractals\n" +
"Bottom menu: Extra user options for canvas interaction" +
"Left Side: Main menu - create, select, edit fractals\n" +
"Right Side: Extra user options for canvas interaction\n" +
"The reset view button brings the canvas back to its original zoom and rotation\n" +
"The clear canvas button clears the whole canvas\n\n" +
"Interact with canvas: Zoom with mouse, click-hold to move";
"Interact with canvas: use zoom buttons + to zoom in and the - to zoom out, \n " +
"Move around the canvas with navigate buttons.";
alert.setContentText(contentText);
alert.getDialogPane().setPrefWidth(400);
......
......@@ -3,10 +3,12 @@ package edu.ntnu.idatt2003.mappevurderingprog2.views.Components;
import edu.ntnu.idatt2003.mappevurderingprog2.controllers.GameController;
import edu.ntnu.idatt2003.mappevurderingprog2.views.View;
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Separator;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
public class Menu extends VBox {
......@@ -27,18 +29,32 @@ public class Menu extends VBox {
Label menuLabel = new Label("Menu");
menuLabel.setStyle("-fx-font-size: 20px; -fx-font-weight: bold;-fx-font-family: 'Times New Roman'");
quitButton.setStyle("-fx-background-color: red; -fx-text-fill: white; -fx-font-weight: bold;");
quitButton.setStyle("-fx-background-color: red; -fx-text-fill: BLACK; " +
"-fx-font-weight: bold;-fx-border-color: black; ");
quitButton.setOnAction(e -> Platform.exit());
getChildren().addAll(menuLabel,
VBox.setMargin(menuLabel, new Insets(10, 0, 10, 0));
VBox.setMargin(existingFractalsMenu, new Insets(40, 0, 10, 0));
VBox.setMargin(createFractalMenu, new Insets(40, 0, 10, 0));
VBox.setMargin(editFractalMenu, new Insets(40, 0, 10, 0));
VBox.setMargin(quitButton, new Insets(40, 0, 40, 0));
getChildren().addAll(
new Separator(),
menuLabel,
new Separator(),
existingFractalsMenu,
createFractalMenu,
editFractalMenu,
new Separator(),
quitButton);
quitButton,
new Separator());
setAlignment(Pos.TOP_CENTER);
setSpacing(20);
setStyle(" -fx-background-color: #faf0e6;");
setStyle("-fx-background-color: #faf0e6; " +
"-fx-border-color: black; " +
"-fx-border-width: 0 2 0 0px;");
}
}
\ No newline at end of file
......@@ -90,12 +90,20 @@ public class View extends BorderPane implements ChaosGameObserver {
this.menu = new Menu(this, gameController);
menu.setPrefWidth(Size.getScreenWidth() * 0.15);
menu.setMaxWidth(Size.getScreenWidth() * 0.15);
this.extraUserOptions = new ExtraUserOptions(this.getMainCanvas(), gameController);
initializeExtraUserOptions();
this.setLeft(menu);
return new Scene(this, Size.getScreenWidth(), Size.getScreenHeight());
}
private void initializeExtraUserOptions() {
extraUserOptions = new ExtraUserOptions(this.getMainCanvas(), gameController);
extraUserOptions.setPrefWidth(Size.getScreenWidth() * 0.15);
extraUserOptions.setMaxWidth(Size.getScreenWidth() * 0.15);
this.setLeft(menu);
extraUserOptions.setPrefHeight(Size.getScreenHeight());
extraUserOptions.setMaxHeight(Size.getScreenHeight());
extraUserOptions.setBackground(new Background(new BackgroundFill(Color.rgb(238, 217, 196), CornerRadii.EMPTY, Insets.EMPTY)));
extraUserOptions.setStyle("-fx-border-color: black; -fx-border-width: 0 0 0 2px;");
this.setRight(extraUserOptions);
return new Scene(this, Size.getScreenWidth(), Size.getScreenHeight());
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment