Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IDATT2003 Mappevurdering
Manage
Activity
Members
Labels
Plan
Issues
13
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
80562791
Commit
80562791
authored
10 months ago
by
Magnus Eik
Browse files
Options
Downloads
Patches
Plain Diff
Add image size field to ChaosGameGuiView
parent
1671807b
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/ChaosGameGuiView.java
+25
-18
25 additions, 18 deletions
...n/java/edu/ntnu/stud/chaosgame/view/ChaosGameGuiView.java
with
25 additions
and
18 deletions
src/main/java/edu/ntnu/stud/chaosgame/view/ChaosGameGuiView.java
+
25
−
18
View file @
80562791
...
...
@@ -54,12 +54,12 @@ public class ChaosGameGuiView implements ChaosGameObserver {
private
PixelWriter
pixelWriter
;
/**
* The ImageView for the GUI.
.
* The ImageView for the GUI.
*/
private
ChaosGameImageView
imageView
;
/**
* The Scene for the GUI.
.
* The Scene for the GUI.
*/
private
Scene
scene
;
...
...
@@ -112,6 +112,9 @@ public class ChaosGameGuiView implements ChaosGameObserver {
private
RadioButton
juliaRadioButton
;
private
RadioButton
improvedBarnsleyButton
;
private
final
int
resolutionHeight
=
1000
;
private
final
int
resolutionWidth
=
1000
;
public
ChaosGameGuiView
(
Stage
primaryStage
)
throws
IOException
{
...
...
@@ -132,6 +135,8 @@ public class ChaosGameGuiView implements ChaosGameObserver {
// Timeline
this
.
timeline
=
new
Timeline
(
new
KeyFrame
(
Duration
.
seconds
(
0.05
),
event
->
this
.
drawChaosGame
()));
this
.
initializeImageView
();
this
.
timeline
.
setCycleCount
(
Timeline
.
INDEFINITE
);
// Side menu
...
...
@@ -185,7 +190,7 @@ public class ChaosGameGuiView implements ChaosGameObserver {
this
.
descriptionRef
=
new
AtomicReference
<>(
factory
.
getDescriptions
().
get
(
0
));
this
.
description
=
descriptionRef
.
get
();
this
.
canvas
=
new
ChaosCanvas
(
1000
,
1000
,
descriptionRef
.
get
().
getMinCoords
(),
descriptionRef
.
get
().
getMaxCoords
());
this
.
canvas
=
new
ChaosCanvas
(
resolutionWidth
,
resolutionHeight
,
descriptionRef
.
get
().
getMinCoords
(),
descriptionRef
.
get
().
getMaxCoords
());
game
=
new
ChaosGame
(
this
.
description
,
canvas
);
}
...
...
@@ -195,11 +200,13 @@ public class ChaosGameGuiView implements ChaosGameObserver {
private
void
initializeImageView
()
{
// Image view
this
.
imageView
=
new
ChaosGameImageView
(
this
);
width
=
1000
;
height
=
1000
;
width
=
resolutionWidth
;
height
=
resolutionHeight
;
WritableImage
writableImage
=
new
WritableImage
(
width
,
height
);
pixelWriter
=
writableImage
.
getPixelWriter
();
this
.
imageView
.
setImage
(
writableImage
);
this
.
imageView
.
setFitHeight
(
1000
);
this
.
imageView
.
setFitWidth
(
1000
);
this
.
fillImageView
();
/*imageView.setOnScroll(event -> {
...
...
@@ -264,54 +271,54 @@ public class ChaosGameGuiView implements ChaosGameObserver {
// Set action for Sierpinski radio button.
sierpinskiRadioButton
.
setOnAction
(
event
->
{
timeline
.
stop
();
canvasRef
.
get
().
clearCanvas
();
//
canvasRef.get().clearCanvas();
WritableImage
newWritableImage
=
new
WritableImage
(
width
,
height
);
setPixelWriter
(
newWritableImage
.
getPixelWriter
());
setImageViewFromImage
(
newWritableImage
);
this
.
fillImageView
();
canvas
.
clearCanvas
();
//
canvas.clearCanvas();
this
.
descriptionRef
.
set
(
factory
.
getDescriptions
().
get
(
0
));
// Assuming the Sierpinski description is at index 0
canvasRef
.
set
(
new
ChaosCanvas
(
1000
,
1000
,
this
.
descriptionRef
.
get
().
getMinCoords
(),
this
.
descriptionRef
.
get
().
getMaxCoords
()));
canvasRef
.
set
(
new
ChaosCanvas
(
resolutionWidth
,
resolutionHeight
,
this
.
descriptionRef
.
get
().
getMinCoords
(),
this
.
descriptionRef
.
get
().
getMaxCoords
()));
game
=
new
ChaosGame
(
this
.
descriptionRef
.
get
(),
canvasRef
.
get
());
});
// Set action for Barnsley radio button.
barnsleyRadioButton
.
setOnAction
(
event
->
{
timeline
.
stop
();
canvasRef
.
get
().
clearCanvas
();
//
canvasRef.get().clearCanvas();
WritableImage
newWritableImage
=
new
WritableImage
(
width
,
height
);
setPixelWriter
(
newWritableImage
.
getPixelWriter
());
setImageViewFromImage
(
newWritableImage
);
this
.
fillImageView
();
canvas
.
clearCanvas
();
//
canvas.clearCanvas();
this
.
descriptionRef
.
set
(
factory
.
getDescriptions
().
get
(
1
));
// Assuming the Sierpinski description is at index 0
canvasRef
.
set
(
new
ChaosCanvas
(
1000
,
1000
,
this
.
descriptionRef
.
get
().
getMinCoords
(),
this
.
descriptionRef
.
get
().
getMaxCoords
()));
canvasRef
.
set
(
new
ChaosCanvas
(
resolutionWidth
,
resolutionHeight
,
this
.
descriptionRef
.
get
().
getMinCoords
(),
this
.
descriptionRef
.
get
().
getMaxCoords
()));
game
=
new
ChaosGame
(
this
.
descriptionRef
.
get
(),
canvasRef
.
get
());
});
// Set action for Julia radio button.
juliaRadioButton
.
setOnAction
(
event
->
{
timeline
.
stop
();
canvasRef
.
get
().
clearCanvas
();
//
canvasRef.get().clearCanvas();
WritableImage
newWritableImage
=
new
WritableImage
(
width
,
height
);
setPixelWriter
(
newWritableImage
.
getPixelWriter
());
setImageViewFromImage
(
newWritableImage
);
this
.
fillImageView
();
canvas
.
clearCanvas
();
//
canvas.clearCanvas();
this
.
descriptionRef
.
set
(
factory
.
getDescriptions
().
get
(
2
));
// Assuming the Sierpinski description is at index 0
canvasRef
.
set
(
new
ChaosCanvas
(
1000
,
1000
,
this
.
descriptionRef
.
get
().
getMinCoords
(),
this
.
descriptionRef
.
get
().
getMaxCoords
()));
canvasRef
.
set
(
new
ChaosCanvas
(
resolutionWidth
,
resolutionHeight
,
this
.
descriptionRef
.
get
().
getMinCoords
(),
this
.
descriptionRef
.
get
().
getMaxCoords
()));
game
=
new
ChaosGame
(
this
.
descriptionRef
.
get
(),
canvasRef
.
get
());
});
improvedBarnsleyButton
.
setOnAction
(
event
->
{
timeline
.
stop
();
canvasRef
.
get
().
clearCanvas
();
//
canvasRef.get().clearCanvas();
WritableImage
newWritableImage
=
new
WritableImage
(
width
,
height
);
setPixelWriter
(
newWritableImage
.
getPixelWriter
());
setImageViewFromImage
(
newWritableImage
);
this
.
fillImageView
();
canvas
.
clearCanvas
();
//
canvas.clearCanvas();
// Test
this
.
descriptionRef
.
set
(
factory
.
getDescriptions
().
get
(
3
));
// Assuming the Sierpinski description is at index 0
...
...
@@ -327,7 +334,7 @@ public class ChaosGameGuiView implements ChaosGameObserver {
}
canvasRef
.
set
(
new
ChaosCanvas
(
1000
,
1000
,
this
.
descriptionRef
.
get
().
getMinCoords
(),
this
.
descriptionRef
.
get
().
getMaxCoords
()));
canvasRef
.
set
(
new
ChaosCanvas
(
resolutionWidth
,
resolutionHeight
,
this
.
descriptionRef
.
get
().
getMinCoords
(),
this
.
descriptionRef
.
get
().
getMaxCoords
()));
game
=
new
ChaosGame
(
this
.
descriptionRef
.
get
(),
canvasRef
.
get
());
});
...
...
@@ -398,7 +405,7 @@ public class ChaosGameGuiView implements ChaosGameObserver {
ChaosCanvas
canvas
=
game
.
getCanvas
();
game
.
runSteps
(
100000
0
);
game
.
runSteps
(
100000
);
// 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