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

Added the missing comments and read everything proof once again.

The Java Native Package does not yet work though..
parent fae41545
No related branches found
No related tags found
No related merge requests found
Showing
with 76 additions and 20 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
package common;
/*
* In dieser Klasse werden alle klassenübergreifen verwendeten Werte einmalig deklariert,
* so dass potentielle Änderungen lediglich einmalig an dieser Stelle durchgeführt werden
* müssen und Code-Vervielfachung vermieden wird (Einhaltung des DRY-Prinzips).
* In dieser Klasse werden alle klassenuebergreifend verwendeten Werte einmalig deklariert,
* so dass potentielle Aenderungen lediglich einmalig an dieser Stelle durchgefuehrt werden
* muessen und Code-Vervielfachung vermieden wird (Einhaltung des DRY-Prinzips).
*/
public class Properties {
......
......@@ -31,7 +31,7 @@ import common.Properties;
/*
* Die Klasse MainApp stellt die Hauptklasse der Clients dar. In ihr wird die GUI initialisiert
* und geladen sowie sämtliche "nach außen" (zum Server) gerichteten Funktionalitäten implementiert.
* und geladen sowie saemtliche "nach aussen" (zum Server) gerichteten Funktionalitaeten implementiert.
*/
public class MainApp extends Application {
......@@ -83,11 +83,11 @@ public class MainApp extends Application {
}
// Initializes the loading of the GUI
// Initializes the GUI
@Override
public void start(Stage primaryStage) {
this.primaryStage = primaryStage;
this.primaryStage.setTitle("Mrklin Control Client");
this.primaryStage.setTitle("Mrklin Control Client");
this.primaryStage.getIcons().add(new Image("file:res/BO.png"));
initRootLayout();
initTabs();
......@@ -112,7 +112,7 @@ public class MainApp extends Application {
}
}
// Shows the control tabs inside the root layout.
// Shows the control tabs inside the tab pane of the root layout.
public void initTabs() {
try {
FXMLLoader loader = new FXMLLoader();
......
......@@ -12,7 +12,7 @@ import javafx.beans.property.StringProperty;
import javafx.scene.image.Image;
/*
* Modell-Klasse für einen Zug.
* Modell-Klasse fuer einen Zug.
*/
public class Engine {
......
......@@ -7,7 +7,7 @@ import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
/*
* Modell-Klasse für die Einstellungen der App.
* Modell-Klasse fuer die Einstellungen der App.
*/
public class Settings {
private final ObjectProperty<InetSocketAddress> server;
......
......@@ -11,7 +11,7 @@ import javafx.beans.property.StringProperty;
import javafx.beans.property.ObjectProperty;
/*
* Modell-Klasse für eine Weiche.
* Modell-Klasse fuer eine Weiche.
*/
public class Switch{
......
......@@ -10,6 +10,10 @@ import javafx.scene.image.ImageView;
import gui.MainApp;
import gui.model.Engine;
/*
* Die Klasse EngineController stellt den Controller fr die Bedienelemente zur Steuerung der Lokomotiven bereit.
*/
public class EngineController {
@FXML
private ImageView engineImage;
......@@ -38,7 +42,9 @@ public class EngineController {
@FXML
private void initialize() {
engineSpeedSlider.setValue(0);
engineFwdButton.setSelected(true); // initializes the forward Button as pressed
engineFwdButton.setSelected(true); // initializes the forward Button as pressed - default direction
// updates the local reference of the selected engine to the Engine selected in the ChoiceBox
engineChoiceBox.getSelectionModel().selectedItemProperty().addListener(
(observable, oldValue, newValue) -> setSelectedEngine(newValue));
......@@ -64,12 +70,14 @@ public class EngineController {
engineImage.setImage(mainApp.getEngines().get(0).getImg().get());
}
// Is called if the state of the direction buttons changes and updates the engine model accordingly
public void handleEngineDirection(){
eng.setDirection(engineFwdButton.isSelected());
mainApp.setEngineDirection(eng);
updateEngineStatus();
}
// updates the GUI to the values of the currently selected engine
public void updateEngineStatus(){
engineImage.setImage(eng.getImg().get());
engineSpeedSlider.setValue(eng.getSpeed().get()/10);
......@@ -80,15 +88,21 @@ public class EngineController {
engineFwdButton.setSelected(eng.getDirection().get());
engineRevButton.setSelected(!eng.getDirection().get());
if (eng.getDirection().get())
status.append("vorwrts");
status.append("vorwrts");
else
status.append("rckwrts");
status.append("rckwrts");
mainApp.setStatus(status.toString());
}
/**
* updates the local reference of the selected engine to the given one
*
* @param Engine
*/
public void setSelectedEngine(Engine eng){
this.eng = eng;
mainApp.setStatus(eng.toString() + " ausgewhlt");
mainApp.setStatus(eng.toString() + " ausgewhlt");
updateEngineStatus();
}
......
......@@ -7,6 +7,10 @@ import org.controlsfx.control.StatusBar;
import gui.MainApp;
/*
* Die Klasse RootLayoutController stellt den Controller fr die Bedienelemente des Basislayouts bereit.
*/
public class RootLayoutController {
@FXML
private TabPane rootTabPane;
......@@ -17,18 +21,29 @@ public class RootLayoutController {
// Reference to the main application.
private MainApp mainApp;
/**
* Is called by the main application to give a reference back to itself.
*
* @param mainApp
*/
public void setMainApp(MainApp mainApp) {
this.mainApp = mainApp;
}
/**
* get the tabs from the main app and load them into the local tabPane
* can't be done in the constructor, since mainApp has to be set first
*/
public void loadTabs(){
rootTabPane.getTabs().addAll(mainApp.getTabs()); //can't be in the constructor
rootTabPane.getTabs().addAll(mainApp.getTabs());
}
// sets the StatusBar text
public void setStatus(String status){
statusBar.setText(status);
}
// passes the Emergency Stop command to the mainApp
public void emergencyStopHandler(){
mainApp.emergencyStopHandler();
}
......
......@@ -39,7 +39,11 @@ public class SettingsController {
public void setMainApp(MainApp mainApp) {
this.mainApp = mainApp;
}
/**
* is called by an OnClick event caused by the Connect Button.
* updates the Settings model to the currently selected IP Adress and
* calls the establishConnection method of the mainApp.
*/
@FXML
private void connectHandler(){
InetSocketAddress address = new InetSocketAddress(serverIP.getText(), settings.getSocketAddress().get().getPort());
......@@ -48,6 +52,7 @@ public class SettingsController {
mainApp.establishConnetion();
}
// updates the GUI
public void updateSettingsStatus(){
InetSocketAddress addr = settings.getSocketAddress().get();
StringBuilder status = new StringBuilder("Verbindung herstellen mit ");
......@@ -62,6 +67,11 @@ public class SettingsController {
}
}
/**
* updates the local reference of the selected settings model to the given one
*
* @param Settings
*/
public void setSettings(Settings settings) {
this.settings = settings;
}
......
......@@ -15,6 +15,11 @@ import org.controlsfx.control.ToggleSwitch;
import gui.MainApp;
import gui.model.Switch;
/*
* Die Klasse SwitchControl stellt ein Sonderbedienelement dar. Sie ldt die Bedienelemente fr jeweils eine Weiche
* und fungiert gleichzeitig als deren Controller. Ihr wird im Konstruktor das zugehrige Weichen-Objekt bergeben.
*/
public class SwitchControl extends HBox{
@FXML
private Label nameLabel;
......@@ -37,6 +42,8 @@ public class SwitchControl extends HBox{
/**
* The constructor.
* The constructor is called before the initialize() method.
* Unique in that it does also load the Switch.fxml, which is usally done in an
* higher class, not in the controller itself.
*/
public SwitchControl(Switch sw) {
this.sw = sw;
......@@ -80,7 +87,7 @@ public class SwitchControl extends HBox{
this.mainApp = mainApp;
}
// updates the GUI elements to reflect the current state of the switch
public void updateSwitchStatus(){
stateToggleSwitch.setSelected(sw.getState().get());
......
......@@ -40,7 +40,11 @@ public class SwitchListController {
this.mainApp = mainApp;
}
/**
* this is where the magic happens!
* kidding aside, this method creates and assigns a new SwitchControl instance to every switch defined in the mainApp.
* it then adds these SwitchControls to the VBox provided in the SwitchList.fxml
*/
public void setSwitchControls(){
ObservableList<Switch> switches = mainApp.getSwitches();
ObservableList<SwitchControl> switchControls = FXCollections.observableArrayList();
......
......@@ -5,6 +5,10 @@ import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
/*
* Die Klasse TurntableController stellt den Controller fr die Bedienelemente zur Steuerung der Drehscheibe bereit.
*/
public class TurntableController {
@FXML
......@@ -34,11 +38,13 @@ public class TurntableController {
}
// Is called by an onClick event on the left button and calls the according function in the main app
public void handleTurnCCW (){
mainApp.turntableTurnCCW();
mainApp.setStatus("Letztes Kommando: Drehteller links drehen");
}
// Is called by an onClick event on the right button and calls the according function in the main app
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