Converted TwoWayNode into abstract class

Becuase all the classes that will extend this class will implelmett thisa
same logic, so there is no reason to implement it as interface.
android-scanner
Vladimir Eliezer Tokarev 2016-08-27 14:24:00 +03:00
parent 9b636f2d2e
commit e200bc0f8b
14 changed files with 96 additions and 51 deletions

Binary file not shown.

View File

@ -5,7 +5,7 @@
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8">
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="main.welcome_splash.WelcomeSplashController">
<columnConstraints>
<ColumnConstraints />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />

View File

@ -1,5 +1,6 @@
package main;
import javafx.scene.Scene;
import javafx.stage.Stage;
import main.welcome_splash.WelcomeSplashLoader;
@ -19,7 +20,10 @@ public class ChainBuilder {
WelcomeSplashLoader welcomeSplashLoader = new WelcomeSplashLoader(primaryStage);
TwoWayNode welcomeSplashController = welcomeSplashLoader.GetWelcomeSplash();
/**
* all other two way nodes initilaized
*/
primaryStage.setScene(new Scene(welcomeSplashController.GetNode()));
}
}

View File

@ -2,16 +2,17 @@ package main;
import javafx.application.Application;
import javafx.stage.Stage;
import main.welcome_splash.WelcomeSplashLoader;
/**
* Created by Vladimir Eliezer Tokarev on 8/27/2016.
* Main calls to ChainBuilder which initilizes all the TwoWayNode's
*/
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
new WelcomeSplashLoader(primaryStage);
public void start(Stage primaryStage) throws Exception
{
ChainBuilder.Build(primaryStage);
primaryStage.setTitle("Meerkat Polling Station");
primaryStage.show();
}

View File

@ -7,35 +7,50 @@ import javafx.stage.Stage;
* Created by Vladimir Eliezer Tokarev on 8/27/2016.
* Two Way node gives the ability to set next and previous objects
*/
public interface TwoWayNode {
public abstract class TwoWayNode {
/**
* GetNode return the paren node that represents current object
* @return Paren object
*/
Parent GetNode();
protected Parent next;
protected Parent previous;
protected Stage currentStage;
protected Parent currentNode;
/**
* Sets which next TwoWayNode
* @param nextObject
*/
void SetNext(TwoWayNode nextObject);
public void SetNext(TwoWayNode nextObject) {
this.next = nextObject.GetNode();
}
/**
* Sets which previous TwoWayNode
* @param previousObject
*/
void SetPrevious(TwoWayNode previousObject);
public void SetPrevious(TwoWayNode previousObject) {
this.previous = previousObject.GetNode();
}
/**
* Sets the stage of current object
* @param primaryStage
*/
void SetStage(Stage primaryStage);
public void SetStage(Stage primaryStage) {
this.currentStage = primaryStage;
}
/**
* Sets the current parent node
* @param parent
*/
void SetParent(Parent parent);
public void SetParent(Parent parent) {
this.currentNode = parent;
}
/**
* GetNode return the paren node that represents current object
* @return Paren object
*/
public Parent GetNode() {
return this.currentNode;
}
}

View File

@ -0,0 +1,13 @@
package main.straight_channel_section;
import javafx.scene.Parent;
import javafx.stage.Stage;
import main.TwoWayNode;
/**
* Created by Vladimir Eliezer Tokarev on 8/27/2016.
* StraightChannelSectionController handle the behavior of welcome splash class
*/
public class StraightChannelSectionController extends TwoWayNode {
}

View File

@ -0,0 +1,45 @@
package main.straight_channel_section;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.stage.Stage;
import main.TwoWayNode;
import main.welcome_splash.WelcomeSplashController;
import java.io.IOException;
/**
* Created by Vladimir Eliezer Tokarev on 8/27/2016.
* StraightChannelSectionLoader creates starlight channel section object and sets its controller
*/
public class StraightChannelSectionLoader {
private static final String STRAIGHT_CHANNEL_LOADER_FXML_PATH = "straight_channel_section.fxml";
private Stage currentStage;
private FXMLLoader fxmlLoader;
public StraightChannelSectionLoader(Stage primaryStage) throws IOException
{
// Parent splashScreenOnBootRoot = FXMLLoader.load(getClass().getResource(SPLASH_SCREEN_ON_BOOT_FXML_PATH));
fxmlLoader = new FXMLLoader(getClass().getResource(STRAIGHT_CHANNEL_LOADER_FXML_PATH));
currentStage = primaryStage;
// currentStage.setScene(new Scene(splashScreenOnBootRoot));
}
/**
* Creates welcome splash parent node and sets it to the controller
* @return TwoWayNode
* @throws IOException
*/
public TwoWayNode GetStraightChannelSection() throws IOException {
Parent straightChannelSection = fxmlLoader.load();
StraightChannelSectionController controller = fxmlLoader.getController();
// set the controller to be functional TwoWayNode
controller.SetParent(welcomeSplash);
controller.SetStage(currentStage);
return controller;
}
}

View File

@ -8,38 +8,5 @@ import main.TwoWayNode;
* Created by Vladimir Eliezer Tokarev on 8/27/2016.
* WelcomeSplashController handle the behavior of welcome splash class
*/
public class WelcomeSplashController implements TwoWayNode {
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;
}
public class WelcomeSplashController extends TwoWayNode {
}

View File

@ -14,7 +14,7 @@ import java.io.IOException;
* 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 static final String WELCOME_SPLASH_FXML_PATH = "welcome_splash_screen.fxml";
private Stage currentStage;
private FXMLLoader fxmlLoader;
@ -22,7 +22,7 @@ public class WelcomeSplashLoader {
public WelcomeSplashLoader(Stage primaryStage) throws IOException
{
// Parent splashScreenOnBootRoot = FXMLLoader.load(getClass().getResource(SPLASH_SCREEN_ON_BOOT_FXML_PATH));
fxmlLoader = new FXMLLoader(getClass().getResource(SPLASH_SCREEN_ON_BOOT_FXML_PATH));
fxmlLoader = new FXMLLoader(getClass().getResource(WELCOME_SPLASH_FXML_PATH));
currentStage = primaryStage;
// currentStage.setScene(new Scene(splashScreenOnBootRoot));
}