Browse Source

Mutliple Bug fixes

dominik 7 years ago
parent
commit
b6f0727df9

+ 1 - 5
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/main/MainWindow.fxml

@@ -32,7 +32,7 @@
             <MenuItem fx:id="save" accelerator="Shortcut+S" mnemonicParsing="false" text="Save" />
             <MenuItem fx:id="saveAs" accelerator="Shortcut+Shift+S" mnemonicParsing="false" text="Save As…" />
             <SeparatorMenuItem mnemonicParsing="false" />
-            <MenuItem fx:id="preferences" mnemonicParsing="false" text="Preferences" />
+            <MenuItem fx:id="preferences" accelerator="Shortcut+P" mnemonicParsing="false" text="Preferences" />
             <SeparatorMenuItem mnemonicParsing="false" />
             <MenuItem fx:id="quit" mnemonicParsing="false" text="Quit" />
           </items>
@@ -89,10 +89,6 @@
                                                 <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
                                              </padding>
                                           </CheckBox>
-                                          <ChoiceBox fx:id="mapViewChoiceBox" prefWidth="150.0">
-                                             <VBox.margin>
-                                                <Insets bottom="10.0" left="10.0" right="10.0" />
-                                             </VBox.margin></ChoiceBox>
                                        </children></VBox>
                                 </children>
                               </AnchorPane>

+ 0 - 24
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/ButtonManager.java

@@ -446,28 +446,4 @@ public final class ButtonManager {
 
 		}
 	}
-
-	/**
-	 * update mapViewer if choiceBox item was changed.
-	 * 
-	 * @param ov
-	 *            The observed Value
-	 * @param oldVal
-	 *            Its old Value
-	 * @param newVal
-	 *            Its new Value
-	 */
-	public static void mapViewChoiceChange(ObservableValue<? extends String> ov, String oldVal, String newVal) {
-		MapViewFunctions.changeMapView();
-	}
-
-	/**
-	 * select the given MapType in the ChoiceBox and change Map View
-	 * @param mapType
-	 */
-	public static void switchToMap(String mapType) {
-		controller.mapViewChoiceBox.getSelectionModel().select(mapType);
-		MapViewFunctions.changeMapView();
-	}
-
 }

+ 9 - 14
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/GUIController.java

