commit 1459ec6167e7e0a3eb608dfbb25360131c083c37
parent 22ebaf0493e023307c139afacf39f49b3034569c
Author: A Koens <[email protected]>
Date: Wed, 30 Nov 2022 23:55:22 +0100
StageHandle docs
Diffstat:
1 file changed, 32 insertions(+), 0 deletions(-)
diff --git a/src/main/java/nl/isygameclient/util/StageHandler.java b/src/main/java/nl/isygameclient/util/StageHandler.java
@@ -14,6 +14,10 @@ import java.util.Map;
import static nl.isygameclient.models.Settings.StageSettings.configureStageFromSettings;
import static nl.isygameclient.models.Settings.StageSettings.createSettingsFromStage;
+/**
+ * This class is a singleton that stores and manages all the active stages in the application.
+ * @author A F Koens.
+ */
public class StageHandler {
private static StageHandler instance;
private final Map<String, Stage> stages = new HashMap<>();
@@ -21,6 +25,10 @@ public class StageHandler {
private StageHandler() {
}
+ /**
+ * This function is for accessing singleton instance of this class.
+ * @return instance op StageHandler.
+ */
public static StageHandler get() {
if (instance == null) {
instance = new StageHandler();
@@ -28,6 +36,11 @@ public class StageHandler {
return instance;
}
+ /**
+ * This function is for accessing a stage stored inside this class.
+ * @param stageName the key for map of stages.
+ * @return a stage object.
+ */
public Stage getStage(String stageName) {
Stage stage = stages.get(stageName);
if (stage == null) stage = new Stage();
@@ -35,10 +48,18 @@ public class StageHandler {
return stage;
}
+ /**
+ * This function is for iconifying also known as minifying a stage window.
+ * @param stageName the key for map of stages.
+ */
public void iconifyStage(String stageName) {
stages.get(stageName).setIconified(true);
}
+ /**
+ * This function is for bringing a stage into view and focussing on it.
+ * @param stageName the key for map of stages.
+ */
public void focusStage(String stageName) {
Stage stage = stages.get(stageName);
stage.setIconified(false);
@@ -46,6 +67,11 @@ public class StageHandler {
stage.requestFocus();
}
+ /**
+ * This function changes the scene of a given stage.
+ * @param stageName the key for map of stages.
+ * @param viewSource the source of the nieuw view for the scene.
+ */
public void changeSceneOfStage(String stageName, String viewSource) {
Stage stage = getStage(stageName);
try {
@@ -57,6 +83,9 @@ public class StageHandler {
}
}
+ /**
+ * This function loads all the stages stored in the settings file into the singleton.
+ */
public void loadStages() {
Settings settings = SettingsFileHandler.load();
for (Map.Entry<String, StageSettings> entry : settings.stages.entrySet()) {
@@ -64,6 +93,9 @@ public class StageHandler {
}
}
+ /**
+ * This function saves all the stages from inside the singleton into the settings file.
+ */
public void saveStages() {
Settings settings = SettingsFileHandler.load();
for (Map.Entry<String, Stage> entry : stages.entrySet()) {