Skip to content
Snippets Groups Projects
Commit b7feb37c authored by Philipp Stenkamp's avatar Philipp Stenkamp
Browse files

Minor cleanup. Added most basic functionality to the turntable

controller (turn CW / turn CCW).
parent a62a941f
No related branches found
No related tags found
No related merge requests found
Showing
with 49 additions and 73 deletions
No preview for this file type
No preview for this file type
No preview for this file type
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.ChoiceBox?> <?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.ToggleButton?> <?import javafx.scene.control.Button?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
...@@ -10,12 +9,9 @@ ...@@ -10,12 +9,9 @@
<children> <children>
<HBox alignment="BOTTOM_CENTER" layoutX="70.0" layoutY="457.0" AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" AnchorPane.topAnchor="0.0"> <HBox alignment="BOTTOM_CENTER" layoutX="70.0" layoutY="457.0" AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" AnchorPane.topAnchor="0.0">
<children> <children>
<ToggleButton fx:id="turntableLeftButton" mnemonicParsing="false" text="&lt;"> <Button fx:id="turntableLeftButton" mnemonicParsing="false" onAction="#handleTurnCCW" text="&lt;" />
<toggleGroup>
<ToggleGroup fx:id="turntableDirection" />
</toggleGroup></ToggleButton>
<ChoiceBox fx:id="slotChoiceBox" prefWidth="150.0" /> <ChoiceBox fx:id="slotChoiceBox" prefWidth="150.0" />
<ToggleButton fx:id="turntableRightButton" mnemonicParsing="false" text="&gt;" toggleGroup="$turntableDirection" /> <Button fx:id="turntableRightButton" mnemonicParsing="false" onAction="#handleTurnCW" text="&gt;" />
</children> </children>
</HBox> </HBox>
</children> </children>
......
No preview for this file type
...@@ -13,7 +13,7 @@ import gui.model.Engine; ...@@ -13,7 +13,7 @@ import gui.model.Engine;
import gui.model.Switch; import gui.model.Switch;
import gui.model.Settings; import gui.model.Settings;
import gui.view.EngineController; import gui.view.EngineController;
//import gui.view.TurntableController; import gui.view.TurntableController;
import gui.view.RootLayoutController; import gui.view.RootLayoutController;
import gui.view.SettingsController; import gui.view.SettingsController;
import gui.view.SwitchListController; import gui.view.SwitchListController;
...@@ -39,7 +39,7 @@ public class MainApp extends Application { ...@@ -39,7 +39,7 @@ public class MainApp extends Application {
private AnchorPane enginePane, turntablePane, settingsPane, switchListPane; private AnchorPane enginePane, turntablePane, settingsPane, switchListPane;
private EngineController engineController; private EngineController engineController;
private SwitchListController switchListController; private SwitchListController switchListController;
// private TurntableController turntableController; private TurntableController turntableController;
private Settings configuration; private Settings configuration;
private SettingsController settingsController; private SettingsController settingsController;
...@@ -108,9 +108,6 @@ public class MainApp extends Application { ...@@ -108,9 +108,6 @@ public class MainApp extends Application {
initTabs(); initTabs();
} }
/**
* Initializes the root layout.
*/
public void initRootLayout() { public void initRootLayout() {
try { try {
// Load root layout from fxml file. // Load root layout from fxml file.
...@@ -151,8 +148,8 @@ public class MainApp extends Application { ...@@ -151,8 +148,8 @@ public class MainApp extends Application {
FXMLLoader turntableLoader = new FXMLLoader(); FXMLLoader turntableLoader = new FXMLLoader();
turntableLoader.setLocation(MainApp.class.getResource("view/Turntable.fxml")); turntableLoader.setLocation(MainApp.class.getResource("view/Turntable.fxml"));
turntablePane = turntableLoader.load(); turntablePane = turntableLoader.load();
//turntableController = turntableLoader.getController(); turntableController = turntableLoader.getController();
//turntableController.setMainApp(this); turntableController.setMainApp(this);
FXMLLoader settingsLoader = new FXMLLoader(); FXMLLoader settingsLoader = new FXMLLoader();
settingsLoader.setLocation(MainApp.class.getResource("view/Settings.fxml")); settingsLoader.setLocation(MainApp.class.getResource("view/Settings.fxml"));
...@@ -164,7 +161,7 @@ public class MainApp extends Application { ...@@ -164,7 +161,7 @@ public class MainApp extends Application {
// Add the tabs // Add the tabs
tabs.add(new Tab("Loks", enginePane)); tabs.add(new Tab("Loks", enginePane));
tabs.add(new Tab("Weichen", switchListPane)); tabs.add(new Tab("Weichen", switchListPane));
tabs.add(new Tab("Drehscheibe", turntablePane)); tabs.add(new Tab("Drehteller", turntablePane));
tabs.add(new Tab("Einstellungen", settingsPane)); tabs.add(new Tab("Einstellungen", settingsPane));
rootController.loadTabs(); rootController.loadTabs();
......
...@@ -37,11 +37,11 @@ public class EngineController { ...@@ -37,11 +37,11 @@ public class EngineController {
*/ */
@FXML @FXML
private void initialize() { private void initialize() {
//engineChoiceBox.setItems(mainApp.getEngines()); doesn't work here (yet)
engineSpeedSlider.setValue(0); engineSpeedSlider.setValue(0);
engineFwdButton.setSelected(true); // initializes the forward Button as pressed engineFwdButton.setSelected(true); // initializes the forward Button as pressed
engineChoiceBox.getSelectionModel().selectedItemProperty().addListener( engineChoiceBox.getSelectionModel().selectedItemProperty().addListener(
(observable, oldValue, newValue) -> setSelectedEngine(newValue)); (observable, oldValue, newValue) -> setSelectedEngine(newValue));
engineSpeedSlider.valueProperty().addListener(new ChangeListener<Number>() { engineSpeedSlider.valueProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> ov, public void changed(ObservableValue<? extends Number> ov,
Number old_val, Number new_val) { Number old_val, Number new_val) {
......
...@@ -17,27 +17,6 @@ public class RootLayoutController { ...@@ -17,27 +17,6 @@ public class RootLayoutController {
// Reference to the main application. // Reference to the main application.
private MainApp mainApp; 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) { public void setMainApp(MainApp mainApp) {
this.mainApp = mainApp; this.mainApp = mainApp;
} }
......
...@@ -28,7 +28,7 @@ public class SwitchListController { ...@@ -28,7 +28,7 @@ public class SwitchListController {
*/ */
@FXML @FXML
private void initialize() { private void initialize() {
//setSwitchControls(); // would be nice to do this here, doesn't work unti setMainApp has been called //setSwitchControls(); // would be nice to do this here, doesn't work until setMainApp has been called
} }
/** /**
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.ChoiceBox?> <?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.ToggleButton?> <?import javafx.scene.control.Button?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?> <?import javafx.scene.layout.HBox?>
...@@ -10,12 +9,9 @@ ...@@ -10,12 +9,9 @@
<children> <children>
<HBox alignment="BOTTOM_CENTER" layoutX="70.0" layoutY="457.0" AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" AnchorPane.topAnchor="0.0"> <HBox alignment="BOTTOM_CENTER" layoutX="70.0" layoutY="457.0" AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" AnchorPane.topAnchor="0.0">
<children> <children>
<ToggleButton fx:id="turntableLeftButton" mnemonicParsing="false" text="&lt;"> <Button fx:id="turntableLeftButton" mnemonicParsing="false" onAction="#handleTurnCCW" text="&lt;" />
<toggleGroup>
<ToggleGroup fx:id="turntableDirection" />
</toggleGroup></ToggleButton>
<ChoiceBox fx:id="slotChoiceBox" prefWidth="150.0" /> <ChoiceBox fx:id="slotChoiceBox" prefWidth="150.0" />
<ToggleButton fx:id="turntableRightButton" mnemonicParsing="false" text="&gt;" toggleGroup="$turntableDirection" /> <Button fx:id="turntableRightButton" mnemonicParsing="false" onAction="#handleTurnCW" text="&gt;" />
</children> </children>
</HBox> </HBox>
</children> </children>
......
package gui.view; package gui.view;
import gui.MainApp; import gui.MainApp;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.ToggleButton; import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox; import javafx.scene.control.ChoiceBox;
public class TurntableController { public class TurntableController {
@FXML @FXML
private ToggleButton turntableLeftButton; private Button turntableLeftButton;
@FXML @FXML
private ToggleButton turntableRightButton; private Button turntableRightButton;
@FXML @FXML
private ChoiceBox<Number> slotChoiceBox; private ChoiceBox<Number> slotChoiceBox;
private MainApp mainApp; private MainApp mainApp;
...@@ -35,4 +33,14 @@ public void setMainApp(MainApp mainApp) { ...@@ -35,4 +33,14 @@ public void setMainApp(MainApp mainApp) {
this.mainApp = mainApp; this.mainApp = mainApp;
} }
public void handleTurnCCW (){
mainApp.turntableTurnCCW();
mainApp.setStatus("Letztes Kommando: Drehteller links drehen");
}
public void handleTurnCW (){
mainApp.turntableTurnCW();
mainApp.setStatus("Letztes Kommando: Drehteller rechts drehen");
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment