From 1ed7ccf146d649a2b333406f4ee3b198fe822987 Mon Sep 17 00:00:00 2001 From: Jessica Syder Date: Sat, 9 Sep 2017 10:44:19 +1200 Subject: [PATCH] Minor changes preparing to merge in 3D #story[1261] --- .../Controllers/ConnectionController.java | 3 +- .../Controllers/KeyBindingsController.java | 37 +++++++++---------- .../Controllers/LobbyHostingController.java | 2 - .../Controllers/RaceViewController.java | 2 - 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/racevisionGame/src/main/java/visualiser/Controllers/ConnectionController.java b/racevisionGame/src/main/java/visualiser/Controllers/ConnectionController.java index c95ce731..7c9269e3 100644 --- a/racevisionGame/src/main/java/visualiser/Controllers/ConnectionController.java +++ b/racevisionGame/src/main/java/visualiser/Controllers/ConnectionController.java @@ -6,6 +6,7 @@ import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.scene.layout.AnchorPane; import visualiser.model.RaceConnection; + import java.io.IOException; import java.net.Socket; import java.net.URL; @@ -13,7 +14,7 @@ import java.util.ResourceBundle; //TODO it appears this view/controller was replaced by Lobby.fxml. Remove? /** - * Controls the connection that the VIsualiser can connect to. + * Controls the connection that the Visualiser can connect to. */ public class ConnectionController extends Controller { @FXML AnchorPane connectionWrapper; diff --git a/racevisionGame/src/main/java/visualiser/Controllers/KeyBindingsController.java b/racevisionGame/src/main/java/visualiser/Controllers/KeyBindingsController.java index 63e7ffda..b8359aad 100644 --- a/racevisionGame/src/main/java/visualiser/Controllers/KeyBindingsController.java +++ b/racevisionGame/src/main/java/visualiser/Controllers/KeyBindingsController.java @@ -1,7 +1,6 @@ package visualiser.Controllers; import javafx.application.Platform; -import javafx.event.EventHandler; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.ListView; @@ -49,7 +48,7 @@ public class KeyBindingsController extends Controller { * Sets up table before populating it. * Set up includes headings, CSS styling and modifying default properties. */ - public void initializeTable(){ + private void initializeTable(){ // set the headings for each column lstKey.getItems().add("Key"); lstControl.getItems().add("Command"); @@ -67,15 +66,15 @@ public class KeyBindingsController extends Controller { // stop the columns from being selectable, so only the buttons are lstKey.getSelectionModel().selectedItemProperty() - .addListener((observable, oldvalue, newValue) -> + .addListener((observable, oldValue, newValue) -> Platform.runLater(() -> lstKey.getSelectionModel().select(0))); lstDescription.getSelectionModel().selectedItemProperty() - .addListener((observable, oldvalue, newValue) -> + .addListener((observable, oldValue, newValue) -> Platform.runLater(() -> lstDescription.getSelectionModel().select(0))); lstControl.getSelectionModel().selectedItemProperty() - .addListener((observable, oldvalue, newValue) -> + .addListener((observable, oldValue, newValue) -> Platform.runLater(() -> lstControl.getSelectionModel().select(0))); } @@ -83,7 +82,7 @@ public class KeyBindingsController extends Controller { /** * Populates the table with commands and their key binding details. */ - public void populateTable(){ + private void populateTable(){ // add each command to the table for (Map.Entry entry : newKeyFactory.getKeyState().entrySet()) { // create button for command @@ -100,9 +99,9 @@ public class KeyBindingsController extends Controller { /** * Makes a copy of the {@link KeyFactory} that does not modify the original. - * @return new keyfactory to be modified + * @return new keyFactory to be modified */ - public KeyFactory copyExistingFactory(){ + private KeyFactory copyExistingFactory(){ newKeyFactory = new KeyFactory(); Map oldKeyState = existingKeyFactory.getKeyState(); Map newKeyState = new HashMap<>(); @@ -118,18 +117,16 @@ public class KeyBindingsController extends Controller { /** * Creates a listener for when a user tries to close the current window. */ - public void setClosedListener(){ + private void setClosedListener(){ anchor.sceneProperty().addListener((obsS, oldS, newS) -> { if (newS != null) { newS.windowProperty().addListener((obsW, oldW, newW) -> { if (newW != null) { Stage stage = (Stage)newW; // WE is processed by onExit method - stage.setOnCloseRequest(new EventHandler() { - public void handle(WindowEvent we) { - if (we.getEventType() == WindowEvent.WINDOW_CLOSE_REQUEST) { - onExit(we); - } + stage.setOnCloseRequest(we -> { + if (we.getEventType() == WindowEvent.WINDOW_CLOSE_REQUEST) { + onExit(we); } }); } @@ -139,11 +136,11 @@ public class KeyBindingsController extends Controller { } /** - * Creates a listener for the base anchorpane for key presses. + * Creates a listener for the base anchorPane for key presses. * It updates the current key bindings of the {@link KeyFactory} if * required. */ - public void setKeyListener(){ + private void setKeyListener(){ anchor.addEventFilter(KeyEvent.KEY_PRESSED, event -> { // if esc, cancel current button click if (event.getCode() == KeyCode.ESCAPE){ @@ -218,10 +215,10 @@ public class KeyBindingsController extends Controller { * commands are missing a key binding. * @return True if valid, false if invalid */ - public Boolean isFactoryValid(){ + private Boolean isFactoryValid(){ for (Map.Entry entry : newKeyFactory.getKeyState().entrySet ()) { - if (entry.getKey().toString()==entry.getValue().toString()){ + if (entry.getKey().toString().equals(entry.getValue().toString())){ return false; } } @@ -234,7 +231,7 @@ public class KeyBindingsController extends Controller { * @param we {@link WindowEvent} close request to be consumed if settings * have not been successfully saved. */ - public void onExit(WindowEvent we){ + private void onExit(WindowEvent we){ // if modified KeyFactory hasn't been saved if (changed){ loadNotification("Please cancel or save your changes before exiting" + @@ -248,7 +245,7 @@ public class KeyBindingsController extends Controller { * @param message the message to be displayed to the user * @param warning true if the message to be displayed is due to user error */ - public void loadNotification(String message, Boolean warning){ + private void loadNotification(String message, Boolean warning){ try { NotificationController nc = (NotificationController) loadPopupScene("notification.fxml", diff --git a/racevisionGame/src/main/java/visualiser/Controllers/LobbyHostingController.java b/racevisionGame/src/main/java/visualiser/Controllers/LobbyHostingController.java index 9462ad4d..fdbfea6a 100644 --- a/racevisionGame/src/main/java/visualiser/Controllers/LobbyHostingController.java +++ b/racevisionGame/src/main/java/visualiser/Controllers/LobbyHostingController.java @@ -112,8 +112,6 @@ public class LobbyHostingController extends Controller { alert.setHeaderText("You are about to quit the race"); Optional result = alert.showAndWait(); if(result.get() == ButtonType.OK){ -// getStage().close(); -// App.app.loadTitleScreen(); loadTitleScreen(); } } diff --git a/racevisionGame/src/main/java/visualiser/Controllers/RaceViewController.java b/racevisionGame/src/main/java/visualiser/Controllers/RaceViewController.java index 45ce8146..1b787e2f 100644 --- a/racevisionGame/src/main/java/visualiser/Controllers/RaceViewController.java +++ b/racevisionGame/src/main/java/visualiser/Controllers/RaceViewController.java @@ -120,8 +120,6 @@ public class RaceViewController extends Controller { loadTitleScreen(); } } - } catch (IOException e) { - e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); }