Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IDATT2003 Mappevurdering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Håvard Johannes Versto Daleng
IDATT2003 Mappevurdering
Commits
c5662332
Commit
c5662332
authored
11 months ago
by
Magnus Eik
Browse files
Options
Downloads
Patches
Plain Diff
Improve GUI formatting and reduced code duplication for GUI elements.
parent
1d2482b7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java
+37
-24
37 additions, 24 deletions
src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java
with
37 additions
and
24 deletions
src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java
+
37
−
24
View file @
c5662332
...
...
@@ -151,6 +151,16 @@ public ChaosGameGui(Stage primaryStage) throws IOException {
this
.
scene
=
new
Scene
(
this
.
borderPane
,
1700
,
1000
);
}
/**
* Creates a TextField of specific size.
*/
private
TextField
createCoordinateTextField
(
String
promptText
)
{
TextField
textField
=
new
TextField
();
textField
.
setPrefHeight
(
5
);
textField
.
setPrefWidth
(
90
);
textField
.
setPromptText
(
promptText
);
return
textField
;
}
/**
* Initialize the main buttons for the GUI.
...
...
@@ -277,6 +287,9 @@ public ChaosGameGui(Stage primaryStage) throws IOException {
this
.
sideMenu
=
new
VBox
();
// Parameters
VBox
parameterBox
=
new
VBox
();
VBox
controlButtonBox
=
new
VBox
();
VBox
radioButtonBox
=
new
VBox
();
VBox
bottomButtonBox
=
new
VBox
();
// Step Count GUI
VBox
stepCountBox
=
new
VBox
();
...
...
@@ -291,14 +304,11 @@ public ChaosGameGui(Stage primaryStage) throws IOException {
// Minimum Coordinates GUI
VBox
minCoordinatesBox
=
new
VBox
();
Label
minCoordinatesLabel
=
new
Label
(
"Min. Coordinates"
);
TextField
minimumCoordinatesTextFieldX
=
new
TextField
();
minimumCoordinatesTextFieldX
.
setPrefHeight
(
5
);
minimumCoordinatesTextFieldX
.
setPrefWidth
(
90
);
minimumCoordinatesTextFieldX
.
setPromptText
(
"x"
);
TextField
minimumCoordinatesTextFieldY
=
new
TextField
();
minimumCoordinatesTextFieldY
.
setPrefHeight
(
5
);
minimumCoordinatesTextFieldY
.
setPrefWidth
(
90
);
minimumCoordinatesTextFieldY
.
setPromptText
(
"y"
);
TextField
minimumCoordinatesTextFieldX
=
createCoordinateTextField
(
"x"
);
TextField
minimumCoordinatesTextFieldY
=
createCoordinateTextField
(
"y"
);
HBox
minCoordsHBox
=
new
HBox
();
minCoordsHBox
.
getChildren
().
addAll
(
minimumCoordinatesTextFieldX
,
minimumCoordinatesTextFieldY
);
Button
changeMinimumCoordinatesButton
=
new
Button
(
"Change Min. Coordinates"
);
...
...
@@ -308,14 +318,8 @@ public ChaosGameGui(Stage primaryStage) throws IOException {
// Maximum Coordinates GUI
VBox
maxCoordinatesBox
=
new
VBox
();
Label
maxCoordinatesLabel
=
new
Label
(
"Max Coordinates"
);
TextField
maximumCoordinatesTextFieldX
=
new
TextField
();
maximumCoordinatesTextFieldX
.
setPrefHeight
(
5
);
maximumCoordinatesTextFieldX
.
setPrefWidth
(
90
);
maximumCoordinatesTextFieldX
.
setPromptText
(
"x"
);
TextField
maximumCoordinatesTextFieldY
=
new
TextField
();
maximumCoordinatesTextFieldY
.
setPrefHeight
(
5
);
maximumCoordinatesTextFieldY
.
setPrefWidth
(
90
);
maximumCoordinatesTextFieldY
.
setPromptText
(
"y"
);
TextField
maximumCoordinatesTextFieldX
=
createCoordinateTextField
(
"x"
);
TextField
maximumCoordinatesTextFieldY
=
createCoordinateTextField
(
"y"
);
HBox
maxCoordsHBox
=
new
HBox
();
maxCoordsHBox
.
getChildren
().
addAll
(
maximumCoordinatesTextFieldX
,
maximumCoordinatesTextFieldY
);
...
...
@@ -340,11 +344,21 @@ public ChaosGameGui(Stage primaryStage) throws IOException {
parameterBox
.
setPadding
(
new
Insets
(
10
));
// Add basic control buttons
sideMenu
.
getChildren
().
addAll
(
startButton
,
stopButton
,
newButton
,
clearButton
);
controlButtonBox
.
getChildren
().
addAll
(
startButton
,
stopButton
,
newButton
,
clearButton
);
controlButtonBox
.
setSpacing
(
5
);
sideMenu
.
getChildren
().
add
(
controlButtonBox
);
// Add spacing
Region
space
=
new
Region
();
space
.
setMinHeight
(
10
);
sideMenu
.
getChildren
().
add
(
space
);
// Add fractal radio buttons
sideMenu
.
getChildren
().
addAll
(
sierpinskiRadioButton
,
barnsleyRadioButton
,
juliaRadioButton
,
improvedBarnsleyButton
);
radioButtonBox
.
getChildren
().
addAll
(
sierpinskiRadioButton
,
barnsleyRadioButton
,
juliaRadioButton
,
improvedBarnsleyButton
);
radioButtonBox
.
setSpacing
(
5
);
sideMenu
.
getChildren
().
add
(
radioButtonBox
);
sideMenu
.
getChildren
().
addAll
(
separator1
,
colorBox
,
separator2
);
//this.initializeColorButtonHandler();
...
...
@@ -352,11 +366,10 @@ public ChaosGameGui(Stage primaryStage) throws IOException {
// Add parameter VBox
sideMenu
.
getChildren
().
add
(
parameterBox
);
// Add file buttons
sideMenu
.
getChildren
().
addAll
(
loadFractalFromFileButton
,
writeFractalToFileButton
);
// Add quit button
sideMenu
.
getChildren
().
add
(
quitButton
);
// Add file buttons and quit button
bottomButtonBox
.
getChildren
().
addAll
(
loadFractalFromFileButton
,
writeFractalToFileButton
,
quitButton
);
bottomButtonBox
.
setSpacing
(
5
);
sideMenu
.
getChildren
().
add
(
bottomButtonBox
);
// Add padding
sideMenu
.
setPadding
(
new
Insets
(
10
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment