Skip to content
Snippets Groups Projects
Commit 35f93c8e authored by Lukas Friedrichsen's avatar Lukas Friedrichsen
Browse files

copied maerklinControl to the Praktikum folder; using it as the new development-base from now on

parent 90023310
No related branches found
No related tags found
No related merge requests found
Showing
with 919 additions and 0 deletions
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry kind="lib" path="D:/Users/Philipp/gitlab/VInf/Praktikum/VINF_MaerklinProject/controlsfx-8.40.12.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MaerklinControl</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
/common/
/gui/
/server/
<?xml version="1.0" encoding="ASCII"?>
<anttasks:AntTask xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:anttasks="http://org.eclipse.fx.ide.jdt/1.0" buildDirectory="${project}/build">
<deploy>
<application name="TestMopped"/>
<info/>
</deploy>
<signjar/>
</anttasks:AntTask>
MaerklinControl
----------------------------------------------------------------------
Java FX8 Application to control and supervise a Märklin Digital Model Train Set, including multiple Trains / Engines, Switches and a Turntable.
Copyright (C) 2016, 2017 Lukas Friedrichsen & Philipp Stenkamp
{ [lukas.friedrichsen](mailto:lukas.friedrichsen@hs-bochum.de), [philipp.stenkamp](mailto:philipp.stenkamp@hs-bochum.de) }@hs-bochum.de
---
These documents are free software; you can redistribute them and/or
modify them under the terms and conditions of the following licenses:
- \*.tex, \*.pdf: documentation and slides
- either the GNU General Public License, version 3 or, at your option, any later version,
- or the Creative Commons Attribution-ShareAlike 3.0 Unported License
- \*.c, \*.cpp, \*.h, Makefile*: programmes
- either the Modified BSD License,
- or the Creative Commons Attribution-ShareAlike 3.0 Unported License
These documents are distributed in the hope that they will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
licenses for more details.
You should have received a [copy](https://gitlab.cvh-server.de/lf.ps/vbls/blob/master/common/GNU-GPL-3.txt) of the GNU General Public License along with this program; see the file GNU-GPL-3. If not, see <http://www.gnu.org/licenses/>.
You should have received a [copy](https://gitlab.cvh-server.de/lf.ps/vbls/blob/master/common/BSD-MODIFIED.txt) of the Modified BSD License along with this document; see the file BSD-MODIFIED. If not, see http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5.
You should have received a [copy](https://gitlab.cvh-server.de/lf.ps/vbls/blob/master/common/CC-BY-SA-3.0.txt) of the Creative Commons Attribution-ShareAlike 3.0 Unported License along with this document; see the file CC-BY-SA-3.0. If not, see
http://creativecommons.org/licenses/.
Praktikum/VINF_MaerklinControl/res/MagIcon_00_00_a.png

433 B

Praktikum/VINF_MaerklinControl/res/MagIcon_00_00_i.png

243 B

Praktikum/VINF_MaerklinControl/res/MagIcon_00_01_a.png

443 B

Praktikum/VINF_MaerklinControl/res/MagIcon_00_01_i.png

247 B

package common;
public class Properties {
// Defining server-ip and port
public final static int PORT = 1234567;
// Defining client-commands
public final static int SESSION_ABORT = -1;
public final static byte SYSTEM_STOP = 0x00;
public final static byte SYSTEM_GO = 0x01;
public final static byte GET_STATUS = 0x02;
public final static byte ENGINE_SET_SPEED = 0x03;
public final static byte ENGINE_INCREASE_SPEED = 0x04;
public final static byte ENGINE_DECREASE_SPEED = 0x05;
public final static byte ENGINE_SET_DIRECTION = 0x06;
public final static byte ENGINE_SWITCH_DIRECTION = 0x07;
public final static byte SWITCH_SET_DIRECTION = 0x08;
public final static byte SWITCH_SWITCH_DIRECTION = 0x09;
//Defining accessory-ids
public final static int ICE_ID = 0x0002;
public final static int LOK_ID = 0x4005;
public final static int REICHSBAHN_ID = 0x4007;
public final static int SWITCH4_ID = 0x3003;
public final static int SWITCH5_ID = 0x3004;
public final static int SWITCH6_ID = 0x3005;
public final static int SWITCH8_ID = 0x3007;
public final static int SWITCH9_ID = 0x3008;
public final static int SWITCH10_ID = 0x3009;
public final static int SWITCH12_ID = 0x300B;
public final static int SWITCH13_ID = 0x300C;
public final static int SWITCH14_ID = 0x300D;
public final static int SWITCH15_ID = 0x300E;
public final static int TURNTABLE_ID = 0x30E2;
}
package gui;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import gui.model.Engine;
import gui.model.Switch;
import gui.model.Settings;
import gui.view.EngineController;
//import gui.view.TurntableController;
import gui.view.RootLayoutController;
import gui.view.SettingsController;
import gui.view.SwitchListController;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import common.Properties;
public class MainApp extends Application {
private Stage primaryStage;
private BorderPane rootLayout;
private RootLayoutController rootController;
private AnchorPane enginePane, turntablePane, settingsPane, switchListPane;
private EngineController engineController;
private SwitchListController switchListController;
// private TurntableController turntableController;
private Settings configuration;
private SettingsController settingsController;
private ObservableList<Tab> tabs = FXCollections.observableArrayList();
private ObservableList<Switch> switches = FXCollections.observableArrayList();
private ObservableList<Engine> engines = FXCollections.observableArrayList();
private Switch turntable;
private Socket client;
private InputStream in;
private OutputStream out;
private Properties properties;
private Boolean connectionEstablished = false;
/**
* Constructor
*/
public MainApp() {
configuration = new Settings();
// Add the already known engines
engines.add(new Engine("ICE", 0x0002));
engines.add(new Engine("Dampflok", 0x4005));
engines.add(new Engine("Reichsbahn", 0x4007));
// Add the already known switches // yes, lazy, i know
for (int i=4;i<=15;i++){ switches.add(new Switch("Weiche "+i, 0x3000+(i-1))); }
turntable = new Switch("Drehteller", Properties.TURNTABLE_ID);
}
/**
* Returns the objects as an observable list.
* @return
*/
public ObservableList<Tab> getTabs() {
return tabs;
}
public ObservableList<Engine> getEngines() {
return engines;
}
public ObservableList<Switch> getSwitches() {
return switches;
}
@Override
public void start(Stage primaryStage) {
this.primaryStage = primaryStage;
this.primaryStage.setTitle("Mrklin Control Client");
initRootLayout();
initTabs();
}
/**
* Initializes the root layout.
*/
public void initRootLayout() {
try {
// Load root layout from fxml file.
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainApp.class.getResource("view/RootLayout.fxml"));
rootLayout = (BorderPane) loader.load();
rootController = loader.getController(); // only works if loader.load() has been called already
rootController.setMainApp(this);
// Show the scene containing the root layout.
Scene scene = new Scene(rootLayout);
primaryStage.setScene(scene);
primaryStage.show();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Shows the control tabs inside the root layout.
*/
public void initTabs() {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainApp.class.getResource("view/Engine.fxml"));
enginePane = loader.load();
engineController = loader.getController(); // only works if loader.load() has been called already
engineController.setMainApp(this);
FXMLLoader switchListLoader = new FXMLLoader();
switchListLoader.setLocation(MainApp.class.getResource("view/SwitchList.fxml"));
switchListPane = switchListLoader.load();
switchListController = switchListLoader.getController();
switchListController.setMainApp(this);
switchListController.setSwitchControls();
FXMLLoader turntableLoader = new FXMLLoader();
turntableLoader.setLocation(MainApp.class.getResource("view/Turntable.fxml"));
turntablePane = turntableLoader.load();
//turntableController = turntableLoader.getController();
//turntableController.setMainApp(this);
FXMLLoader settingsLoader = new FXMLLoader();
settingsLoader.setLocation(MainApp.class.getResource("view/Settings.fxml"));
settingsPane = settingsLoader.load();
settingsController = settingsLoader.getController();
settingsController.setMainApp(this);
settingsController.setSettings(configuration);
// Add the tabs
tabs.add(new Tab("Loks", enginePane));
tabs.add(new Tab("Weichen", switchListPane));
tabs.add(new Tab("Drehscheibe", turntablePane));
tabs.add(new Tab("Einstellungen", settingsPane));
rootController.loadTabs();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Returns the main stage.
* @return
*/
public void setStatus(String status){
rootController.setStatus(status);
}
public Stage getPrimaryStage() {
return primaryStage;
}
public static void main(String[] args) {
launch(args);
}
public void emergencyStopHandler() {
emergencyStop();
for(Engine eng:engines){
eng.setSpeed(0);
}
engineController.updateEngineStatus();
setStatus("NOTAUS");
}
public void emergencyStop () {
if (connectionEstablished) {
try {
byte[] datagram = {(byte) 0x00, (byte) Properties.SYSTEM_STOP, (byte) 0x00, (byte) 0x00};
out.write(datagram);
} catch (Exception e) {
setStatus("Error at: emergencyStop");
e.printStackTrace();
}
}
}
public void setEngineDirection (Engine eng) {
if (connectionEstablished) {
try {
byte dir;
if (eng.getDirection().get())
dir = (byte) 0x01;
else
dir = (byte) 0x02;
byte[] datagram = {(byte) eng.getMaerklinID().get(), (byte) Properties.ENGINE_SET_DIRECTION, dir, (byte) 0x00};
out.write(datagram);
} catch (Exception e) {
setStatus("Error at: engineSetDirectionRight");
e.printStackTrace();
}
}
}
public void setEngineSpeed (Engine eng) {
if (connectionEstablished) {
try {
int newEngineSpeed = eng.getSpeed().get();
byte[] datagram = {(byte) eng.getMaerklinID().get(), (byte) Properties.ENGINE_SET_SPEED, (byte) ((newEngineSpeed/(1<<8))%(1<<8)), (byte) (newEngineSpeed%(1<<8))};
out.write(datagram);
} catch (Exception e) {
setStatus("engineSetSpeed");
e.printStackTrace();
}
}
}
public void setSwitchState (Switch sw) {
if (connectionEstablished) {
try {
byte dir;
if (sw.getState().get())
dir = (byte) 0x00;
else
dir = (byte) 0x01;
byte[] datagram = {(byte) sw.getMaerklinID().get(), (byte) Properties.SWITCH_SET_DIRECTION, dir, (byte) 0x00};
out.write(datagram);
} catch (Exception e) {
setStatus("Error at: switchSetDirection");
e.printStackTrace();
}
}
}
public void turntableTurnCW () {
if (connectionEstablished) {
try {
byte[] datagram = {(byte) turntable.getMaerklinID().get(), (byte) Properties.SWITCH_SET_DIRECTION, (byte) 0x00, (byte) 0x00};
out.write(datagram);
} catch (Exception e) {
setStatus("Error at: turntableTurnCW");
e.printStackTrace();
}
}
}
public void turntableTurnCCW () {
if (connectionEstablished) {
try {
byte[] datagram = {(byte) turntable.getMaerklinID().get(), (byte) Properties.SWITCH_SET_DIRECTION, (byte) 0x01, (byte) 0x00};
out.write(datagram);
} catch (Exception e) {
setStatus("Error at: turntableTurnCCW");
e.printStackTrace();
}
}
}
public void establishConnetion () {
if (connectionEstablished) {
try {
byte[] datagram = {(byte) 0x00, (byte) Properties.SESSION_ABORT, (byte) 0x00, (byte) 0x00};
out.write(datagram);
client.close();
connectionEstablished = false;
} catch (Exception e) {
setStatus("Error at: establishConnection (shutting down connection");
e.printStackTrace();
}
}
else {
try (Socket socket = new Socket()) {
socket.bind(configuration.getSocketAddress().get());
client = socket;
client.setKeepAlive(true);
in = client.getInputStream();
out = client.getOutputStream();
client.setSoTimeout(200);
connectionEstablished = true;
setStatus("Verbindung zu "+client.getRemoteSocketAddress()+" aufgebaut!");
Platform.runLater(new updateThread(this));
}
catch (Exception e) {
setStatus("Error at: establishConnection (establishing connection");
e.printStackTrace();
}
}
}
class updateThread implements Runnable {
MainApp controllerInstance;
updateThread (MainApp controller) {
controllerInstance = controller;
}
@Override
public void run() {
// TODO Auto-generated method stub
}
}
}
\ No newline at end of file
package gui.model;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
/**
* Model class for a Model Engine.
*
* @author Philipp Stenkamp
*/
public class Engine {
private final StringProperty name;
private final IntegerProperty id;
private final IntegerProperty speed;
private final BooleanProperty fwd;
/**
* Default constructor.
*/
public Engine() {
this(null, null);
}
/**
* Constructor with some initial data.
*
* @param name
* @param id
*/
public Engine(String name, Integer id) {
this.name = new SimpleStringProperty(name);
this.id = new SimpleIntegerProperty(id);
// Initialize the switch in a straigt (=false) state
this.fwd = new SimpleBooleanProperty(true);
this.speed = new SimpleIntegerProperty(0);
}
@Override
public String toString() {
return name.getValue();
}
public StringProperty getName() {
return name;
}
public IntegerProperty getMaerklinID() {
return id;
}
public BooleanProperty getDirection() {
return fwd;
}
public void setDirection(Boolean fwd) {
this.fwd.set(fwd);
}
public IntegerProperty getSpeed() {
return speed;
}
public void setSpeed(Integer speed) {
this.speed.set(speed);
}
}
package gui.model;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.SimpleObjectProperty;
/**
* Model class for a Model Engine.
*
* @author Philipp Stenkamp
*/
public class Settings {
private final ObjectProperty<InetSocketAddress> server;
/**
* Default constructor.
*/
public Settings() {
this.server = new SimpleObjectProperty<InetSocketAddress> (new InetSocketAddress("localhost", 12345));
}
public ObjectProperty<InetSocketAddress> getSocketAddress() {
return server;
}
public void setSocketAddress(InetSocketAddress server) {
this.server.set(server);
}
}
package gui.model;
import javafx.beans.property.IntegerProperty;
import gui.view.SwitchControl;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.property.ObjectProperty;
/**
* Model class for a Model Train Switch.
*
* @author Philipp Stenkamp
*/
public class Switch{
private final StringProperty name;
private final IntegerProperty id;
private final BooleanProperty state;
private final ObjectProperty<SwitchControl> controller;
/**
* Default constructor.
*/
public Switch() {
this(null, null, null);
}
/**
* Constructor with some initial data.
*
* @param name
* @param id
*/
public Switch(String name, Integer id){
this(name, id, null);
}
public Switch(String name, Integer id, SwitchControl controller) {
this.name = new SimpleStringProperty(name);
this.id = new SimpleIntegerProperty(id);
this.controller = new SimpleObjectProperty<SwitchControl>(controller);
// Initialize the switch in a straigt (=false) state
this.state = new SimpleBooleanProperty(false);
}
@Override
public String toString() {
return name.getValue();
}
public StringProperty getName() {
return name;
}
public void setName(String name) {
this.name.set(name);
}
public IntegerProperty getMaerklinID() {
return id;
}
public BooleanProperty getState() {
return state;
}
public void setState(Boolean state) {
this.state.set(state);
}
public ObjectProperty<SwitchControl> getController(){
return controller;
}
public void setController(SwitchControl controller){
this.controller.setValue(controller);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane prefHeight="600.0" prefWidth="340.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1">
<children>
<TabPane layoutX="10.0" layoutY="10.0" prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<tabs>
<Tab text="Loks">
<content>
<fx:include source="Engine.fxml" />
</content>
</Tab>
<Tab text="Weichen">
<content>
<fx:include source="SwitchList.fxml" />
</content>
</Tab>
<Tab text="Drehscheibe">
<content>
<fx:include source="Turntable.fxml" />
</content>
</Tab>
<Tab text="Verbindung">
<content>
<fx:include source="Settings.fxml" />
</content>
</Tab>
</tabs>
</TabPane>
</children>
</AnchorPane>
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.Slider?>
<?import javafx.scene.control.ToggleButton?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gui.view.EngineController">
<children>
<VBox alignment="BOTTOM_LEFT" prefHeight="200.0" prefWidth="100.0" AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" AnchorPane.topAnchor="0.0">
<children>
<Slider fx:id="engineSpeedSlider" showTickLabels="true" showTickMarks="true" />
<HBox alignment="CENTER" prefWidth="300.0">
<children>
<ToggleButton fx:id="engineRevButton" mnemonicParsing="false" onAction="#handleEngineDirection" text="&lt;">
<toggleGroup>
<ToggleGroup fx:id="direction" />
</toggleGroup></ToggleButton>
<ChoiceBox fx:id="engineChoiceBox" prefWidth="150.0" />
<ToggleButton fx:id="engineFwdButton" mnemonicParsing="false" onAction="#handleEngineDirection" text="&gt;" toggleGroup="$direction" />
</children>
</HBox>
</children>
<opaqueInsets>
<Insets right="9.0" />
</opaqueInsets>
</VBox>
</children>
</AnchorPane>
package gui.view;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.scene.control.Slider;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ToggleButton;
import gui.MainApp;
import gui.model.Engine;
public class EngineController {
@FXML
private Slider engineSpeedSlider;
@FXML
private ChoiceBox<Engine> engineChoiceBox;
@FXML
private ToggleButton engineRevButton, engineFwdButton;
// Reference to the main application.
private MainApp mainApp;
private Engine eng;
/**
* The constructor.
* The constructor is called before the initialize() method.
*/
public EngineController() {
}
/**
* Initializes the controller class. This method is automatically called
* after the fxml file has been loaded.
*/
@FXML
private void initialize() {
//engineChoiceBox.setItems(mainApp.getEngines()); doesn't work here (yet)
engineSpeedSlider.setValue(0);
engineFwdButton.setSelected(true); // initializes the forward Button as pressed
engineChoiceBox.getSelectionModel().selectedItemProperty().addListener(
(observable, oldValue, newValue) -> selectEngine(newValue));
engineSpeedSlider.valueProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> ov,
Number old_val, Number new_val) {
eng.setSpeed(new_val.intValue()*10);
mainApp.setEngineSpeed(eng);
updateEngineStatus();
}
});
}
/**
* Is called by the main application to give a reference back to itself.
*
* @param mainApp
*/
public void setMainApp(MainApp mainApp) {
this.mainApp = mainApp;
engineChoiceBox.setItems(mainApp.getEngines());
engineChoiceBox.setValue(mainApp.getEngines().get(0));
}
public void handleEngineDirection(){
eng.setDirection(engineFwdButton.isSelected());
eng.setSpeed(0);
mainApp.setEngineDirection(eng);
updateEngineStatus();
}
public void updateEngineStatus(){
engineSpeedSlider.setValue(eng.getSpeed().get()/10);
StringBuilder status = new StringBuilder("Letztes Kommando: ");
status.append(eng.toString() + " ");
status.append(eng.getSpeed().get()/10 + "% ");
engineFwdButton.setSelected(eng.getDirection().get());
engineRevButton.setSelected(!eng.getDirection().get());
if (eng.getDirection().get())
status.append("vorwrts");
else
status.append("rckwrts");
mainApp.setStatus(status.toString());
}
public void selectEngine(Engine eng){
this.eng = eng;
mainApp.setStatus(eng.toString() + " ausgewhlt");
updateEngineStatus();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<?import org.controlsfx.control.StatusBar?>
<BorderPane prefHeight="600.0" prefWidth="340.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="gui.view.RootLayoutController">
<top>
<MenuBar BorderPane.alignment="CENTER">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" text="Close" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem mnemonicParsing="false" text="Delete" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
<center>
<TabPane fx:id="rootTabPane" prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" BorderPane.alignment="CENTER">
<tabs>
</tabs>
</TabPane>
</center>
<bottom>
<VBox alignment="TOP_CENTER" BorderPane.alignment="CENTER">
<children>
<Button fx:id="emergencyStop" mnemonicParsing="false" onAction="#emergencyStopHandler" prefHeight="50.0" prefWidth="300.0" style="-fx-background-color: red;" text="NOTAUS" textFill="WHITE">
<padding>
<Insets bottom="10.0" left="5.0" right="5.0" top="5.0" />
</padding>
<font>
<Font name="System Bold" size="14.0" />
</font>
<VBox.margin>
<Insets bottom="10.0" top="10.0" />
</VBox.margin>
</Button>
<StatusBar fx:id="statusBar" />
</children>
</VBox>
</bottom>
</BorderPane>
package gui.view;
import javafx.fxml.FXML;
import javafx.scene.control.TabPane;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.paint.Color;
import org.controlsfx.control.StatusBar;
import gui.MainApp;
public class RootLayoutController {
@FXML
private TabPane rootTabPane;
@FXML
private StatusBar statusBar;
// Reference to the main application.
private MainApp mainApp;
/**
* The constructor.
* The constructor is called before the initialize() method.
*/
public RootLayoutController() {
}
/**
* Initializes the controller class. This method is automatically called
* after the fxml file has been loaded.
*/
@FXML
private void initialize() {
}
/**
* Is called by the main application to give a reference back to itself.
*
* @param mainApp
*/
public void setMainApp(MainApp mainApp) {
this.mainApp = mainApp;
}
public void loadTabs(){
rootTabPane.getTabs().addAll(mainApp.getTabs()); //can't be in the constructor
}
public void setStatus(String status){
statusBar.setText(status);
}
public void emergencyStopHandler(){
mainApp.emergencyStopHandler();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment