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
3127a10d
Commit
3127a10d
authored
11 months ago
by
Håvard Daleng
Browse files
Options
Downloads
Patches
Plain Diff
Rebased
parent
b90e5086
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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
+40
-54
40 additions, 54 deletions
src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java
with
40 additions
and
54 deletions
src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGui.java
+
40
−
54
View file @
3127a10d
...
...
@@ -40,12 +40,16 @@ import java.io.IOException;
public
class
ChaosGameGui
implements
ChaosGameObserver
{
private
int
currentLine
=
0
;
/**
* The primary stage for the GUI.
*/
private
Stage
primaryStage
;
/**
* The aspect ratio of the GUI.
*/
private
double
aspectRatio
;
/**
* The canvas for this GUI.
*/
...
...
@@ -122,13 +126,24 @@ public class ChaosGameGui implements ChaosGameObserver {
*/
private
Button
clearButton
;
/**
* The quit button for the GUI.
*/
private
Button
quitButton
;
/**
* The side menu button for the GUI.
*/
private
Button
sideMenuButton
;
/**
* The load fractal from file and write fractal to file buttons for the GUI.
*/
private
Button
loadFractalFromFileButton
;
/**
* The write fractal to file button for the GUI.
*/
private
Button
writeFractalToFileButton
;
/**
...
...
@@ -172,23 +187,24 @@ public class ChaosGameGui implements ChaosGameObserver {
* @param primaryStage the primary stage for the GUI.
* @throws IOException if the GUI fails to initialize.
*/
public
ChaosGameGui
(
Stage
primaryStage
)
throws
IOException
{
this
.
primaryStage
=
primaryStage
;
this
.
initializeComponents
();
this
.
initializeGameComponents
();
this
.
controller
=
new
GuiButtonController
(
game
,
this
);
// Initialize controller here
primaryStage
.
setTitle
(
"Fractal Chaos Game"
);
primaryStage
.
setScene
(
scene
);
primaryStage
.
setOnShown
(
event
->
this
.
imageView
.
requestFocus
());
primaryStage
.
show
();
// Initialize aspect ratio based on initial dimensions
this
.
aspectRatio
=
(
double
)
width
/
height
;
// Add listeners to handle window size changes
scene
.
widthProperty
().
addListener
((
observable
,
oldValue
,
newValue
)
->
{
resizeCanvas
();
});
public
ChaosGameGui
(
Stage
primaryStage
)
throws
IOException
{
this
.
primaryStage
=
primaryStage
;
this
.
initializeComponents
();
this
.
initializeGameComponents
();
this
.
controller
=
new
GuiButtonController
(
game
,
this
);
// Initialize controller here
primaryStage
.
setTitle
(
"Fractal Chaos Game"
);
primaryStage
.
setScene
(
scene
);
primaryStage
.
setOnShown
(
event
->
this
.
imageView
.
requestFocus
());
primaryStage
.
show
();
// Initialize aspect ratio based on initial dimensions
this
.
aspectRatio
=
(
double
)
width
/
height
;
// Add listeners to handle window size changes
scene
.
widthProperty
().
addListener
((
observable
,
oldValue
,
newValue
)
->
{
resizeCanvas
();
});
scene
.
heightProperty
().
addListener
((
observable
,
oldValue
,
newValue
)
->
{
resizeCanvas
();
...
...
@@ -200,6 +216,8 @@ sideMenu.prefWidthProperty().bind(scene.widthProperty().multiply(0.2)); // 20% o
// Bind the height of the sideMenu to the height of the scene
sideMenu
.
prefHeightProperty
().
bind
(
scene
.
heightProperty
());
}
/**
* Initialize the components of the GUI.
*/
...
...
@@ -226,35 +244,6 @@ sideMenu.prefHeightProperty().bind(scene.heightProperty());
return
textField
;
}
/**
* Initialize the main buttons for the GUI.
*/
// private void initializeMainButtons() {
// this.startButton = new Button("Start");
// startButton.setOnAction(event -> controller.startGame());
// this.stopButton = new Button("Stop");
// stopButton.setOnAction(event -> controller.stopGame());
//
// this.newButton = new Button("New");
//
// newButton.setOnAction(event ->{
// this.canvas.getGraphicsContext2D().clearRect(0, 0, canvas.getWidth(), canvas.getHeight());
// chaosCanvas.clearCanvas();
// });
//
// this.clearButton = new Button("Clear");
//
// clearButton.setOnAction(event -> {
// getImageView().setImage(null);
// setCurrentLine(0);
// });
//
// // Quit button
// this.quitButton = new Button("Quit");
// quitButton.setOnAction(event -> Platform.exit());
//
// }
/**
* Initialize the components related to the chaos game itself.
*/
...
...
@@ -313,8 +302,6 @@ sideMenu.prefHeightProperty().bind(scene.heightProperty());
this
.
improvedBarnsleyButton
=
new
RadioButton
(
"Improved Barnsley"
);
improvedBarnsleyButton
.
setToggleGroup
(
group
);
// Load fractal file button and tooltip
this
.
loadFractalFromFileButton
=
new
Button
(
"Load Fractal"
);
Tooltip
loadFractalFromFileButtonTooltip
=
new
Tooltip
(
"Load a text file describing a new fractal chaos game"
);
...
...
@@ -354,7 +341,6 @@ sideMenu.prefHeightProperty().bind(scene.heightProperty());
Tooltip
clearButtonTooltip
=
new
Tooltip
(
"Clear the current fracal"
);
Tooltip
quitButtonTooltip
=
new
Tooltip
(
"Quit the application"
);
// Attach Tooltips to Buttons
Tooltip
.
install
(
startButton
,
startButtonTooltip
);
Tooltip
.
install
(
stopButton
,
stopButtonTooltip
);
...
...
@@ -362,6 +348,7 @@ sideMenu.prefHeightProperty().bind(scene.heightProperty());
Tooltip
.
install
(
quitButton
,
quitButtonTooltip
);
this
.
sideMenu
=
new
VBox
();
//this.sideMenu.setAlignment(Pos.CENTER);
// Parameters
VBox
parameterBox
=
new
VBox
();
VBox
controlButtonBox
=
new
VBox
();
...
...
@@ -466,9 +453,9 @@ sideMenu.prefHeightProperty().bind(scene.heightProperty());
parameterBox
.
setPadding
(
new
Insets
(
10
));
// Add basic control buttons
controlButtonBox
.
getChildren
().
addAll
(
canvasLabel
,
startButton
,
stopButton
,
clearButton
);
controlButtonBox
.
setAlignment
(
Pos
.
CENTER
);
controlButtonBox
.
getChildren
().
addAll
(
canvasLabel
,
startButton
,
stopButton
,
clearButton
);
controlButtonBox
.
setSpacing
(
5
);
sideMenu
.
getChildren
().
add
(
controlButtonBox
);
...
...
@@ -580,7 +567,6 @@ sideMenu.prefHeightProperty().bind(scene.heightProperty());
return
this
.
chaosCanvas
;
}
public
int
getWidth
(){
return
this
.
width
;
}
...
...
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