sceneEnum has been refactored to sceneType. Issue #15
This commit is contained in:
parent
4f33ec150e
commit
76fce85de7
3 changed files with 15 additions and 16 deletions
|
@ -14,7 +14,7 @@ import java.net.URL;
|
||||||
*
|
*
|
||||||
* @author Luke Wybar (LAW39)
|
* @author Luke Wybar (LAW39)
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
* @see SceneEnum
|
* @see SceneType
|
||||||
*/
|
*/
|
||||||
public class ScreenSwitch extends SharedCodeController {
|
public class ScreenSwitch extends SharedCodeController {
|
||||||
private static Scene scene;
|
private static Scene scene;
|
||||||
|
@ -28,7 +28,7 @@ public class ScreenSwitch extends SharedCodeController {
|
||||||
* @param stage This a JavaFX stage setup by application, this will be ready to have a scene assigned.
|
* @param stage This a JavaFX stage setup by application, this will be ready to have a scene assigned.
|
||||||
*/
|
*/
|
||||||
public ScreenSwitch(Stage stage){
|
public ScreenSwitch(Stage stage){
|
||||||
scene = new Scene(fxmlLoader(SceneEnum.dictionaryScene));
|
scene = new Scene(fxmlLoader(SceneType.dictionaryScene));
|
||||||
stage.setMinHeight(680);
|
stage.setMinHeight(680);
|
||||||
stage.setHeight(680);
|
stage.setHeight(680);
|
||||||
stage.setMinWidth(1100);
|
stage.setMinWidth(1100);
|
||||||
|
@ -70,10 +70,10 @@ public class ScreenSwitch extends SharedCodeController {
|
||||||
/**
|
/**
|
||||||
* Method that is responsible for the switching between
|
* Method that is responsible for the switching between
|
||||||
* JavaFX, with it taking the new scene’s name as an enum as a parameter.
|
* JavaFX, with it taking the new scene’s name as an enum as a parameter.
|
||||||
* @see SceneEnum
|
* @see SceneType
|
||||||
* @param newScene This is a SceneEnum of the scene which is requested to switch to
|
* @param newScene This is a SceneEnum of the scene which is requested to switch to
|
||||||
*/
|
*/
|
||||||
public static void swap(SceneEnum newScene){
|
public static void swap(SceneType newScene){
|
||||||
Parent root = fxmlLoader(newScene);
|
Parent root = fxmlLoader(newScene);
|
||||||
scene.setRoot(root);
|
scene.setRoot(root);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public class ScreenSwitch extends SharedCodeController {
|
||||||
* @param newScene This is a SceneEnum of the scene which is to be loaded in.
|
* @param newScene This is a SceneEnum of the scene which is to be loaded in.
|
||||||
* @return Parent containing the interpreted FXML.
|
* @return Parent containing the interpreted FXML.
|
||||||
*/
|
*/
|
||||||
private static Parent fxmlLoader(SceneEnum newScene){
|
private static Parent fxmlLoader(SceneType newScene){
|
||||||
Parent root = null;
|
Parent root = null;
|
||||||
try{
|
try{
|
||||||
String fxmlName = newScene.getFXML();
|
String fxmlName = newScene.getFXML();
|
||||||
|
@ -102,7 +102,7 @@ public class ScreenSwitch extends SharedCodeController {
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SceneEnum{
|
public enum SceneType {
|
||||||
/**
|
/**
|
||||||
* Enum containing each of the scenes required for use in the program along with the FXML file names.
|
* Enum containing each of the scenes required for use in the program along with the FXML file names.
|
||||||
* This is a sub-enum of ScreenSwitch
|
* This is a sub-enum of ScreenSwitch
|
||||||
|
@ -132,7 +132,7 @@ public class ScreenSwitch extends SharedCodeController {
|
||||||
*
|
*
|
||||||
* @param fxmlName This is the FXML file name including extension.
|
* @param fxmlName This is the FXML file name including extension.
|
||||||
*/
|
*/
|
||||||
SceneEnum(String fxmlName) {
|
SceneType(String fxmlName) {
|
||||||
this.fxmlName = fxmlName;
|
this.fxmlName = fxmlName;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -133,7 +133,7 @@ abstract public class SharedCodeController {
|
||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
private void dictionaryIconClick() {
|
private void dictionaryIconClick() {
|
||||||
ScreenSwitch.swap(ScreenSwitch.SceneEnum.dictionaryScene);
|
ScreenSwitch.swap(ScreenSwitch.SceneType.dictionaryScene);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,7 +142,7 @@ abstract public class SharedCodeController {
|
||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
private void practiceListIconClick() {
|
private void practiceListIconClick() {
|
||||||
ScreenSwitch.swap(ScreenSwitch.SceneEnum.practiceListScene);
|
ScreenSwitch.swap(ScreenSwitch.SceneType.practiceListScene);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -163,7 +163,7 @@ abstract public class SharedCodeController {
|
||||||
alert.setContentText("The practice list is currently empty, please add some practice words to use the Flashcard feature.");
|
alert.setContentText("The practice list is currently empty, please add some practice words to use the Flashcard feature.");
|
||||||
alert.showAndWait();
|
alert.showAndWait();
|
||||||
} else{
|
} else{
|
||||||
ScreenSwitch.swap(ScreenSwitch.SceneEnum.flashcardScene); // Switch to flashcard scene if the program has practice words.
|
ScreenSwitch.swap(ScreenSwitch.SceneType.flashcardScene); // Switch to flashcard scene if the program has practice words.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ abstract public class SharedCodeController {
|
||||||
@FXML
|
@FXML
|
||||||
private void addWordIconClick(){
|
private void addWordIconClick(){
|
||||||
|
|
||||||
ScreenSwitch.swap(ScreenSwitch.SceneEnum.addWordScene);
|
ScreenSwitch.swap(ScreenSwitch.SceneType.addWordScene);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package uk.ac.aber.cs221.group20.selfassessment;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.ButtonType;
|
import javafx.scene.control.ButtonType;
|
||||||
import uk.ac.aber.cs221.group20.javafx.*;
|
import uk.ac.aber.cs221.group20.javafx.*;
|
||||||
import uk.ac.aber.cs221.group20.javafx.*;
|
|
||||||
import uk.ac.aber.cs221.group20.json.DictionaryEntry;
|
import uk.ac.aber.cs221.group20.json.DictionaryEntry;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
@ -175,13 +174,13 @@ public class AssessmentGenerator {
|
||||||
|
|
||||||
if (currentQuestion instanceof MatchTheMeaningQuestion) {
|
if (currentQuestion instanceof MatchTheMeaningQuestion) {
|
||||||
MatchTheMeaningController.answer = ((MatchTheMeaningQuestion) currentQuestion).getCorrectAnswer();
|
MatchTheMeaningController.answer = ((MatchTheMeaningQuestion) currentQuestion).getCorrectAnswer();
|
||||||
ScreenSwitch.swap(ScreenSwitch.SceneEnum.matchMeaningScene);
|
ScreenSwitch.swap(ScreenSwitch.SceneType.matchMeaningScene);
|
||||||
} else if (currentQuestion instanceof SixMeaningsQuestion) {
|
} else if (currentQuestion instanceof SixMeaningsQuestion) {
|
||||||
SixMeaningsController.allQuestions = ((SixMeaningsQuestion) currentQuestion).getCorrectAnswer();
|
SixMeaningsController.allQuestions = ((SixMeaningsQuestion) currentQuestion).getCorrectAnswer();
|
||||||
ScreenSwitch.swap(ScreenSwitch.SceneEnum.sixMeaningScene);
|
ScreenSwitch.swap(ScreenSwitch.SceneType.sixMeaningScene);
|
||||||
} else if (currentQuestion instanceof TranslationQuestion) {
|
} else if (currentQuestion instanceof TranslationQuestion) {
|
||||||
TranslationController.answer = ((TranslationQuestion) currentQuestion).getCorrectAnswer();
|
TranslationController.answer = ((TranslationQuestion) currentQuestion).getCorrectAnswer();
|
||||||
ScreenSwitch.swap(ScreenSwitch.SceneEnum.translationScene);
|
ScreenSwitch.swap(ScreenSwitch.SceneType.translationScene);
|
||||||
} else {
|
} else {
|
||||||
System.err.print("The question has not been recognised");
|
System.err.print("The question has not been recognised");
|
||||||
System.err.println(currentQuestion);
|
System.err.println(currentQuestion);
|
||||||
|
@ -213,7 +212,7 @@ public class AssessmentGenerator {
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
if (result.isEmpty() || result.get() == noBtn) {
|
if (result.isEmpty() || result.get() == noBtn) {
|
||||||
ScreenSwitch.swap(ScreenSwitch.SceneEnum.dictionaryScene);
|
ScreenSwitch.swap(ScreenSwitch.SceneType.dictionaryScene);
|
||||||
} else {
|
} else {
|
||||||
generateAssessment(Application.practiceList);
|
generateAssessment(Application.practiceList);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue