diff --git a/voting-booth-gui/src/main/ChainBuilder.java b/voting-booth-gui/src/main/ChainBuilder.java index 76677bb..c45e021 100644 --- a/voting-booth-gui/src/main/ChainBuilder.java +++ b/voting-booth-gui/src/main/ChainBuilder.java @@ -1,5 +1,10 @@ package main; +import javafx.stage.Stage; +import main.welcome_splash.WelcomeSplashLoader; + +import java.io.IOException; + /** * Created by Vladimir Eliezer Tokarev on 8/27/2016. * ChainBuilder builds all the two way nodes that are in current project (voting-booth-gui) @@ -10,7 +15,10 @@ public class ChainBuilder { /** * Creates all the twoWayNodes and connects between them */ - public static void Build() { + public static void Build(Stage primaryStage) throws IOException { + WelcomeSplashLoader welcomeSplashLoader = new WelcomeSplashLoader(primaryStage); + TwoWayNode welcomeSplashController = welcomeSplashLoader.GetWelcomeSplash(); + } diff --git a/voting-booth-gui/src/main/welcome_splash/Main.java b/voting-booth-gui/src/main/Main.java similarity index 88% rename from voting-booth-gui/src/main/welcome_splash/Main.java rename to voting-booth-gui/src/main/Main.java index d9c6213..35672a0 100644 --- a/voting-booth-gui/src/main/welcome_splash/Main.java +++ b/voting-booth-gui/src/main/Main.java @@ -1,7 +1,8 @@ -package main.welcome_splash; +package main; import javafx.application.Application; import javafx.stage.Stage; +import main.welcome_splash.WelcomeSplashLoader; /** * Created by Vladimir Eliezer Tokarev on 8/27/2016. diff --git a/voting-booth-gui/src/main/TwoWayNode.java b/voting-booth-gui/src/main/TwoWayNode.java index a247f69..e20e326 100644 --- a/voting-booth-gui/src/main/TwoWayNode.java +++ b/voting-booth-gui/src/main/TwoWayNode.java @@ -1,5 +1,6 @@ package main; +import javafx.scene.Parent; import javafx.stage.Stage; /** @@ -8,7 +9,33 @@ import javafx.stage.Stage; */ public interface TwoWayNode { + /** + * GetNode return the paren node that represents current object + * @return Paren object + */ + Parent GetNode(); + + /** + * Sets which next TwoWayNode + * @param nextObject + */ void SetNext(TwoWayNode nextObject); + + /** + * Sets which previous TwoWayNode + * @param previousObject + */ void SetPrevious(TwoWayNode previousObject); + + /** + * Sets the stage of current object + * @param primaryStage + */ void SetStage(Stage primaryStage); + + /** + * Sets the current parent node + * @param parent + */ + void SetParent(Parent parent); } diff --git a/voting-booth-gui/src/main/welcome_splash/WelcomeSplashController.java b/voting-booth-gui/src/main/welcome_splash/WelcomeSplashController.java index 2a10185..999a510 100644 --- a/voting-booth-gui/src/main/welcome_splash/WelcomeSplashController.java +++ b/voting-booth-gui/src/main/welcome_splash/WelcomeSplashController.java @@ -10,22 +10,36 @@ import main.TwoWayNode; */ public class WelcomeSplashController implements TwoWayNode { - private Parent Next; - private Parent Previous; + private Parent next; + private Parent previous; private Stage currentSrage; + private Parent currentNode; + @Override public void SetNext(TwoWayNode nextObject) { - + this.next = nextObject.GetNode(); } @Override public void SetPrevious(TwoWayNode previousObject) { - + this.previous = previousObject.GetNode(); } @Override public void SetStage(Stage primaryStage) { - + this.currentSrage = primaryStage; } + + @Override + public void SetParent(Parent parent) { + this.currentNode = parent; + } + + @Override + public Parent GetNode() { + return this.currentNode; + } + + } diff --git a/voting-booth-gui/src/main/welcome_splash/WelcomeSplashLoader.java b/voting-booth-gui/src/main/welcome_splash/WelcomeSplashLoader.java index 9560175..085a8cb 100644 --- a/voting-booth-gui/src/main/welcome_splash/WelcomeSplashLoader.java +++ b/voting-booth-gui/src/main/welcome_splash/WelcomeSplashLoader.java @@ -5,21 +5,41 @@ import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; +import main.TwoWayNode; import java.io.IOException; /** * Created by Vladimir Eliezer Tokarev on 8/27/2016. + * WelcomeSplashLoader creates welcome spalash object and sets its controller */ public class WelcomeSplashLoader { private static final String SPLASH_SCREEN_ON_BOOT_FXML_PATH = "welcome_splash_screen.fxml"; private Stage currentStage; + private FXMLLoader fxmlLoader; public WelcomeSplashLoader(Stage primaryStage) throws IOException { - Parent splashScreenOnBootRoot = FXMLLoader.load(getClass().getResource(SPLASH_SCREEN_ON_BOOT_FXML_PATH)); + // Parent splashScreenOnBootRoot = FXMLLoader.load(getClass().getResource(SPLASH_SCREEN_ON_BOOT_FXML_PATH)); + fxmlLoader = new FXMLLoader(getClass().getResource(SPLASH_SCREEN_ON_BOOT_FXML_PATH)); currentStage = primaryStage; - currentStage.setScene(new Scene(splashScreenOnBootRoot, 565, 365)); + // currentStage.setScene(new Scene(splashScreenOnBootRoot)); + } + + /** + * Creates welcome splash parent node and sets it to the controller + * @return TwoWayNode + * @throws IOException + */ + public TwoWayNode GetWelcomeSplash() throws IOException { + Parent welcomeSplash = fxmlLoader.load(); + WelcomeSplashController controller = fxmlLoader.getController(); + + // set the controller to be functional TwoWayNode + controller.SetParent(welcomeSplash); + controller.SetStage(currentStage); + + return controller; } }