@@ -163,8 +163,6 @@ public class GUIController implements Initializable {
 	public CheckBox nodeLabelCheckbox;
 	@FXML
 	public CheckBox edgeWeightCheckbox;
-	@FXML
-	public ChoiceBox<String> mapViewChoiceBox;
 
 	@FXML
 	public ScrollPane consoleScrollPane;
@@ -233,8 +231,6 @@ public class GUIController implements Initializable {
 		mapViewer.addMouseListener(new CenterMapListener(mapViewer));
 		// zoom with mousewheel
 		mapViewer.addMouseWheelListener(new ZoomMouseWheelListenerCursor(mapViewer));
-		// TODO make this work
-		mapViewer.addKeyListener(new PanKeyListener(mapViewer));
 		// "Drag map around" Listener
 		MouseInputListener mia = new PanMouseInputListener(mapViewer);
 		mapViewer.addMouseListener(mia);
@@ -289,10 +285,10 @@ public class GUIController implements Initializable {
 
 		centerMap.setOnAction((event) -> ButtonManager.centerMapAction(event));
 
-		defaultMapView.setOnAction((event) -> ButtonManager.switchToMap("Default"));
-		roadMapView.setOnAction((event) -> ButtonManager.switchToMap("Road"));
-		satelliteMapView.setOnAction((event) -> ButtonManager.switchToMap("Satellite"));
-		hybridMapView.setOnAction((event) -> ButtonManager.switchToMap("Hybrid"));
+		defaultMapView.setOnAction((event) -> MapViewFunctions.changeMapView("Default"));
+		roadMapView.setOnAction((event) -> MapViewFunctions.changeMapView("Road"));
+		satelliteMapView.setOnAction((event) -> MapViewFunctions.changeMapView("Satellite"));
+		hybridMapView.setOnAction((event) -> MapViewFunctions.changeMapView("Hybrid"));
 
 		previousWaypoint.setOnAction((event) -> MapViewFunctions.switchToPreviousWaypoint());
 		nextWaypoint.setOnAction((event) -> MapViewFunctions.switchToNextWaypoint());
@@ -322,11 +318,6 @@ public class GUIController implements Initializable {
 		edgeWeightCheckbox.selectedProperty()
 				.addListener((ov, oldVal, newVal) -> ButtonManager.edgeWeightVisibilitySwitcher(ov, oldVal, newVal));
 
-		mapViewChoiceBox.setItems(FXCollections.observableArrayList("Default", "Road", "Satellite", "Hybrid"));
-		mapViewChoiceBox.getSelectionModel().selectFirst();
-		mapViewChoiceBox.getSelectionModel().selectedItemProperty()
-				.addListener((ov, oldVal, newVal) -> ButtonManager.mapViewChoiceChange(ov, oldVal, newVal));
-
 	}
 
 	/**
@@ -387,6 +378,8 @@ public class GUIController implements Initializable {
 		});
 
 		toolbox.getColumns().setAll(toolboxObjectColumn, toolboxStringColumn);
+		
+		//TODO make this work!!!!!!!!!!!!
 
 		toolbox.getSelectionModel().selectedItemProperty()
 				.addListener((ov, oldVal, newVal) -> ToolboxManager.selectedItemChanged(ov, oldVal, newVal));
@@ -395,6 +388,9 @@ public class GUIController implements Initializable {
 		toolbox.setRowFactory(tv -> {
 			TableRow<Pair<Object, String>> row = new TableRow<>();
 			row.setOnMouseClicked((event) -> ToolboxManager.rowClickedHandler(event));
+			row.setOnDragDetected((event) -> {
+			
+			});
 			return row;
 		});
 
@@ -556,7 +552,6 @@ public class GUIController implements Initializable {
 		assert edgesVisibleCheckbox != null : "fx:id=\"edgesVisibleCheckbox\" was not injected: check your FXML file 'MainWindow.fxml'.";
 		assert nodeLabelCheckbox != null : "fx:id=\"nodeLabelCheckbox\" was not injected: check your FXML file 'MainWindow.fxml'.";
 		assert edgeWeightCheckbox != null : "fx:id=\"egdeWeightCheckbox\" was not injected: check your FXML file 'MainWindow.fxml'.";
-		assert mapViewChoiceBox != null : "fx:id=\"mapViewChoiceBox\" was not injected: check your FXML file 'MainWindow.fxml'.";
 
 		assert stackPane != null : "fx:id=\"stackPane\" was not injected: check your FXML file 'MainWindow.fxml'.";
 		assert swingNodeWorldView != null : "fx:id=\"swingNodeWorldView\" was not injected: check your FXML file 'MainWindow.fxml'.";

+ 58 - 10
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/OptionsManager.java

@@ -3,6 +3,10 @@ package de.tu_darmstadt.informatik.tk.scopviz.ui;
 import java.util.ArrayList;
 import java.util.Arrays;
 
+import org.graphstream.ui.graphicGraph.GraphicEdge.EdgeGroup;
+
+import com.sun.prism.paint.Color;
+
 import de.tu_darmstadt.informatik.tk.scopviz.ui.mapView.CustomWaypointRenderer;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.mapView.EdgePainter;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.mapView.MapViewFunctions;
@@ -11,6 +15,7 @@ import javafx.application.Platform;
 import javafx.collections.FXCollections;
 import javafx.collections.ObservableList;
 import javafx.geometry.Insets;
+import javafx.scene.control.Button;
 import javafx.scene.control.ButtonBar.ButtonData;
 import javafx.scene.control.ButtonType;
 import javafx.scene.control.ChoiceBox;
@@ -38,6 +43,25 @@ public final class OptionsManager {
 	private static double defaultLong = 8.654546;
 	/** If the default coordinates have been changed */
 	private static boolean coordinatesChanged = false;
+	
+	/**
+	 * the default device size
+	 */
+	private static int defaultDeviceSize = 50;
+	
+	/**
+	 * the default thickness of edges
+	 */
+	private static int defaultEdgeThickness = 2;
+	
+	/**
+	 * default Color theme in symbol layer
+	 */
+	private static String defaultStandardEdgeColor = "Black";
+	private static String defaultClickedEdgeColor = "Red";
+	private static String defaultPlacementColor = "Blue";
+	private static String defaultStandardDeviceColor = "Black";
+	private static String defaultClickedDeviceColor = "Red";
 
 	/**
 	 * Private Constructor to prevent Instantiation.
@@ -52,7 +76,7 @@ public final class OptionsManager {
 		// Create new Dialog
 		Dialog<ArrayList<String>> addPropDialog = new Dialog<>();
 		addPropDialog.setTitle("Preferences");
-
+		
 		ButtonType addButtonType = new ButtonType("save & exit", ButtonData.OK_DONE);
 		addPropDialog.getDialogPane().getButtonTypes().addAll(addButtonType, ButtonType.CANCEL);
 
@@ -102,7 +126,27 @@ public final class OptionsManager {
 		
 		TextField edgeThickness = new TextField(Integer.toString(EdgePainter.getThickness()));
 		
-		TextField waypointSize = new TextField(Integer.toString(CustomWaypointRenderer.getWaypointSize()));
+		TextField deviceSize = new TextField(Integer.toString(CustomWaypointRenderer.getDeviceSize()));
+		
+		Button resetButton = new Button("Reset");
+		resetButton.setOnAction((event) -> {
+
+			edgeThickness.setText(Integer.toString(defaultEdgeThickness));
+			EdgePainter.setEdgeThickness(defaultEdgeThickness);
+			
+			deviceSize.setText(Integer.toString(defaultDeviceSize));
+			CustomWaypointRenderer.setScaleSize(defaultDeviceSize);
+			
+			edgeStandardColorSymbolLayer.getSelectionModel().select(defaultStandardEdgeColor);
+			edgePlacementColorSymbolLayer.getSelectionModel().select(defaultPlacementColor);
+			edgeSelectedColorSymbolLayer.getSelectionModel().select(defaultClickedEdgeColor);
+			EdgePainter.setColor(defaultStandardEdgeColor, defaultPlacementColor, defaultClickedEdgeColor);
+			
+			waypointStandardColorSymbolLayer.getSelectionModel().select(defaultStandardDeviceColor);
+			waypointSelectedColorSymbolLayer.getSelectionModel().select(defaultClickedDeviceColor);
+			CustomWaypointRenderer.setColor(defaultStandardDeviceColor, defaultClickedDeviceColor);
+			
+		});
 
 		// position elements on grid
 		int row = 0;
@@ -131,12 +175,13 @@ public final class OptionsManager {
 		// symbol layer stuff
 		grid.add(new Label(""), 1, row); row++;
 		grid.add(new Label("Symbol-Layer Options"), 1, row); row++;
-		grid.add(new Label("Waypoint Size (int):"), 0, row);
-		grid.add(waypointSize, 1, row); row++;
+		grid.add(new Label("Device Size (int):"), 0, row);
+		grid.add(deviceSize, 1, row); row++;
 		
 		grid.add(new Label("Edge thickness (int):"), 0, row);
 		grid.add(edgeThickness, 1, row); row++;
 		
+		grid.add(new Label(""), 1, row); row++;
 		grid.add(new Label("Edge Colors"), 1, row); row++;
 		grid.add(new Label("Standard Edge Color"), 0, row);
 		grid.add(edgeStandardColorSymbolLayer, 1, row); row++;
@@ -147,12 +192,15 @@ public final class OptionsManager {
 		grid.add(new Label("Placement Edge Color"), 0, row);
 		grid.add(edgePlacementColorSymbolLayer, 1, row); row++;
 		
-		grid.add(new Label("Waypoint Colors"), 1, row); row++;
-		grid.add(new Label("Standard Waypoint Color"), 0, row);
+		grid.add(new Label("Device Colors"), 1, row); row++;
+		grid.add(new Label("Standard Device Color"), 0, row);
 		grid.add(waypointStandardColorSymbolLayer, 1, row); row++;
 		
-		grid.add(new Label("Clicked Waypoint Color"), 0, row);
-		grid.add(waypointSelectedColorSymbolLayer, 1, row);
+		grid.add(new Label("Clicked Device Color"), 0, row);
+		grid.add(waypointSelectedColorSymbolLayer, 1, row); row++;
+		
+		grid.add(new Label(""), 1, row); row++;
+		grid.add(resetButton, 1, row);
 
 		// set dialog
 		addPropDialog.getDialogPane().setContent(grid);
@@ -176,8 +224,8 @@ public final class OptionsManager {
 						EdgePainter.setEdgeThickness(Integer.parseInt(edgeThickness.getText()));
 					}
 					// symbol layer waypoint size
-					if(Integer.parseInt(waypointSize.getText()) != CustomWaypointRenderer.getWaypointSize()) {
-						CustomWaypointRenderer.setScaleSize(Integer.parseInt(waypointSize.getText()));
+					if(Integer.parseInt(deviceSize.getText()) != CustomWaypointRenderer.getDeviceSize()) {
+						CustomWaypointRenderer.setScaleSize(Integer.parseInt(deviceSize.getText()));
 						MapViewFunctions.resetImageMap();
 						MapViewFunctions.initializeWaypointImages();
 					}

+ 26 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/handlers/KeyboardShortcuts.java

@@ -1,5 +1,10 @@
 package de.tu_darmstadt.informatik.tk.scopviz.ui.handlers;
 
+import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
+import de.tu_darmstadt.informatik.tk.scopviz.ui.GraphDisplayManager;
+import de.tu_darmstadt.informatik.tk.scopviz.ui.MenuBarManager;
+import de.tu_darmstadt.informatik.tk.scopviz.ui.mapView.MapViewFunctions;
+import javafx.event.ActionEvent;
 import javafx.event.EventHandler;
 import javafx.scene.input.KeyCode;
 import javafx.scene.input.KeyCodeCombination;
@@ -21,6 +26,11 @@ public final class KeyboardShortcuts {
 	final static KeyCombination rCtrl = new KeyCodeCombination(KeyCode.M, KeyCombination.CONTROL_DOWN);
 	final static KeyCombination rCtrlShift = new KeyCodeCombination(KeyCode.R, KeyCombination.CONTROL_DOWN,
 			KeyCombination.SHIFT_DOWN);
+	
+	/**
+	 * preferences shortcut
+	 */
+	final static KeyCombination pCtrl = new KeyCodeCombination(KeyCode.P, KeyCombination.CONTROL_DOWN);
 
 	/**
 	 * Private constructor to prevent Instantiation.
@@ -55,6 +65,22 @@ public final class KeyboardShortcuts {
 			else if (rCtrlShift.match(event)) {
 				System.out.println("Ctrl+Shift+R pressed");
 			}
+			
+			else if (pCtrl.match(event)) {
+				MenuBarManager.preferencesAction(new ActionEvent());
+			}
+			
+			else if (event.getCode().equals(KeyCode.RIGHT)) {
+				if (GraphDisplayManager.getCurrentLayer().equals(Layer.SYMBOL)) {
+					MapViewFunctions.switchToNextWaypoint();
+				}
+			}
+			
+			else if (event.getCode().equals(KeyCode.LEFT)) {
+				if (GraphDisplayManager.getCurrentLayer().equals(Layer.SYMBOL)) {
+					MapViewFunctions.switchToPreviousWaypoint();
+				}
+			}
 
 		}
 	};

+ 4 - 2
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/mapView/CustomMapClickListener.java

@@ -81,6 +81,8 @@ public class CustomMapClickListener extends MapClickListener {
 	 */
 	public Boolean checkWaypointClicked(Point2D clickedPoint, Boolean wayPointSelected) {
 		Point2D nodePoint;
+		
+		int pictureSize = CustomWaypointRenderer.SCALEWIDTH;
 
 		for (CustomWaypoint nodeWaypoint : CustomMapClickListener.waypoints) {
 			// transform GeoPosition to point on screen
@@ -92,13 +94,13 @@ public class CustomMapClickListener extends MapClickListener {
 			// clicked position is in range of 50 pixel above the waypoint
 			// position
 			double deltaY = clickedPoint.getY() - nodePoint.getY();
-			if (deltaY > -50 && deltaY < 0) {
+			if (deltaY > -pictureSize && deltaY < 0) {
 				yChecked = true;
 			}
 
 			// clicked Position is in x- and y-range of wapoint position (in
 			// range of 50 pixels)
-			if (Math.abs(clickedPoint.getX() - nodePoint.getX()) < 25 && yChecked) {
+			if (Math.abs(clickedPoint.getX() - nodePoint.getX()) < (pictureSize / 2) && yChecked) {
 
 				wayPointSelected = true;
 

+ 1 - 1
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/mapView/CustomWaypointRenderer.java

@@ -131,7 +131,7 @@ public class CustomWaypointRenderer implements WaypointRenderer<CustomWaypoint>
 	/**
 	 * @return waypoint size after scaling it
 	 */
-	public static int getWaypointSize() {
+	public static int getDeviceSize() {
 		return SCALEWIDTH;
 	}
 

+ 16 - 6
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/mapView/MapViewFunctions.java

@@ -44,7 +44,15 @@ public final class MapViewFunctions {
 	public static HashMap<String, BufferedImage> imageMap = new HashMap<String, BufferedImage>(
 			WorldView.waypoints.size());
 
+	/**
+	 * the waypoints represented as an ordered list
+	 */
 	private static ArrayList<CustomWaypoint> waypointsAsList = new ArrayList<CustomWaypoint>();
+	
+	/**
+	 * the selected mapType "Default", "Road", "Satellite", "Hybrid"
+	 */
+	private static String mapType = "Default";
 
 	/**
 	 * private constructor to avoid instantiation
@@ -244,10 +252,12 @@ public final class MapViewFunctions {
 	}
 
 	/**
-	 * change the shown map based on the selected item in the ChoiceBox
+	 * change the shown map based on the given string
+	 * @param string 
 	 */
-	public static void changeMapView() {
-		String selected = WorldView.controller.mapViewChoiceBox.getSelectionModel().getSelectedItem();
+	public static void changeMapView(String selected) {
+		
+		mapType = selected;
 
 		switch (selected) {
 		case "Default":
@@ -274,7 +284,7 @@ public final class MapViewFunctions {
 	}
 
 	/**
-	 * Check if Checkboxes or ChoiceBox where changed, last time symbol-rep.
+	 * Check if Checkboxes or mapType where changed, last time symbol-rep.
 	 * layer was shown
 	 */
 	public static void checkVBoxChanged() {
@@ -295,8 +305,8 @@ public final class MapViewFunctions {
 		if (!WorldView.controller.edgeWeightCheckbox.isSelected()) {
 			edgePainter.setShowWeights(false);
 		}
-		if (!WorldView.controller.mapViewChoiceBox.getSelectionModel().getSelectedItem().equals("Default")) {
-			MapViewFunctions.changeMapView();
+		if (!mapType.equals("Default")) {
+			changeMapView(mapType);
 		}
 	}