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
8bc928ca
Commit
8bc928ca
authored
11 months ago
by
Magnus Eik
Browse files
Options
Downloads
Patches
Plain Diff
Add fractal choice control to radio buttons and a quit button
parent
e48ef630
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/ChaosGameGUIView.java
+54
-5
54 additions, 5 deletions
...n/java/edu/ntnu/stud/chaosgame/view/ChaosGameGUIView.java
with
54 additions
and
5 deletions
src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGUIView.java
+
54
−
5
View file @
8bc928ca
...
@@ -7,6 +7,7 @@ import edu.ntnu.stud.chaosgame.model.generators.ChaosGameDescriptionFactory;
...
@@ -7,6 +7,7 @@ import edu.ntnu.stud.chaosgame.model.generators.ChaosGameDescriptionFactory;
import
javafx.animation.KeyFrame
;
import
javafx.animation.KeyFrame
;
import
javafx.animation.Timeline
;
import
javafx.animation.Timeline
;
import
javafx.application.Platform
;
import
javafx.scene.Scene
;
import
javafx.scene.Scene
;
import
javafx.scene.control.ToggleGroup
;
import
javafx.scene.control.ToggleGroup
;
import
javafx.scene.control.RadioButton
;
import
javafx.scene.control.RadioButton
;
...
@@ -22,6 +23,7 @@ import javafx.scene.control.Button;
...
@@ -22,6 +23,7 @@ import javafx.scene.control.Button;
import
javafx.util.Duration
;
import
javafx.util.Duration
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.concurrent.atomic.AtomicReference
;
public
class
ChaosGameGUIView
{
public
class
ChaosGameGUIView
{
private
int
currentLine
=
0
;
private
int
currentLine
=
0
;
...
@@ -43,7 +45,7 @@ public class ChaosGameGUIView {
...
@@ -43,7 +45,7 @@ public class ChaosGameGUIView {
imageView
=
new
ImageView
();
imageView
=
new
ImageView
();
width
=
1
1
00
;
width
=
1
0
00
;
height
=
1000
;
height
=
1000
;
WritableImage
writableImage
=
new
WritableImage
(
width
,
height
);
WritableImage
writableImage
=
new
WritableImage
(
width
,
height
);
...
@@ -57,9 +59,9 @@ public class ChaosGameGUIView {
...
@@ -57,9 +59,9 @@ public class ChaosGameGUIView {
//TEMPORARY CODE to test Chaos Games in GUI
//TEMPORARY CODE to test Chaos Games in GUI
ChaosGameDescriptionFactory
factory
=
new
ChaosGameDescriptionFactory
();
ChaosGameDescriptionFactory
factory
=
new
ChaosGameDescriptionFactory
();
ChaosGameDescription
description
=
factory
.
getDescriptions
().
get
(
1
);
AtomicReference
<
ChaosGameDescription
>
description
=
new
AtomicReference
<>(
factory
.
getDescriptions
().
get
(
0
)
);
ChaosCanvas
canvas
=
new
ChaosCanvas
(
1000
,
1000
,
description
.
getMinCoords
(),
description
.
getMaxCoords
());
ChaosCanvas
canvas
=
new
ChaosCanvas
(
1000
,
1000
,
description
.
get
().
getMinCoords
(),
description
.
get
().
getMaxCoords
());
game
=
new
ChaosGame
(
description
,
canvas
);
game
=
new
ChaosGame
(
description
.
get
()
,
canvas
);
Button
startButton
=
new
Button
(
"Start"
);
Button
startButton
=
new
Button
(
"Start"
);
startButton
.
setOnAction
(
event
->
timeline
.
play
());
startButton
.
setOnAction
(
event
->
timeline
.
play
());
...
@@ -94,8 +96,55 @@ public class ChaosGameGUIView {
...
@@ -94,8 +96,55 @@ public class ChaosGameGUIView {
RadioButton
juliaRadioButton
=
new
RadioButton
(
"Julia"
);
RadioButton
juliaRadioButton
=
new
RadioButton
(
"Julia"
);
juliaRadioButton
.
setToggleGroup
(
group
);
juliaRadioButton
.
setToggleGroup
(
group
);
AtomicReference
<
ChaosCanvas
>
canvasRef
=
new
AtomicReference
<>(
canvas
);
sierpinskiRadioButton
.
setOnAction
(
event
->
{
timeline
.
stop
();
canvasRef
.
get
().
clearCanvas
();
WritableImage
newWritableImage
=
new
WritableImage
(
width
,
height
);
setPixelWriter
(
newWritableImage
.
getPixelWriter
());
setImageViewFromImage
(
newWritableImage
);
canvas
.
clearCanvas
();
description
.
set
(
factory
.
getDescriptions
().
get
(
0
));
// Assuming the Sierpinski description is at index 0
canvasRef
.
set
(
new
ChaosCanvas
(
1000
,
1000
,
description
.
get
().
getMinCoords
(),
description
.
get
().
getMaxCoords
()));
game
=
new
ChaosGame
(
description
.
get
(),
canvasRef
.
get
());
});
barnsleyRadioButton
.
setOnAction
(
event
->
{
timeline
.
stop
();
canvasRef
.
get
().
clearCanvas
();
WritableImage
newWritableImage
=
new
WritableImage
(
width
,
height
);
setPixelWriter
(
newWritableImage
.
getPixelWriter
());
setImageViewFromImage
(
newWritableImage
);
canvas
.
clearCanvas
();
description
.
set
(
factory
.
getDescriptions
().
get
(
1
));
// Assuming the Sierpinski description is at index 0
canvasRef
.
set
(
new
ChaosCanvas
(
1000
,
1000
,
description
.
get
().
getMinCoords
(),
description
.
get
().
getMaxCoords
()));
game
=
new
ChaosGame
(
description
.
get
(),
canvasRef
.
get
());
});
juliaRadioButton
.
setOnAction
(
event
->
{
timeline
.
stop
();
canvasRef
.
get
().
clearCanvas
();
WritableImage
newWritableImage
=
new
WritableImage
(
width
,
height
);
setPixelWriter
(
newWritableImage
.
getPixelWriter
());
setImageViewFromImage
(
newWritableImage
);
canvas
.
clearCanvas
();
description
.
set
(
factory
.
getDescriptions
().
get
(
2
));
// Assuming the Sierpinski description is at index 0
canvasRef
.
set
(
new
ChaosCanvas
(
1000
,
1000
,
description
.
get
().
getMinCoords
(),
description
.
get
().
getMaxCoords
()));
game
=
new
ChaosGame
(
description
.
get
(),
canvasRef
.
get
());
});
// Quit button
Button
quitButton
=
new
Button
(
"Quit"
);
quitButton
.
setOnAction
(
event
->
Platform
.
exit
());
// Add basic control buttons
sideMenu
.
getChildren
().
addAll
(
startButton
,
stopButton
,
newButton
,
clearButton
);
sideMenu
.
getChildren
().
addAll
(
startButton
,
stopButton
,
newButton
,
clearButton
);
// Add fractal radio buttons
sideMenu
.
getChildren
().
addAll
(
sierpinskiRadioButton
,
barnsleyRadioButton
,
juliaRadioButton
);
sideMenu
.
getChildren
().
addAll
(
sierpinskiRadioButton
,
barnsleyRadioButton
,
juliaRadioButton
);
// Add quit button
sideMenu
.
getChildren
().
add
(
quitButton
);
BorderPane
borderPane
=
new
BorderPane
();
BorderPane
borderPane
=
new
BorderPane
();
...
@@ -117,7 +166,7 @@ public class ChaosGameGUIView {
...
@@ -117,7 +166,7 @@ public class ChaosGameGUIView {
ChaosCanvas
canvas
=
game
.
getCanvas
();
ChaosCanvas
canvas
=
game
.
getCanvas
();
game
.
runSteps
(
10
);
game
.
runSteps
(
10
0000
);
// Test implementation for drawing fractals
// Test implementation for drawing fractals
int
[][]
betaArray
=
canvas
.
getCanvasArray
();
int
[][]
betaArray
=
canvas
.
getCanvasArray
();
...
...
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