Преглед изворни кода

Small changes

- Simplified getDeviceType in MapviewFunctions. 
- Also added an image placeholder if a device type doesn't have an image
- Renamed "edgeVisibleSwitch" as "edgeVisibilitySwitcher" to ensure
consistency
Julian Ohl пре 7 година
родитељ
комит
c1b9519c03

+ 5 - 2
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/ButtonManager.java

@@ -15,6 +15,9 @@ import de.tu_darmstadt.informatik.tk.scopviz.ui.mapView.WorldView;
 import javafx.beans.value.ObservableValue;
 import javafx.event.ActionEvent;
 import javafx.scene.control.Button;
+import javafx.scene.control.TableRow;
+import javafx.scene.control.TableView;
+import javafx.util.Callback;
 
 /**
  * Manager to contain the various handlers for the buttons of the UI.
@@ -184,7 +187,7 @@ public final class ButtonManager {
 
 		// make properties uneditable
 		controller.propertiesObjectColumn.setEditable(false);
-
+		
 		// make map view non mouse transparent
 		controller.stackPane.setMouseTransparent(false);
 		controller.swingNodeWorldView.setMouseTransparent(false);
@@ -216,7 +219,7 @@ public final class ButtonManager {
 	 * @param newVal
 	 *            Checkbox current state (Checked or unchecked)
 	 */
-	public static void edgeVisibleSwitch(ObservableValue<? extends Boolean> ov, Boolean oldVal, Boolean newVal) {
+	public static void edgeVisibilitySwitcher(ObservableValue<? extends Boolean> ov, Boolean oldVal, Boolean newVal) {
 		// Show edges
 		if (newVal) {
 			WorldView.edgePainter.setShowEdges(true);

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

@@ -230,7 +230,7 @@ public class GUIController implements Initializable {
 		symbolToolVBox.setVisible(false);
 
 		edgesVisibleCheckbox.selectedProperty()
-				.addListener((ov, oldVal, newVal) -> ButtonManager.edgeVisibleSwitch(ov, oldVal, newVal));
+				.addListener((ov, oldVal, newVal) -> ButtonManager.edgeVisibilitySwitcher(ov, oldVal, newVal));
 		nodeLabelCheckbox.selectedProperty()
 				.addListener((ov, oldVal, newVal) -> ButtonManager.labelVisibilitySwitcher(ov, oldVal, newVal));
 		edgeWeightCheckbox.selectedProperty()

+ 7 - 51
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/mapView/MapViewFunctions.java

@@ -127,61 +127,17 @@ public final class MapViewFunctions {
 	 * @return
 	 */
 	public static URL getDeviceType(String deviceType) {
-		// TODO add pngs for device types
-		switch (deviceType.equals(null) ? "" : deviceType) {
 
-		case "3G_lte_basestation":
-			return MainApp.class.getResource("/png/symbol_icons/3G_lte_basestation.png");
+		URL image = MainApp.class.getResource("/png/symbol_icons/" + deviceType + ".png");
 
-		case "car":
-			return MainApp.class.getResource("/png/symbol_icons/car.png");
-
-		case "cloud_computing_server":
-			return MainApp.class.getResource("/png/symbol_icons/cloud_computing_server.png");
-
-		case "data_storage":
-			return MainApp.class.getResource("/png/symbol_icons/data_storage.png");
-
-		case "desktop":
-			return MainApp.class.getResource("/png/symbol_icons/desktop.png");
-
-		case "laptop":
-			return MainApp.class.getResource("/png/symbol_icons/laptop.png");
-
-		case "network_middlebox":
-			return MainApp.class.getResource("/png/symbol_icons/network_middlebox.png");
-
-		case "raspberry_pi":
-			return MainApp.class.getResource("/png/symbol_icons/raspberry_pi.png");
-
-		case "router":
-			return MainApp.class.getResource("/png/symbol_icons/router.png");
-
-		case "sensor":
-			return MainApp.class.getResource("/png/symbol_icons/sensor.png");
-
-		case "smart_home":
-			return MainApp.class.getResource("/png/symbol_icons/smart_home.png");
-
-		case "smartband":
-			return MainApp.class.getResource("/png/symbol_icons/smartband.png");
-
-		case "smartphone":
-			return MainApp.class.getResource("/png/symbol_icons/smartphone.png");
-
-		case "smartwatch":
-			return MainApp.class.getResource("/png/symbol_icons/smartwatch.png");
-
-		case "switch":
-			return MainApp.class.getResource("/png/symbol_icons/switch.png");
-
-		case "tablet":
-			return MainApp.class.getResource("/png/symbol_icons/tablet.png");
-
-		default:
-			return MainApp.class.getResource("/png/symbol_icons/unknown.png");
+		if (image == null) {
+			return MainApp.class.getResource("/png/symbol_icons/not_found.png");
+		}
 
+		else {
+			return image;
 		}
+
 	}
 
 	/**

BIN
scopviz/src/main/resources/png/symbol_icons/not_found.png