Skip to content
Snippets Groups Projects
Commit 4ea1ec62 authored by Edvard Berdal Eek's avatar Edvard Berdal Eek
Browse files

Slight refactoring of gui, removing redundancy improving uniformity

parent 3a5fc02a
No related branches found
No related tags found
1 merge request!20Created test classes for Factory and FileReader. Created equals methods
Pipeline #287962 passed
...@@ -21,12 +21,10 @@ public class MainApp extends Application { ...@@ -21,12 +21,10 @@ public class MainApp extends Application {
new PageController(mainPane, chaosGameController, exploreGameController); new PageController(mainPane, chaosGameController, exploreGameController);
Scene scene = new Scene(mainPane, 1200, 800); Scene scene = new Scene(mainPane, 1200, 800);
mainPane.prefWidthProperty().bind(scene.widthProperty());
mainPane.prefHeightProperty().bind(scene.heightProperty());
scene.getStylesheets().add(Objects.requireNonNull(getClass().getResource("/global.css")).toExternalForm()); scene.getStylesheets().add(Objects.requireNonNull(getClass().getResource("/global.css")).toExternalForm());
primaryStage.setMinWidth(800); primaryStage.setMinWidth(1000);
primaryStage.setMinHeight(600); primaryStage.setMinHeight(650);
primaryStage.setScene(scene); primaryStage.setScene(scene);
primaryStage.setTitle("Chaos Game Canvas"); primaryStage.setTitle("Chaos Game Canvas");
......
...@@ -27,15 +27,14 @@ public class ChaosPage extends GamePage { ...@@ -27,15 +27,14 @@ public class ChaosPage extends GamePage {
this.bottomBar.getStyleClass().add("chaos-text"); this.bottomBar.getStyleClass().add("chaos-text");
SideBar sideBar = new SideBar(chaosGameController); SideBar sideBar = new SideBar(chaosGameController);
this.setCenter(gc.getCanvas());
this.setTop(topBar); this.setTop(topBar);
this.setRight(sideBar); this.setRight(sideBar);
this.setBottom(bottomBar); this.setBottom(bottomBar);
this.setLeft(gc.getCanvas());
} }
public void updateInformation(Transform2D transformation, int steps, Vector2D min, Vector2D max) { public void updateInformation(Transform2D transformation, int steps, Vector2D min, Vector2D max) {
topBar.updateTopBar(transformation, steps, min, max); topBar.updateTotalTopBar(transformation, steps, min, max);
bottomBar.updateBottomBar(transformation); bottomBar.updateBottomBar(transformation);
} }
......
...@@ -32,16 +32,15 @@ public class BottomBar extends HBox { ...@@ -32,16 +32,15 @@ public class BottomBar extends HBox {
public BottomBar(GameController gameController) { public BottomBar(GameController gameController) {
this.setSpacing(10); this.setSpacing(10);
this.realPartLabel = new Label(); this.realPartLabel = new Label();
this.realPartLabel.getStyleClass().add("top-bottom-padding");
this.imaginaryPartLabel = new Label(); this.imaginaryPartLabel = new Label();
this.imaginaryPartLabel.getStyleClass().add("top-bottom-padding");
this.sliderRealPart = new SliderRealPart(gameController); this.sliderRealPart = new SliderRealPart(gameController);
this.sliderImaginaryPart = new SliderImaginaryPart(gameController); this.sliderImaginaryPart = new SliderImaginaryPart(gameController);
realPartLabel.setMinSize(200, 20); realPartLabel.setMinSize(200, 20);
imaginaryPartLabel.setMinSize(200, 20); imaginaryPartLabel.setMinSize(200, 20);
realPartLabel.setAlignment(Pos.CENTER); this.setAlignment(Pos.CENTER);
imaginaryPartLabel.setAlignment(Pos.CENTER);
this.setAlignment(javafx.geometry.Pos.CENTER);
this.getChildren().addAll(realPartLabel, sliderRealPart, this.getChildren().addAll(realPartLabel, sliderRealPart,
sliderImaginaryPart, imaginaryPartLabel); sliderImaginaryPart, imaginaryPartLabel);
......
...@@ -30,13 +30,13 @@ public class SideBar extends VBox { ...@@ -30,13 +30,13 @@ public class SideBar extends VBox {
resetGame.setOnAction(event -> chaosGameController.resetGame()); resetGame.setOnAction(event -> chaosGameController.resetGame());
this.getChildren().addAll( this.getChildren().addAll(
fractalSelectionBox, colorPicker, numberOfStepsInput, fractalSelectionBox, colorPicker, coordinatesButton,
coordinatesButton, createOwnFractal, saveFractalButton, openFileButton, createOwnFractal, saveFractalButton, openFileButton,
runGame, resetGame); numberOfStepsInput, runGame, resetGame);
this.setAlignment(Pos.CENTER_RIGHT); this.setAlignment(Pos.CENTER_RIGHT);
VBox.setMargin(coordinatesButton, new Insets(50, 0, 0, 0)); VBox.setMargin(coordinatesButton, new Insets(30, 0, 0, 0));
VBox.setMargin(runGame, new Insets(50, 0, 0, 0)); VBox.setMargin(numberOfStepsInput, new Insets(30, 0, 0, 0));
this.getStyleClass().add("side-bar"); this.getStyleClass().add("side-bar");
} }
......
...@@ -11,6 +11,7 @@ public class SliderImaginaryPart extends BaseSlider { ...@@ -11,6 +11,7 @@ public class SliderImaginaryPart extends BaseSlider {
super(gameController); super(gameController);
this.setMin(-1); this.setMin(-1);
this.setMax(1); this.setMax(1);
this.getStyleClass().add("top-bottom-padding");
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
......
...@@ -8,6 +8,7 @@ public class SliderRealPart extends BaseSlider { ...@@ -8,6 +8,7 @@ public class SliderRealPart extends BaseSlider {
super(gameController); super(gameController);
this.setMin(-1); this.setMin(-1);
this.setMax(1); this.setMax(1);
this.getStyleClass().add("top-bottom-padding");
} }
@Override @Override
......
...@@ -18,30 +18,29 @@ public class TopBar extends HBox { ...@@ -18,30 +18,29 @@ public class TopBar extends HBox {
public TopBar(GameController gameController) { public TopBar(GameController gameController) {
super(); super();
this.gameInfo = new Label(); this.gameInfo = new Label();
this.gameInfo.getStyleClass().add("top-bottom-padding");
this.stepsLabel = new Label(); this.stepsLabel = new Label();
this.stepsLabel.getStyleClass().add("top-bottom-padding");
this.coordinatesLabel = new Label(); this.coordinatesLabel = new Label();
this.coordinatesLabel.getStyleClass().add("top-bottom-padding");
Button homeButton = new HomeButton(); Button homeButton = new HomeButton();
homeButton.setOnAction(event -> gameController.homeButtonClicked()); homeButton.setOnAction(event -> gameController.homeButtonClicked());
this.getChildren().addAll(homeButton, gameInfo, coordinatesLabel, stepsLabel); this.getChildren().addAll(homeButton, gameInfo, coordinatesLabel, stepsLabel);
this.setPadding(new javafx.geometry.Insets(10));
this.setSpacing(50);
this.setAlignment(Pos.CENTER_LEFT); this.setAlignment(Pos.CENTER_LEFT);
this.getStyleClass().add("top-bottom-bar"); this.getStyleClass().add("top-bottom-bar");
} }
public void updateTopBar(Transform2D first, int totalSteps, Vector2D min, Vector2D max) { public void updateTotalTopBar(Transform2D first, int totalSteps, Vector2D min, Vector2D max) {
gameInfo.setText("Transformation: " + first.getClass().getSimpleName()); gameInfo.setText("Transformation: " + first.getClass().getSimpleName());
coordinatesLabel.setText("Min-Coordinate: " + min.getX() + ", " + min.getY() + updateTopBar(min, max);
". Max-Coordinate: " + max.getX() + ", " + max.getY());
stepsLabel.setText("Total steps: " + totalSteps); stepsLabel.setText("Total steps: " + totalSteps);
} }
public void updateTopBar(Vector2D min, Vector2D max) { public void updateTopBar(Vector2D min, Vector2D max) {
coordinatesLabel.setText("Min-Coordinate: " + (double) Math.round(min.getX() * 100) / 100 + ", " + (double) Math.round(min.getY() * 100) / 100 + coordinatesLabel.setText("Coordinates: " + (double) Math.round(min.getX() * 100) / 100 + " , " + (double) Math.round(min.getY() * 100) / 100 +
". Max-Coordinate: " + (double) Math.round(max.getX() * 100) / 100 + ", " + (double) Math.round(max.getY() * 100) / 100); " (min), " + (double) Math.round(max.getX() * 100) / 100 + ", " + (double) Math.round(max.getY() * 100) / 100 + " (max)");
} }
public void setTopBarStyle(String text) { public void setTopBarStyle(String text) {
......
...@@ -26,8 +26,12 @@ ...@@ -26,8 +26,12 @@
} }
.text-field { .text-field {
-fx-font: 14 arial; -fx-font: 20 arial;
-fx-border-color: black; -fx-background-color: #252525;
-fx-text-fill: white;
-fx-border-color: #3b3b3b;
-fx-background-radius: 20;
-fx-border-radius: 20;
-fx-border-width: 2; -fx-border-width: 2;
-fx-background-insets: 1; -fx-background-insets: 1;
} }
...@@ -125,6 +129,7 @@ ...@@ -125,6 +129,7 @@
-fx-padding: 20; -fx-padding: 20;
-fx-spacing: 10; -fx-spacing: 10;
} }
.top-bottom-bar .text { .top-bottom-bar .text {
-fx-font: 20 arial; -fx-font: 20 arial;
-fx-fill: #7c7c7c; -fx-fill: #7c7c7c;
...@@ -138,6 +143,11 @@ ...@@ -138,6 +143,11 @@
-fx-background-insets: 1; -fx-background-insets: 1;
} }
.top-bottom-padding{
-fx-padding: 0 10 0 10;
}
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