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 {
new PageController(mainPane, chaosGameController, exploreGameController);
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());
primaryStage.setMinWidth(800);
primaryStage.setMinHeight(600);
primaryStage.setMinWidth(1000);
primaryStage.setMinHeight(650);
primaryStage.setScene(scene);
primaryStage.setTitle("Chaos Game Canvas");
......
......@@ -27,15 +27,14 @@ public class ChaosPage extends GamePage {
this.bottomBar.getStyleClass().add("chaos-text");
SideBar sideBar = new SideBar(chaosGameController);
this.setCenter(gc.getCanvas());
this.setTop(topBar);
this.setRight(sideBar);
this.setBottom(bottomBar);
this.setLeft(gc.getCanvas());
}
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);
}
......
......@@ -32,16 +32,15 @@ public class BottomBar extends HBox {
public BottomBar(GameController gameController) {
this.setSpacing(10);
this.realPartLabel = new Label();
this.realPartLabel.getStyleClass().add("top-bottom-padding");
this.imaginaryPartLabel = new Label();
this.imaginaryPartLabel.getStyleClass().add("top-bottom-padding");
this.sliderRealPart = new SliderRealPart(gameController);
this.sliderImaginaryPart = new SliderImaginaryPart(gameController);
realPartLabel.setMinSize(200, 20);
imaginaryPartLabel.setMinSize(200, 20);
realPartLabel.setAlignment(Pos.CENTER);
imaginaryPartLabel.setAlignment(Pos.CENTER);
this.setAlignment(javafx.geometry.Pos.CENTER);
this.setAlignment(Pos.CENTER);
this.getChildren().addAll(realPartLabel, sliderRealPart,
sliderImaginaryPart, imaginaryPartLabel);
......
......@@ -30,13 +30,13 @@ public class SideBar extends VBox {
resetGame.setOnAction(event -> chaosGameController.resetGame());
this.getChildren().addAll(
fractalSelectionBox, colorPicker, numberOfStepsInput,
coordinatesButton, createOwnFractal, saveFractalButton, openFileButton,
runGame, resetGame);
fractalSelectionBox, colorPicker, coordinatesButton,
createOwnFractal, saveFractalButton, openFileButton,
numberOfStepsInput, runGame, resetGame);
this.setAlignment(Pos.CENTER_RIGHT);
VBox.setMargin(coordinatesButton, new Insets(50, 0, 0, 0));
VBox.setMargin(runGame, new Insets(50, 0, 0, 0));
VBox.setMargin(coordinatesButton, new Insets(30, 0, 0, 0));
VBox.setMargin(numberOfStepsInput, new Insets(30, 0, 0, 0));
this.getStyleClass().add("side-bar");
}
......
......@@ -11,6 +11,7 @@ public class SliderImaginaryPart extends BaseSlider {
super(gameController);
this.setMin(-1);
this.setMax(1);
this.getStyleClass().add("top-bottom-padding");
}
/**
* {@inheritDoc}
......
......@@ -8,6 +8,7 @@ public class SliderRealPart extends BaseSlider {
super(gameController);
this.setMin(-1);
this.setMax(1);
this.getStyleClass().add("top-bottom-padding");
}
@Override
......
......@@ -18,30 +18,29 @@ public class TopBar extends HBox {
public TopBar(GameController gameController) {
super();
this.gameInfo = new Label();
this.gameInfo.getStyleClass().add("top-bottom-padding");
this.stepsLabel = new Label();
this.stepsLabel.getStyleClass().add("top-bottom-padding");
this.coordinatesLabel = new Label();
this.coordinatesLabel.getStyleClass().add("top-bottom-padding");
Button homeButton = new HomeButton();
homeButton.setOnAction(event -> gameController.homeButtonClicked());
this.getChildren().addAll(homeButton, gameInfo, coordinatesLabel, stepsLabel);
this.setPadding(new javafx.geometry.Insets(10));
this.setSpacing(50);
this.setAlignment(Pos.CENTER_LEFT);
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());
coordinatesLabel.setText("Min-Coordinate: " + min.getX() + ", " + min.getY() +
". Max-Coordinate: " + max.getX() + ", " + max.getY());
updateTopBar(min, max);
stepsLabel.setText("Total steps: " + totalSteps);
}
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 +
". Max-Coordinate: " + (double) Math.round(max.getX() * 100) / 100 + ", " + (double) Math.round(max.getY() * 100) / 100);
coordinatesLabel.setText("Coordinates: " + (double) Math.round(min.getX() * 100) / 100 + " , " + (double) Math.round(min.getY() * 100) / 100 +
" (min), " + (double) Math.round(max.getX() * 100) / 100 + ", " + (double) Math.round(max.getY() * 100) / 100 + " (max)");
}
public void setTopBarStyle(String text) {
......
......@@ -26,8 +26,12 @@
}
.text-field {
-fx-font: 14 arial;
-fx-border-color: black;
-fx-font: 20 arial;
-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-background-insets: 1;
}
......@@ -125,6 +129,7 @@
-fx-padding: 20;
-fx-spacing: 10;
}
.top-bottom-bar .text {
-fx-font: 20 arial;
-fx-fill: #7c7c7c;
......@@ -138,6 +143,11 @@
-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