浏览代码

Merged Dominik

Jan Enders 8 年之前
父节点
当前提交
965d79cfec

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

@@ -33,7 +33,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>
@@ -92,10 +92,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>

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

@@ -5,6 +5,7 @@ import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.stream.Collectors;
 
+import org.graphstream.graph.implementations.Graphs;
 import org.jxmapviewer.viewer.GeoPosition;
 import org.jxmapviewer.viewer.WaypointPainter;
 
@@ -263,6 +264,7 @@ public final class ButtonManager {
 	 */
 	public static void symbolRepAction(ActionEvent arg0) {
 		Main.getInstance().getGraphManager().deselectEdgeCreationNodes();
+		PropertiesManager.showNewDataSet(null);
 
 		if (!(GraphDisplayManager.getCurrentLayer().equals(Layer.SYMBOL))) {
 
@@ -473,7 +475,7 @@ public final class ButtonManager {
 	 * @param newVal
 	 *            Its new Value
 	 */
-	public static void mapViewChoiceChange(ObservableValue<? extends String> ov, String oldVal, String newVal) {
+/*	public static void mapViewChoiceChange(ObservableValue<? extends String> ov, String oldVal, String newVal) {
 		MapViewFunctions.changeMapView();
 	}
 
@@ -482,11 +484,11 @@ public final class ButtonManager {
 	 * 
 	 * @param mapType
 	 */
-	public static void switchToMap(String mapType) {
+/*	public static void switchToMap(String mapType) {
 		controller.mapViewChoiceBox.getSelectionModel().select(mapType);
 		MapViewFunctions.changeMapView();
 	}
-
+*/
 	public static void setupOpGraphComboBox() {
 		controller.opGraphSelectionBox.getItems().clear();
 		GraphManager operatorManager = GraphDisplayManager.getGraphManager(Layer.OPERATOR);

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

@@ -171,8 +171,6 @@ public class GUIController implements Initializable {
 	public CheckBox nodeLabelCheckbox;
 	@FXML
 	public CheckBox edgeWeightCheckbox;
-	@FXML
-	public ChoiceBox<String> mapViewChoiceBox;
 
 	@FXML
 	public VBox rightSide;
@@ -247,8 +245,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);
@@ -304,10 +300,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());
@@ -337,11 +333,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));
-
 	}
 
 	/**
@@ -402,6 +393,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));
@@ -410,6 +403,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;
 		});
 
@@ -605,7 +601,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'.";

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

@@ -12,6 +12,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;
@@ -39,6 +40,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.
@@ -110,7 +130,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;
@@ -141,14 +181,16 @@ public final class OptionsManager {
 		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);
+		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++;
-
+		//TODO: This line might be unneccesary
+		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);
@@ -163,14 +205,17 @@ public final class OptionsManager {
 		grid.add(edgePlacementColorSymbolLayer, 1, row);
 		row++;
 
-		grid.add(new Label("Waypoint Colors"), 1, row);
+		grid.add(new Label("Device Colors"), 1, row);
 		row++;
-		grid.add(new Label("Standard Waypoint Color"), 0, 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++;
+		//TODO: unnecessary?
+		grid.add(new Label(""), 1, row); row++;
+		grid.add(resetButton, 1, row);
 
 		row++;
 		grid.add(new Label("Logging level"), 0, row);
@@ -199,8 +244,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();
 					}

+ 24 - 6
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/PropertiesManager.java

@@ -22,6 +22,7 @@ import javafx.collections.ObservableList;
 import javafx.event.EventHandler;
 import javafx.geometry.Insets;
 import javafx.scene.control.ButtonBar.ButtonData;
+import javafx.scene.control.Alert;
 import javafx.scene.control.ButtonType;
 import javafx.scene.control.ChoiceBox;
 import javafx.scene.control.ContextMenu;
@@ -32,6 +33,7 @@ import javafx.scene.control.TableColumn.CellEditEvent;
 import javafx.scene.control.TableRow;
 import javafx.scene.control.TableView;
 import javafx.scene.control.TextField;
+import javafx.scene.control.Alert.AlertType;
 import javafx.scene.layout.GridPane;
 import javafx.util.Callback;
 
@@ -218,8 +220,8 @@ public final class PropertiesManager {
 			final MenuItem onlyAddPropMenuItem = new MenuItem("Add..");
 
 			// add functionality
-			onlyAddPropMenuItem.setOnAction((event) -> addPropFunctionality());
-			addPropMenuItem.setOnAction((event) -> addPropFunctionality());
+			onlyAddPropMenuItem.setOnAction((event) -> addPropFunctionality(null));
+			addPropMenuItem.setOnAction((event) -> addPropFunctionality(null));
 
 			// delete functionality
 			deletePropMenuItem.setOnAction((event) -> {
@@ -447,13 +449,19 @@ public final class PropertiesManager {
 	/**
 	 * TODO Auslagern contextMenu add button functionality.
 	 */
-	private static void addPropFunctionality() {
+	private static void addPropFunctionality(String preConfigPropName) {
 		Debug.out("Add Element");
 
 		// Create new Dialog
 		Dialog<ArrayList<String>> addPropDialog = new Dialog<>();
 		addPropDialog.setTitle("Add Property");
 		addPropDialog.setHeaderText("Choose your Property Details");
+		
+		// Alert window -> when problems with input
+		Alert alert = new Alert(AlertType.WARNING);
+		alert.setTitle("Property-Type Alert");
+		alert.setHeaderText("The selected Type doesnt fit the Input");
+		alert.setContentText(null);
 
 		ButtonType addButtonType = new ButtonType("Confirm", ButtonData.OK_DONE);
 		addPropDialog.getDialogPane().getButtonTypes().addAll(addButtonType, ButtonType.CANCEL);
@@ -487,6 +495,12 @@ public final class PropertiesManager {
 
 		nameSet = false;
 		valueSet = false;
+		
+		// show pre defined property name
+		if(preConfigPropName != null){
+			name.setText(preConfigPropName);
+			PropertiesManager.nameSet = true;
+		}
 
 		// hide confirm button, when textfields empty
 		name.textProperty().addListener((observable, oldValue, newValue) -> {
@@ -535,11 +549,11 @@ public final class PropertiesManager {
 
 			Element selected = getSelected();
 
-			if (t.get(2).equals("Integer")) {
+			if (t.get(2).equals("Integer") && t.get(1).matches(IS_INT)) {
 				selected.addAttribute(t.get(0), Integer.valueOf(t.get(1)));
 				GraphHelper.propagateAttribute(Main.getInstance().getGraphManager().getGraph()
 						, selected, t.get(0), Integer.valueOf(t.get(1)));
-			} else if (t.get(2).equals("Float")) {
+			} else if (t.get(2).equals("Float") && t.get(1).matches(IS_FLOAT)) {
 				selected.addAttribute(t.get(0), Float.valueOf(t.get(1)));
 				GraphHelper.propagateAttribute(Main.getInstance().getGraphManager().getGraph()
 						, selected, t.get(0), Float.valueOf(t.get(1)));
@@ -547,10 +561,14 @@ public final class PropertiesManager {
 				selected.addAttribute(t.get(0), String.valueOf(t.get(1)));
 				GraphHelper.propagateAttribute(Main.getInstance().getGraphManager().getGraph()
 						, selected, t.get(0), String.valueOf(t.get(1)));
-			} else if (t.get(2).equals("Boolean")) {
+			} else if (t.get(2).equals("Boolean")&& t.get(1).matches(IS_BOOL)) {
 				selected.addAttribute(t.get(0), Boolean.valueOf(t.get(1)));
 				GraphHelper.propagateAttribute(Main.getInstance().getGraphManager().getGraph()
 						, selected, t.get(0), Boolean.valueOf(t.get(1)));
+			} else {
+				// type doesnt fit input -> show alert and re-open property creation window
+				alert.showAndWait();
+				addPropFunctionality(t.get(0));
 			}
 
 			showNewDataSet(selected);

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

@@ -1,7 +1,11 @@
 package de.tu_darmstadt.informatik.tk.scopviz.ui.handlers;
 
 import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
+import de.tu_darmstadt.informatik.tk.scopviz.ui.GraphDisplayManager;
 import de.tu_darmstadt.informatik.tk.scopviz.main.CreationMode;
+import de.tu_darmstadt.informatik.tk.scopviz.ui.MenuBarManager;
+import de.tu_darmstadt.informatik.tk.scopviz.ui.mapView.MapViewFunctions;
+import javafx.event.ActionEvent;
 import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
 import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.GUIController;
@@ -31,6 +35,11 @@ public final class KeyboardShortcuts {
 	final static KeyCombination mShift = new KeyCodeCombination(KeyCode.M, KeyCombination.SHIFT_DOWN);
 	final static KeyCombination rAltShift = new KeyCodeCombination(KeyCode.R, KeyCombination.ALT_DOWN,
 			KeyCombination.SHIFT_DOWN);
+	
+	/**
+	 * preferences shortcut
+	 */
+	final static KeyCombination pCtrl = new KeyCodeCombination(KeyCode.P, KeyCombination.CONTROL_DOWN);
 
 	/**
 	 * Private constructor to prevent Instantiation.
@@ -108,6 +117,22 @@ public final class KeyboardShortcuts {
 				}
 
 			}
+			
+			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

@@ -82,6 +82,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
 			nodePoint = CustomMapClickListener.viewer.getTileFactory().geoToPixel(nodeWaypoint.getPosition(),
@@ -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;
 

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

@@ -57,7 +57,7 @@ public class CustomWaypointRenderer implements WaypointRenderer<CustomWaypoint>
 		BufferedImage loadedImg = MapViewFunctions.imageMap.get(w.getDeviceType());
 
 		// standard color has been changed
-		if (!getStandardColor().equals(Color.BLACK)) {
+		if (!STANDARD.equals(Color.BLACK)) {
 			loadedImg = MapViewFunctions.colorImage(loadedImg, Color.BLACK, CustomWaypointRenderer.STANDARD,
 					CustomWaypointRenderer.ALPHA);
 		}
@@ -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;
 	}
 

+ 29 - 106
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/mapView/MapViewFunctions.java

@@ -3,31 +3,20 @@ package de.tu_darmstadt.informatik.tk.scopviz.ui.mapView;
 import java.awt.Color;
 import java.awt.Graphics2D;
 import java.awt.image.BufferedImage;
-import java.net.URL;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.HashSet;
 
 import javax.imageio.ImageIO;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.graphstream.graph.Edge;
-import org.graphstream.graph.Node;
 import org.jxmapviewer.JXMapViewer;
 import org.jxmapviewer.OSMTileFactoryInfo;
 import org.jxmapviewer.VirtualEarthTileFactoryInfo;
 import org.jxmapviewer.painter.Painter;
-import org.jxmapviewer.viewer.GeoPosition;
 import org.jxmapviewer.viewer.TileFactoryInfo;
 import org.jxmapviewer.viewer.WaypointPainter;
 
-import de.tu_darmstadt.informatik.tk.scopviz.graphs.GraphManager;
-import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
 import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
-import de.tu_darmstadt.informatik.tk.scopviz.main.MainApp;
-import de.tu_darmstadt.informatik.tk.scopviz.ui.GraphDisplayManager;
-import de.tu_darmstadt.informatik.tk.scopviz.ui.PropertiesManager;
 import javafx.beans.binding.Bindings;
 import javafx.scene.control.CheckBox;
 import javafx.scene.control.ContextMenu;
@@ -44,7 +33,10 @@ public final class MapViewFunctions {
 	public static HashMap<String, BufferedImage> imageMap = new HashMap<String, BufferedImage>(
 			WorldView.waypoints.size());
 
-	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
@@ -65,7 +57,9 @@ public final class MapViewFunctions {
 	 */
 	public static void initializeWaypointImages() {
 
-		for (CustomWaypoint w : WorldView.waypoints) {
+		imageMap = new HashMap<String, BufferedImage>(WorldView.waypoints.size());
+
+		for (CustomWaypoint w : WorldView.getWaypoints()) {
 
 			BufferedImage origImage = null;
 
@@ -144,81 +138,6 @@ public final class MapViewFunctions {
 		return imgOut;
 	}
 
-	/**
-	 * Initialize HashSets with data from graph
-	 * 
-	 * @param nodePositions
-	 *            Read node data to create GeoPositions of all nodes
-	 * @param waypoints
-	 *            Read node data to create CustomWaypoints with deviceTypes
-	 */
-	public static void fetchGraphData(HashSet<GeoPosition> nodePositions, HashSet<CustomWaypoint> waypoints,
-			HashSet<Edge> edges) {
-
-		GraphManager man = GraphDisplayManager.getGraphManager(Layer.UNDERLAY);
-
-		// add all edges from the Graph to the HashSet
-		for (Edge edge : man.getGraph().getEdgeSet()) {
-			edges.add(edge);
-		}
-
-		// fetch all needed data from nodes
-		for (Node node : man.getGraph().getEachNode()) {
-
-			if (node.hasAttribute("lat") && node.hasAttribute("long")) {
-
-				// Fetch all geo-data from nodes
-				Double latitude = node.getAttribute("lat");
-				Double longitude = node.getAttribute("long");
-
-				GeoPosition geoPos = new GeoPosition(latitude.doubleValue(), longitude.doubleValue());
-
-				nodePositions.add(geoPos);
-
-				// Create waypoints with device type dependent pictures
-				String deviceType = (String) node.getAttribute("typeofDevice");
-				URL resource = getDeviceTypeURL(deviceType);
-
-				// create a new waypoint with the node information
-				CustomWaypoint waypoint = new CustomWaypoint(node.getAttribute("ui.label"), node.getId(), resource,
-						deviceType, geoPos);
-
-				waypoints.add(waypoint);
-
-				waypointsAsList.add(waypoint);
-			}
-		}
-
-		// deselect all previously clicked waypoints or edges
-		PropertiesManager.showNewDataSet(null);
-
-		// load and save waypoint images
-		MapViewFunctions.initializeWaypointImages();
-
-	}
-
-	/**
-	 * get the png URL based on the device.type of nodes
-	 * 
-	 * @param deviceType
-	 * @return
-	 */
-	public static URL getDeviceTypeURL(String deviceType) {
-
-		URL image = MainApp.class
-				.getResource("/de/tu_darmstadt/informatik/tk/scopviz/ui/mapView/symbol_icons/" + deviceType + ".png");
-
-		if (image == null) {
-			return MainApp.class
-					.getResource("/de/tu_darmstadt/informatik/tk/scopviz/ui/mapView/symbol_icons/not_found.png");
-		}
-
-		else {
-			return image;
-		}
-
-	}
-
 	/**
 	 * Returns either an EdgePainter (case input "edge") or a WaypointPainter
 	 * (case input "waypoint") based on input
@@ -244,10 +163,13 @@ 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,8 +196,8 @@ public final class MapViewFunctions {
 	}
 
 	/**
-	 * Check if Checkboxes or ChoiceBox where changed, last time symbol-rep.
-	 * layer was shown
+	 * Check if Checkboxes or mapType where changed, last time symbol-rep. layer
+	 * was shown
 	 */
 	public static void checkVBoxChanged() {
 
@@ -295,8 +217,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);
 		}
 	}
 
@@ -370,16 +292,17 @@ public final class MapViewFunctions {
 
 		CustomWaypoint selectedWaypoint = CustomMapClickListener.selectedNode;
 
-		if (selectedWaypoint == null && waypointsAsList.size() > 0) {
-			CustomMapClickListener.selectWaypoint(waypointsAsList.get(0));
+		if (selectedWaypoint == null && WorldView.waypointsAsList.size() > 0) {
+			CustomMapClickListener.selectWaypoint(WorldView.waypointsAsList.get(0));
 
 		} else {
-			int index = waypointsAsList.indexOf(selectedWaypoint);
+			int index = WorldView.waypointsAsList.indexOf(selectedWaypoint);
 
 			if (index == 0) {
-				CustomMapClickListener.selectWaypoint(waypointsAsList.get(waypointsAsList.size() - 1));
+				CustomMapClickListener
+						.selectWaypoint(WorldView.waypointsAsList.get(WorldView.waypointsAsList.size() - 1));
 			} else {
-				CustomMapClickListener.selectWaypoint(waypointsAsList.get(index - 1));
+				CustomMapClickListener.selectWaypoint(WorldView.waypointsAsList.get(index - 1));
 			}
 		}
 	}
@@ -391,16 +314,16 @@ public final class MapViewFunctions {
 
 		CustomWaypoint selectedWaypoint = CustomMapClickListener.selectedNode;
 
-		if (selectedWaypoint == null && waypointsAsList.size() > 0) {
-			CustomMapClickListener.selectWaypoint(waypointsAsList.get(0));
+		if (selectedWaypoint == null && WorldView.waypointsAsList.size() > 0) {
+			CustomMapClickListener.selectWaypoint(WorldView.waypointsAsList.get(0));
 
 		} else {
-			int index = waypointsAsList.indexOf(selectedWaypoint);
+			int index = WorldView.waypointsAsList.indexOf(selectedWaypoint);
 
-			if (index == waypointsAsList.size() - 1) {
-				CustomMapClickListener.selectWaypoint(waypointsAsList.get(0));
+			if (index == WorldView.waypointsAsList.size() - 1) {
+				CustomMapClickListener.selectWaypoint(WorldView.waypointsAsList.get(0));
 			} else {
-				CustomMapClickListener.selectWaypoint(waypointsAsList.get(index + 1));
+				CustomMapClickListener.selectWaypoint(WorldView.waypointsAsList.get(index + 1));
 			}
 		}
 

+ 109 - 24
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/mapView/WorldView.java

@@ -10,6 +10,7 @@ import java.util.HashSet;
 import java.util.List;
 
 import org.graphstream.graph.Edge;
+import org.graphstream.graph.Node;
 import org.jxmapviewer.JXMapViewer;
 import org.jxmapviewer.OSMTileFactoryInfo;
 import org.jxmapviewer.painter.CompoundPainter;
@@ -18,7 +19,11 @@ import org.jxmapviewer.viewer.GeoPosition;
 import org.jxmapviewer.viewer.TileFactoryInfo;
 import org.jxmapviewer.viewer.WaypointPainter;
 
+import de.tu_darmstadt.informatik.tk.scopviz.graphs.GraphManager;
+import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
+import de.tu_darmstadt.informatik.tk.scopviz.main.MainApp;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.GUIController;
+import de.tu_darmstadt.informatik.tk.scopviz.ui.GraphDisplayManager;
 import javafx.geometry.Rectangle2D;
 
 public class WorldView {
@@ -53,11 +58,18 @@ public class WorldView {
 	 */
 	public static HashSet<CustomWaypoint> waypoints;
 
+	/**
+	 * the waypoints represented as an ordered list
+	 */
+	public static ArrayList<CustomWaypoint> waypointsAsList;
+
 	/*
 	 * All edges in the WorldView
 	 */
 	public static HashSet<Edge> edges;
 
+	public static HashSet<GeoPosition> nodePositions;
+
 	/*
 	 * All painter in symbolLayer stored in a list
 	 */
@@ -87,30 +99,28 @@ public class WorldView {
 	 */
 	public static void loadWorldView() throws IOException {
 
-		HashSet<GeoPosition> nodePositions = new HashSet<GeoPosition>();
+		nodePositions = new HashSet<GeoPosition>();
 		waypoints = new HashSet<CustomWaypoint>();
 		edges = new HashSet<Edge>();
+		waypointsAsList = new ArrayList<CustomWaypoint>();
 
 		// Get GeoPositions of nodes and get all waypoints created
-		MapViewFunctions.fetchGraphData(nodePositions, waypoints, edges);
+		fetchGraphData();
 
-		if (edgePainter == null)
-			// Create a line for all edges
-			edgePainter = new EdgePainter(edges);
+		MapViewFunctions.initializeWaypointImages();
 
-		if (waypointPainter == null) {
-			// Create a waypoint painter that takes all the waypoints
-			waypointPainter = new WaypointPainter<CustomWaypoint>();
-			waypointPainter.setWaypoints(waypoints);
-			waypointPainter.setRenderer(new CustomWaypointRenderer());
-		}
+		// Create a line for all edges
+		edgePainter = new EdgePainter(edges);
 
-		if (painters == null) {
-			// Create a compound painter that uses all painters
-			painters = new ArrayList<Painter<JXMapViewer>>();
-			painters.add(edgePainter);
-			painters.add(waypointPainter);
-		}
+		// Create a waypoint painter that takes all the waypoints
+		waypointPainter = new WaypointPainter<CustomWaypoint>();
+		waypointPainter.setWaypoints(waypoints);
+		waypointPainter.setRenderer(new CustomWaypointRenderer());
+
+		// Create a compound painter that uses all painters
+		painters = new ArrayList<Painter<JXMapViewer>>();
+		painters.add(edgePainter);
+		painters.add(waypointPainter);
 
 		CompoundPainter<JXMapViewer> painter = new CompoundPainter<JXMapViewer>(painters);
 
@@ -127,19 +137,23 @@ public class WorldView {
 
 		showAllWaypoints(nodePositions);
 
-		// set Zoom and Center to show all node positions
-		// internMapViewer.zoomToBestFit(nodePositions, 1);
-
-		if (internMapViewer.getOverlayPainter() == null) {
-			internMapViewer.setOverlayPainter(painter);
-		}
+		internMapViewer.setOverlayPainter(painter);
 
+		// set listener the first time
 		if (mapClickListener == null) {
 			mapClickListener = new CustomMapClickListener(internMapViewer);
 
 			// "click on waypoints" listener
 			internMapViewer.addMouseListener(mapClickListener);
 		}
+		// update listener
+		else {
+			internMapViewer.removeMouseListener(mapClickListener);
+
+			mapClickListener = new CustomMapClickListener(internMapViewer);
+
+			internMapViewer.addMouseListener(mapClickListener);
+		}
 
 		internMapViewer.repaint();
 
@@ -153,7 +167,6 @@ public class WorldView {
 			connection.connect();
 
 		} catch (MalformedURLException e) {
-			// TODO add Dialog with eroor msg and stack trace
 			e.printStackTrace();
 
 		}
@@ -207,4 +220,76 @@ public class WorldView {
 
 	}
 
+	/**
+	 * Initialize HashSets with data from graph
+	 * 
+	 * @param nodePositions
+	 *            Read node data to create GeoPositions of all nodes
+	 * @param waypoints
+	 *            Read node data to create CustomWaypoints with deviceTypes
+	 */
+	public static void fetchGraphData() {
+
+		GraphManager man = GraphDisplayManager.getGraphManager(Layer.UNDERLAY);
+
+		// add all edges from the Graph to the HashSet
+		for (Edge edge : man.getGraph().getEdgeSet()) {
+			edges.add(edge);
+		}
+
+		// fetch all needed data from nodes
+		for (Node node : man.getGraph().getEachNode()) {
+
+			if (node.hasAttribute("lat") && node.hasAttribute("long")) {
+
+				// Fetch all geo-data from nodes
+				Double latitude = node.getAttribute("lat");
+				Double longitude = node.getAttribute("long");
+
+				GeoPosition geoPos = new GeoPosition(latitude.doubleValue(), longitude.doubleValue());
+
+				nodePositions.add(geoPos);
+
+				// Create waypoints with device type dependent pictures
+				String deviceType = (String) node.getAttribute("typeofDevice");
+				URL resource = getDeviceTypeURL(deviceType);
+
+				// create a new waypoint with the node information
+				CustomWaypoint waypoint = new CustomWaypoint(node.getAttribute("ui.label"), node.getId(), resource,
+						deviceType, geoPos);
+
+				waypoints.add(waypoint);
+
+				waypointsAsList.add(waypoint);
+			}
+		}
+
+	}
+
+	/**
+	 * get the png URL based on the device.type of nodes
+	 * 
+	 * @param deviceType
+	 * @return
+	 */
+	public static URL getDeviceTypeURL(String deviceType) {
+
+		URL image = MainApp.class
+				.getResource("/de/tu_darmstadt/informatik/tk/scopviz/ui/mapView/symbol_icons/" + deviceType + ".png");
+
+		if (image == null) {
+			return MainApp.class
+					.getResource("/de/tu_darmstadt/informatik/tk/scopviz/ui/mapView/symbol_icons/not_found.png");
+		}
+
+		else {
+			return image;
+		}
+
+	}
+
+	public static HashSet<CustomWaypoint> getWaypoints() {
+		return waypoints;
+	}
+
 }