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
e48ef630
Commit
e48ef630
authored
11 months ago
by
Magnus Eik
Browse files
Options
Downloads
Patches
Plain Diff
Add dummy radio buttons for fractal to ChaosGameGUIView.
parent
534eb91f
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
+28
-7
28 additions, 7 deletions
...n/java/edu/ntnu/stud/chaosgame/view/ChaosGameGUIView.java
with
28 additions
and
7 deletions
src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGUIView.java
+
28
−
7
View file @
e48ef630
...
...
@@ -8,6 +8,8 @@ import edu.ntnu.stud.chaosgame.model.generators.ChaosGameDescriptionFactory;
import
javafx.animation.KeyFrame
;
import
javafx.animation.Timeline
;
import
javafx.scene.Scene
;
import
javafx.scene.control.ToggleGroup
;
import
javafx.scene.control.RadioButton
;
import
javafx.scene.image.Image
;
import
javafx.scene.image.ImageView
;
import
javafx.scene.image.PixelWriter
;
...
...
@@ -34,6 +36,7 @@ public class ChaosGameGUIView {
private
final
Timeline
timeline
;
public
ChaosGameGUIView
(
Stage
primaryStage
)
throws
IOException
{
this
.
timeline
=
new
Timeline
(
new
KeyFrame
(
Duration
.
seconds
(
0.05
),
event
->
this
.
drawChaosGame
()));
...
...
@@ -50,6 +53,14 @@ public class ChaosGameGUIView {
VBox
sideMenu
=
new
VBox
();
//TEMPORARY CODE to test Chaos Games in GUI
ChaosGameDescriptionFactory
factory
=
new
ChaosGameDescriptionFactory
();
ChaosGameDescription
description
=
factory
.
getDescriptions
().
get
(
1
);
ChaosCanvas
canvas
=
new
ChaosCanvas
(
1000
,
1000
,
description
.
getMinCoords
(),
description
.
getMaxCoords
());
game
=
new
ChaosGame
(
description
,
canvas
);
Button
startButton
=
new
Button
(
"Start"
);
startButton
.
setOnAction
(
event
->
timeline
.
play
());
Button
stopButton
=
new
Button
(
"Stop"
);
...
...
@@ -62,6 +73,7 @@ public class ChaosGameGUIView {
WritableImage
newWritableImage
=
new
WritableImage
(
width
,
height
);
setPixelWriter
(
newWritableImage
.
getPixelWriter
());
setImageViewFromImage
(
newWritableImage
);
canvas
.
clearCanvas
();
});
Button
clearButton
=
new
Button
(
"Clear"
);
...
...
@@ -70,8 +82,21 @@ public class ChaosGameGUIView {
getImageView
().
setImage
(
null
);
setCurrentLine
(
0
);
});
// Radio buttons for choosing fractal type
ToggleGroup
group
=
new
ToggleGroup
();
RadioButton
sierpinskiRadioButton
=
new
RadioButton
(
"Sierpinski"
);
sierpinskiRadioButton
.
setToggleGroup
(
group
);
sierpinskiRadioButton
.
setSelected
(
true
);
RadioButton
barnsleyRadioButton
=
new
RadioButton
(
"Barnsley"
);
barnsleyRadioButton
.
setToggleGroup
(
group
);
RadioButton
juliaRadioButton
=
new
RadioButton
(
"Julia"
);
juliaRadioButton
.
setToggleGroup
(
group
);
sideMenu
.
getChildren
().
addAll
(
startButton
,
stopButton
,
newButton
,
clearButton
);
sideMenu
.
getChildren
().
addAll
(
sierpinskiRadioButton
,
barnsleyRadioButton
,
juliaRadioButton
);
BorderPane
borderPane
=
new
BorderPane
();
borderPane
.
setCenter
(
imageView
);
...
...
@@ -83,20 +108,16 @@ public class ChaosGameGUIView {
primaryStage
.
setScene
(
scene
);
primaryStage
.
show
();
//TEMPORARY CODE to test Chaos Games in GUI
ChaosGameDescriptionFactory
factory
=
new
ChaosGameDescriptionFactory
();
ChaosGameDescription
description
=
factory
.
getDescriptions
().
get
(
0
);
ChaosCanvas
canvas
=
new
ChaosCanvas
(
1000
,
1000
,
description
.
getMinCoords
(),
description
.
getMaxCoords
());
game
=
new
ChaosGame
(
description
,
canvas
);
}
public
void
drawChaosGame
(){
ChaosCanvas
canvas
=
game
.
getCanvas
();
game
.
runSteps
(
100000
);
game
.
runSteps
(
10
);
// Test implementation for drawing fractals
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