Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mappe - programmering 2
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
Sverre Grønhaug Halvorsen
Mappe - programmering 2
Commits
07ec3788
Commit
07ec3788
authored
1 year ago
by
Sverre Grønhaug Halvorsen
Browse files
Options
Downloads
Patches
Plain Diff
Feat: Add method getAllCustomTransforms that retrieves custom transforms stored in file
parent
da81f7ee
No related branches found
No related tags found
2 merge requests
!41
final delivery
,
!35
Resolve "Redesign GUI"
Pipeline
#288314
passed
1 year ago
Stage: build
Stage: test
Stage: package
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/edu/ntnu/idatt2003/controller/MainPageController.java
+33
-1
33 additions, 1 deletion
...ava/edu/ntnu/idatt2003/controller/MainPageController.java
with
33 additions
and
1 deletion
src/main/java/edu/ntnu/idatt2003/controller/MainPageController.java
+
33
−
1
View file @
07ec3788
...
...
@@ -20,6 +20,7 @@ import java.io.ObjectInputStream;
import
java.io.ObjectOutputStream
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.StandardCopyOption
;
import
java.util.ArrayList
;
import
java.util.InputMismatchException
;
...
...
@@ -29,6 +30,7 @@ import java.util.logging.Level;
import
java.util.logging.Logger
;
import
java.util.logging.SimpleFormatter
;
import
java.util.stream.DoubleStream
;
import
java.util.stream.Stream
;
/**
* The controller class for the main page of the ChaosGame application.
...
...
@@ -67,8 +69,8 @@ public class MainPageController {
this
.
game
=
loadGameState
();
this
.
view
=
new
MainPageView
(
this
);
this
.
game
.
registerObserver
(
view
);
this
.
customTransformations
=
getAllCustomTransforms
();
this
.
view
.
render
();
this
.
customTransformations
=
new
ArrayList
<>();
Runtime
.
getRuntime
().
addShutdownHook
(
new
Thread
(
this
::
saveGameState
));
LOGGER
.
log
(
Level
.
INFO
,
"MainPageController initialized successfully."
);
}
...
...
@@ -389,6 +391,36 @@ public class MainPageController {
}
/**
* Retrieves a list of all custom transformation files in the transformations directory
* and updates the customTransformations list.*
*
* @return the updated list of custom transformation file names.
*/
public
List
<
String
>
getAllCustomTransforms
()
{
List
<
String
>
transformations
=
new
ArrayList
<>();
Path
transformationsPath
=
Paths
.
get
(
TRANSFORMATIONS_PATH
);
if
(
Files
.
exists
(
transformationsPath
)
&&
Files
.
isDirectory
(
transformationsPath
))
{
try
(
Stream
<
Path
>
paths
=
Files
.
list
(
transformationsPath
))
{
transformations
=
paths
.
filter
(
Files:
:
isRegularFile
)
.
map
(
Path:
:
getFileName
)
.
map
(
Path:
:
toString
)
.
map
(
name
->
name
.
replace
(
".txt"
,
""
))
.
toList
();
LOGGER
.
log
(
Level
.
INFO
,
"All custom transformations retrieved successfully."
);
}
catch
(
IOException
e
)
{
LOGGER
.
log
(
Level
.
WARNING
,
"Error retrieving custom transformation files."
,
e
);
}
}
else
{
LOGGER
.
log
(
Level
.
WARNING
,
"Transformations directory does not exist or is not a "
+
"directory."
);
}
return
transformations
;
}
/**
* Retrieves the list of custom transformation names.
*
...
...
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