Browse Source

Updated Symbol-Representation

added map types 
added properties selection
fixed some bugs
dominik 8 years ago
parent
commit
68eb0af026

+ 130 - 19
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/ButtonManager.java

@@ -7,16 +7,21 @@ import java.util.List;
 
 import javax.swing.event.MouseInputListener;
 
+import org.graphstream.graph.Edge;
 import org.graphstream.graph.Node;
 import org.graphstream.graph.implementations.Graphs;
 import org.jxmapviewer.JXMapViewer;
+import org.jxmapviewer.OSMTileFactoryInfo;
+import org.jxmapviewer.VirtualEarthTileFactoryInfo;
 import org.jxmapviewer.input.CenterMapListener;
 import org.jxmapviewer.input.PanKeyListener;
 import org.jxmapviewer.input.PanMouseInputListener;
 import org.jxmapviewer.input.ZoomMouseWheelListenerCursor;
 import org.jxmapviewer.painter.CompoundPainter;
 import org.jxmapviewer.painter.Painter;
+import org.jxmapviewer.viewer.DefaultTileFactory;
 import org.jxmapviewer.viewer.GeoPosition;
+import org.jxmapviewer.viewer.TileFactoryInfo;
 import org.jxmapviewer.viewer.WaypointPainter;
 
 import de.tu_darmstadt.informatik.tk.scopviz.main.GraphManager;
@@ -26,7 +31,13 @@ import de.tu_darmstadt.informatik.tk.scopviz.main.MainApp;
 import de.tu_darmstadt.informatik.tk.scopviz.main.MyGraph;
 import javafx.beans.value.ObservableValue;
 import javafx.event.ActionEvent;
+import javafx.geometry.Insets;
 import javafx.scene.control.Button;
+import javafx.scene.control.ButtonBar.ButtonData;
+import javafx.scene.control.ButtonType;
+import javafx.scene.control.Dialog;
+import javafx.scene.control.Label;
+import javafx.scene.layout.GridPane;
 
 /**
  * Manager to contain the various handlers for the buttons of the UI.
@@ -47,6 +58,8 @@ public final class ButtonManager {
 
 	private static JXMapViewer internMapViewer;
 
+	private static Boolean hostReachable = true;
+
 	/**
 	 * Private Constructor to prevent Instantiation.
 	 */
@@ -70,7 +83,7 @@ public final class ButtonManager {
 	 * Handler for zoom in Button
 	 */
 	public static final void zoomInAction(ActionEvent event) {
-		if(GraphDisplayManager.getCurrentLayer().equals(Layer.SYMBOL)){
+		if (GraphDisplayManager.getCurrentLayer().equals(Layer.SYMBOL)) {
 			internMapViewer.setZoom(internMapViewer.getZoom() - 1);
 		} else {
 			Main.getInstance().getGraphManager().zoomIn();
@@ -81,13 +94,12 @@ public final class ButtonManager {
 	 * Handler for zoom out Button
 	 */
 	public static final void zoomOutAction(ActionEvent event) {
-		if(GraphDisplayManager.getCurrentLayer().equals(Layer.SYMBOL)){
+		if (GraphDisplayManager.getCurrentLayer().equals(Layer.SYMBOL)) {
 			internMapViewer.setZoom(internMapViewer.getZoom() + 1);
 		} else {
 			Main.getInstance().getGraphManager().zoomOut();
 		}
 	}
-	
 
 	/**
 	 * After switching from symbol-layer to other layer show toolbox and make
@@ -103,7 +115,7 @@ public final class ButtonManager {
 
 			controller.swingNodeWorldView.setVisible(false);
 			controller.swingNode.setVisible(true);
-			
+
 			controller.stackPane.setMouseTransparent(true);
 			controller.swingNodeWorldView.setMouseTransparent(true);
 
@@ -178,27 +190,58 @@ public final class ButtonManager {
 			GraphDisplayManager.addGraph(gClone, true);
 
 			activateWorldView();
+
 		}
 
 		GraphDisplayManager.switchActiveGraph();
 		setBorderStyle((Button) arg0.getSource());
 	}
 
+	public static void showHostNotReachableDialog() {
+		// Create new Dialog
+		Dialog<ArrayList<String>> addPropDialog = new Dialog<>();
+		addPropDialog.setTitle("Preferences");
+
+		ButtonType okButton = new ButtonType("Ok", ButtonData.OK_DONE);
+		addPropDialog.getDialogPane().getButtonTypes().add(okButton);
+
+		// create grid
+		GridPane grid = new GridPane();
+		grid.setHgap(10);
+		grid.setVgap(10);
+		grid.setPadding(new Insets(20, 150, 10, 10));
+
+		// position elements on grid
+		grid.add(new Label("Currently no OpenStreetView Host connection"), 0, 0);
+
+		// set dialog
+		addPropDialog.getDialogPane().setContent(grid);
+
+		// get new property values
+		addPropDialog.setResultConverter(dialogButton -> {
+
+			controller.underlayButton.fire();
+			return null;
+
+		});
+		addPropDialog.showAndWait();
+
+	}
+
 	/**
 	 * Initializes the WorldView, sets data and paints them
 	 */
 	private static void activateWorldView() {
 
-		GraphManager man = GraphDisplayManager.getGraphManager(Layer.UNDERLAY);
-
 		HashSet<GeoPosition> nodePositions = new HashSet<GeoPosition>();
 		HashSet<CustomWaypoint> waypoints = new HashSet<CustomWaypoint>();
+		HashSet<Edge> edges = new HashSet<Edge>();
 
 		// Get GeoPositions of nodes and get all waypoints created
-		initializeDataSets(nodePositions, waypoints);
+		initializeDataSets(nodePositions, waypoints, edges);
 
 		// Create a line for all edges
-		EdgePainter edgePainter = new EdgePainter(man.getGraph().getEdgeSet());
+		EdgePainter edgePainter = new EdgePainter(edges);
 
 		// Create a waypoint painter that takes all the waypoints
 		WaypointPainter<CustomWaypoint> waypointPainter = new WaypointPainter<CustomWaypoint>();
@@ -212,30 +255,39 @@ public final class ButtonManager {
 
 		CompoundPainter<JXMapViewer> painter = new CompoundPainter<JXMapViewer>(painters);
 
-		// Fetch mapViwer from SwingNode
 		JXMapViewer mapViewer = (JXMapViewer) controller.swingNodeWorldView.getContent();
 
-		// set Zoom and Center to show all node positions
-		mapViewer.zoomToBestFit(nodePositions, 0.7);
+		// Create a TileFactoryInfo for OpenStreetMap
+		TileFactoryInfo info = new OSMTileFactoryInfo();
+		DefaultTileFactory tileFactory = new DefaultTileFactory(info);
+		mapViewer.setTileFactory(tileFactory);
 
-		mapViewer.setOverlayPainter(painter);
+		// Use 8 threads in parallel to load the tiles
+		tileFactory.setThreadPoolSize(8);
 
 		// Add interactions
+
+		// "Drag map around" Listener
 		MouseInputListener mia = new PanMouseInputListener(mapViewer);
 		mapViewer.addMouseListener(mia);
 		mapViewer.addMouseMotionListener(mia);
 
+		// "click on waypoints" listener
+		mapViewer.addMouseListener(new CustomMapClickListener(mapViewer, waypoints, edges));
+
+		// center map if double clicked / middle clicked
 		mapViewer.addMouseListener(new CenterMapListener(mapViewer));
 
+		// zoom with mousewheel
 		mapViewer.addMouseWheelListener(new ZoomMouseWheelListenerCursor(mapViewer));
 
+		// TODO make this work
 		mapViewer.addKeyListener(new PanKeyListener(mapViewer));
 
-		internMapViewer = mapViewer;
-		internMapViewer.repaint();
+		// set Zoom and Center to show all node positions
+		mapViewer.zoomToBestFit(nodePositions, 0.7);
 
-		controller.swingNodeWorldView.setContent(internMapViewer);
-		controller.swingNodeWorldView.setVisible(true);
+		mapViewer.setOverlayPainter(painter);
 
 		// Checkboxes were changed last time symbolRep-Layer was shown
 		if (!controller.edgesVisibleCheckbox.isSelected()) {
@@ -249,6 +301,15 @@ public final class ButtonManager {
 		if (!controller.edgeWeightCheckbox.isSelected()) {
 			edgePainter.setShowWeights(false);
 		}
+		if (!controller.mapViewChoiceBox.getSelectionModel().getSelectedItem().equals("Default")) {
+			changeMapView();
+		}
+
+		internMapViewer = mapViewer;
+		internMapViewer.repaint();
+
+		controller.swingNodeWorldView.setContent(internMapViewer);
+		controller.swingNodeWorldView.setVisible(true);
 	}
 
 	/**
@@ -259,10 +320,16 @@ public final class ButtonManager {
 	 * @param waypoints
 	 *            Read node data to create CustomWaypoints with deviceTypes
 	 */
-	private static void initializeDataSets(HashSet<GeoPosition> nodePositions, HashSet<CustomWaypoint> waypoints) {
+	private static void initializeDataSets(HashSet<GeoPosition> nodePositions, HashSet<CustomWaypoint> waypoints,
+			HashSet<Edge> edges) {
 
 		GraphManager man = GraphDisplayManager.getGraphManager();
 
+		// add all edges from the Graph to the HashSet
+		for (Edge egde : man.getGraph().getEdgeSet()) {
+			edges.add(egde);
+		}
+
 		for (Node node : man.getGraph().getEachNode()) {
 
 			if (node.hasAttribute("lat") && node.hasAttribute("long")) {
@@ -296,7 +363,7 @@ public final class ButtonManager {
 					break;
 				}
 
-				waypoints.add(new CustomWaypoint(node.getAttribute("ui.label"), resource, geoPos));
+				waypoints.add(new CustomWaypoint(node.getAttribute("ui.label"), node.getId(), resource, geoPos));
 
 			}
 		}
@@ -390,7 +457,7 @@ public final class ButtonManager {
 	 * @return EdgePainter or WaypointPainter if existing in CompoundPainter
 	 *         otherwise null
 	 */
-	private static Painter<JXMapViewer> getCurrentPainter(String requested) {
+	public static Painter<JXMapViewer> getCurrentPainter(String requested) {
 
 		// return types
 		EdgePainter edgePainter = null;
@@ -430,6 +497,15 @@ public final class ButtonManager {
 
 	}
 
+	/**
+	 * Set the hostReachable atrribute
+	 * 
+	 * @param reachable
+	 */
+	public static void setHostReachable(Boolean reachable) {
+		hostReachable = reachable;
+	}
+
 	/**
 	 * Changes the border of the button that was pressed to red
 	 * 
@@ -449,4 +525,39 @@ public final class ButtonManager {
 		}
 	}
 
+	/**
+	 * update mapViewer if choiceBox item was changed
+	 * 
+	 * @param ov
+	 * @param oldVal
+	 * @param newVal
+	 */
+	public static void mapViewChoiceChange(ObservableValue<? extends String> ov, String oldVal, String newVal) {
+		changeMapView();
+	}
+
+	private static void changeMapView() {
+		String selected = controller.mapViewChoiceBox.getSelectionModel().getSelectedItem();
+
+		switch (selected) {
+		case "Default":
+			TileFactoryInfo defaultTileFactoryInfo = new OSMTileFactoryInfo();
+			internMapViewer.setTileFactory(new DefaultTileFactory(defaultTileFactoryInfo));
+			break;
+		case "Road":
+			TileFactoryInfo roadTileFactoryInfo = new VirtualEarthTileFactoryInfo(VirtualEarthTileFactoryInfo.MAP);
+			internMapViewer.setTileFactory(new DefaultTileFactory(roadTileFactoryInfo));
+			break;
+		case "Satellite":
+			TileFactoryInfo sateliteTileFactoryInfo = new VirtualEarthTileFactoryInfo(
+					VirtualEarthTileFactoryInfo.SATELLITE);
+			internMapViewer.setTileFactory(new DefaultTileFactory(sateliteTileFactoryInfo));
+			break;
+		case "Hybrid":
+			TileFactoryInfo hybridTileFactoryInfo = new VirtualEarthTileFactoryInfo(VirtualEarthTileFactoryInfo.HYBRID);
+			internMapViewer.setTileFactory(new DefaultTileFactory(hybridTileFactoryInfo));
+			break;
+		}
+	}
+
 }

+ 119 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/CustomMapClickListener.java

@@ -0,0 +1,119 @@
+package de.tu_darmstadt.informatik.tk.scopviz.ui;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.util.HashSet;
+
+import org.graphstream.graph.Edge;
+import org.jxmapviewer.JXMapViewer;
+import org.jxmapviewer.input.MapClickListener;
+import org.jxmapviewer.viewer.GeoPosition;
+
+import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
+
+public class CustomMapClickListener extends MapClickListener {
+
+	private final HashSet<CustomWaypoint> nodePositions;
+	private final JXMapViewer viewer;
+
+	private static CustomWaypoint selected;
+
+	private static HashSet<Edge> edges;
+
+	public CustomMapClickListener(JXMapViewer viewer, HashSet<CustomWaypoint> waypoints, HashSet<Edge> edges) {
+		super(viewer);
+
+		this.viewer = viewer;
+		this.nodePositions = waypoints;
+		CustomMapClickListener.edges = edges;
+
+	}
+
+	@Override
+	public void mapClicked(GeoPosition arg0) {
+
+		Point2D clickedPoint = this.viewer.getTileFactory().geoToPixel(arg0, this.viewer.getZoom());
+		Point2D nodePoint;
+
+		// a waypoint was clicked
+		Boolean wayPointSelected = false;
+
+		for (CustomWaypoint nodeWaypoint : this.nodePositions) {
+			// transform GeoPosition to point on screen
+			nodePoint = this.viewer.getTileFactory().geoToPixel(nodeWaypoint.getPosition(), this.viewer.getZoom());
+
+			boolean yChecked = false;
+
+			// clicked position is in range of 50 pixel above the waypoint
+			// position
+			double deltaY = clickedPoint.getY() - nodePoint.getY();
+			if (deltaY > -50 && 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) {
+
+				wayPointSelected = true;
+
+				PropertiesManager.showNewDataSet(GraphDisplayManager.getGraphManager(Layer.UNDERLAY).getGraph()
+						.getNode(nodeWaypoint.getNodeID()));
+
+				// deselect old waypoint and select new clicked waypoint
+				deselectAll();
+				selected = nodeWaypoint;
+				nodeWaypoint.select();
+				viewer.repaint();
+				break;
+			}
+		}
+
+		// no node selected so check if edge selected
+		if (!wayPointSelected) {
+			for (Edge edge : CustomMapClickListener.edges) {
+				// Get geo Positions of the two nodes that define the edge
+				GeoPosition startPos = new GeoPosition(edge.getNode0().getAttribute("lat"),
+						edge.getNode0().getAttribute("long"));
+				GeoPosition endPos = new GeoPosition(edge.getNode1().getAttribute("lat"),
+						edge.getNode1().getAttribute("long"));
+
+				// convert geo-coordinate to world bitmap pixel
+				Point2D startPoint = viewer.getTileFactory().geoToPixel(startPos, viewer.getZoom());
+				Point2D endPoint = viewer.getTileFactory().geoToPixel(endPos, viewer.getZoom());
+
+				Line2D.Double line = new Line2D.Double(startPoint.getX(), startPoint.getY(), endPoint.getX(),
+						endPoint.getY());
+
+				// Clicked point in 10 pixel range of line
+				if (line.ptLineDist(clickedPoint) < 10) {
+					deselectAll();
+					if (!edge.hasAttribute("ui.map.selected"))
+						edge.addAttribute("ui.map.selected", true);
+					else
+						edge.changeAttribute("ui.map.selected", true);
+
+					PropertiesManager.showNewDataSet(edge);
+
+					viewer.repaint();
+					break;
+				} else {
+					edge.changeAttribute("ui.map.selected", false);
+				}
+			}
+		}
+
+	}
+
+	/**
+	 * deselect all edges and the selected node
+	 */
+	public static void deselectAll() {
+		if (selected != null)
+			selected.deselect();
+		for (Edge edge : edges) {
+			edge.changeAttribute("ui.map.selected", false);
+		}
+	}
+
+}

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

@@ -14,6 +14,9 @@ public class CustomWaypoint extends DefaultWaypoint {
 
 	private final String label;
 	private final URL resource;
+	private final String nodeID;
+
+	private Boolean isSelected = false;
 
 	/**
 	 * @param label
@@ -23,10 +26,11 @@ public class CustomWaypoint extends DefaultWaypoint {
 	 * @param coord
 	 *            the coordinate
 	 */
-	public CustomWaypoint(String label, URL resource, GeoPosition coord) {
+	public CustomWaypoint(String label, String nodeID, URL resource, GeoPosition coord) {
 		super(coord);
 		this.label = label;
 		this.resource = resource;
+		this.nodeID = nodeID;
 	}
 
 	/**
@@ -42,4 +46,35 @@ public class CustomWaypoint extends DefaultWaypoint {
 	public URL getResource() {
 		return resource;
 	}
+
+	/**
+	 * 
+	 * @return the id of the referenced node
+	 */
+	public String getNodeID() {
+		return nodeID;
+	}
+
+	/**
+	 * change isSelected value to true
+	 */
+	public void select() {
+		this.isSelected = true;
+	}
+
+	/**
+	 * change isSelected value to false
+	 */
+	public void deselect() {
+		this.isSelected = false;
+	}
+
+	/**
+	 * return isSelected value
+	 * 
+	 * @return
+	 */
+	public Boolean getIsSelected() {
+		return this.isSelected;
+	}
 }

+ 31 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/CustomWaypointRenderer.java

@@ -1,5 +1,6 @@
 package de.tu_darmstadt.informatik.tk.scopviz.ui;
 
+import java.awt.Color;
 import java.awt.Font;
 import java.awt.FontMetrics;
 import java.awt.Graphics2D;
@@ -48,6 +49,9 @@ public class CustomWaypointRenderer implements WaypointRenderer<CustomWaypoint>
 
 		try {
 			origImage = ImageIO.read(w.getResource());
+			if (w.getIsSelected()) {
+				origImage = colorImage(origImage);
+			}
 		} catch (Exception ex) {
 			log.warn("couldn't read Waypoint png", ex);
 		}
@@ -72,6 +76,11 @@ public class CustomWaypointRenderer implements WaypointRenderer<CustomWaypoint>
 			String label = w.getLabel();
 			g.setFont(font);
 
+			if (w.getIsSelected()) {
+				g.setColor(Color.RED);
+			} else
+				g.setColor(Color.BLACK);
+
 			// get label height and width under given font
 			FontMetrics metrics = g.getFontMetrics();
 			int tw = metrics.stringWidth(label);
@@ -85,6 +94,28 @@ public class CustomWaypointRenderer implements WaypointRenderer<CustomWaypoint>
 		}
 	}
 
+	/**
+	 * change every black pixel to a red one
+	 * 
+	 * @param image
+	 * @return colored image
+	 */
+	private static BufferedImage colorImage(BufferedImage image) {
+		int width = image.getWidth();
+		int height = image.getHeight();
+
+		for (int xx = 0; xx < width; xx++) {
+			for (int yy = 0; yy < height; yy++) {
+				Color originalColor = new Color(image.getRGB(xx, yy), true);
+
+				if (originalColor.equals(Color.BLACK) && originalColor.getAlpha() == 255) {
+					image.setRGB(xx, yy, Color.RED.getRGB());
+				}
+			}
+		}
+		return image;
+	}
+
 	public void setShowLabels(Boolean showLabels) {
 		this.showLabels = showLabels;
 	}

+ 72 - 35
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/EdgePainter.java

@@ -42,29 +42,29 @@ public class EdgePainter implements Painter<JXMapViewer> {
 	}
 
 	@Override
-	public void paint(Graphics2D g, JXMapViewer map, int w, int h) {
+	public void paint(Graphics2D g, JXMapViewer mapViewer, int w, int h) {
 
 		if (showEdges) {
 			g = (Graphics2D) g.create();
 
 			// convert from viewport to world bitmap
-			Rectangle rect = map.getViewportBounds();
+			Rectangle rect = mapViewer.getViewportBounds();
 			g.translate(-rect.x, -rect.y);
 
 			if (antiAlias)
 				g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 
 			// do the drawing
-			g.setColor(Color.BLACK);
+			g.setColor(color);
 			g.setStroke(new BasicStroke(4));
 
-			drawRoute(g, map);
+			drawRoute(g, mapViewer);
 
 			// do the drawing again
 			g.setColor(color);
 			g.setStroke(new BasicStroke(2));
 
-			drawRoute(g, map);
+			drawRoute(g, mapViewer);
 
 			g.dispose();
 		}
@@ -75,10 +75,10 @@ public class EdgePainter implements Painter<JXMapViewer> {
 	 * 
 	 * @param g
 	 *            the graphics object
-	 * @param map
+	 * @param mapViewer
 	 *            the map
 	 */
-	private void drawRoute(Graphics2D g, JXMapViewer map) {
+	private void drawRoute(Graphics2D g, JXMapViewer mapViewer) {
 
 		for (Edge edge : edges) {
 
@@ -89,45 +89,81 @@ public class EdgePainter implements Painter<JXMapViewer> {
 					edge.getNode1().getAttribute("long"));
 
 			// convert geo-coordinate to world bitmap pixel
-			Point2D startPoint = map.getTileFactory().geoToPixel(startPos, map.getZoom());
-			Point2D endPoint = map.getTileFactory().geoToPixel(endPos, map.getZoom());
+			Point2D startPoint = mapViewer.getTileFactory().geoToPixel(startPos, mapViewer.getZoom());
+			Point2D endPoint = mapViewer.getTileFactory().geoToPixel(endPos, mapViewer.getZoom());
 
-			g.drawLine((int) startPoint.getX(), (int) startPoint.getY(), (int) endPoint.getX(), (int) endPoint.getY());
+			// if edge has attribute selected
+			if (edge.hasAttribute("ui.map.selected")) {
 
-			if (showWeights) {
+				// draw red line if edge is selected
+				if ((boolean) edge.getAttribute("ui.map.selected")) {
+					g.setColor(Color.RED);
+					g.drawLine((int) startPoint.getX(), (int) startPoint.getY(), (int) endPoint.getX(),
+							(int) endPoint.getY());
 
-				// Set weight Position on street map
-				String weight = edge.getAttribute("weight").toString();
+					// draw black line if not selected
+				} else {
+					g.setColor(color);
+					g.drawLine((int) startPoint.getX(), (int) startPoint.getY(), (int) endPoint.getX(),
+							(int) endPoint.getY());
+				}
 
-				// get weight height and width under given font
-				FontMetrics metrics = g.getFontMetrics();
-				int tw = metrics.stringWidth(weight);
-				int th = 1 + metrics.getAscent();
+				// edge hasnt got selected attribute
+			} else {
+				g.setColor(color);
+				g.drawLine((int) startPoint.getX(), (int) startPoint.getY(), (int) endPoint.getX(),
+						(int) endPoint.getY());
+			}
 
-				g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+			if (showWeights) {
+				drawWeights(edge, g, startPoint, endPoint);
+			}
+		}
+	}
+
+	/**
+	 * draw the weights of an edge
+	 * 
+	 * @param edge
+	 *            edge
+	 * @param g
+	 *            graphic
+	 * @param startPoint
+	 *            start point edge
+	 * @param endPoint
+	 *            end point edge
+	 */
+	private void drawWeights(Edge edge, Graphics2D g, Point2D startPoint, Point2D endPoint) {
+		// Set weight Position on street map
+		String weight = edge.getAttribute("weight").toString();
 
-				double deltaX = (startPoint.getX() - endPoint.getX()) / 2;
-				double deltaY = (startPoint.getY() - endPoint.getY()) / 2;
+		// get weight height and width under given font
+		FontMetrics metrics = g.getFontMetrics();
+		int tw = metrics.stringWidth(weight);
+		int th = 1 + metrics.getAscent();
 
-				double weightPosX;
-				double weightPosY;
+		g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
 
-				if (deltaX < 0) {
-					weightPosX = startPoint.getX() + Math.abs(deltaX);
-				} else {
-					weightPosX = startPoint.getX() - Math.abs(deltaX);
-				}
+		double deltaX = (startPoint.getX() - endPoint.getX()) / 2;
+		double deltaY = (startPoint.getY() - endPoint.getY()) / 2;
 
-				if (deltaY < 0) {
-					weightPosY = startPoint.getY() + Math.abs(deltaY);
-				} else {
-					weightPosY = startPoint.getY() - Math.abs(deltaY);
-				}
-				// Show weight left middle of deviceType picture
-				g.drawString(weight, (int) weightPosX - tw / 2, (int) weightPosY - th / 2);
+		double weightPosX;
+		double weightPosY;
 
-			}
+		if (deltaX < 0) {
+			weightPosX = startPoint.getX() + Math.abs(deltaX);
+		} else {
+			weightPosX = startPoint.getX() - Math.abs(deltaX);
+		}
+
+		if (deltaY < 0) {
+			weightPosY = startPoint.getY() + Math.abs(deltaY);
+		} else {
+			weightPosY = startPoint.getY() - Math.abs(deltaY);
 		}
+		// Show weight left middle of deviceType picture
+		g.drawString(weight, (int) weightPosX - tw / 2, (int) weightPosY - th / 2);
+
 	}
 
 	/**
@@ -147,4 +183,5 @@ public class EdgePainter implements Painter<JXMapViewer> {
 	public void setShowWeights(Boolean showWeights) {
 		this.showWeights = showWeights;
 	}
+
 }

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

@@ -7,9 +7,6 @@ import java.util.ResourceBundle;
 import javax.swing.JPanel;
 
 import org.jxmapviewer.JXMapViewer;
-import org.jxmapviewer.OSMTileFactoryInfo;
-import org.jxmapviewer.viewer.DefaultTileFactory;
-import org.jxmapviewer.viewer.TileFactoryInfo;
 
 import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.handlers.KeyboardShortcuts;
@@ -17,11 +14,13 @@ import de.tu_darmstadt.informatik.tk.scopviz.ui.handlers.MyAnimationTimer;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.handlers.ResizeListener;
 import javafx.beans.value.ChangeListener;
 import javafx.beans.value.ObservableValue;
+import javafx.collections.FXCollections;
 import javafx.embed.swing.SwingNode;
 import javafx.fxml.FXML;
 import javafx.fxml.Initializable;
 import javafx.scene.control.Button;
 import javafx.scene.control.CheckBox;
+import javafx.scene.control.ChoiceBox;
 import javafx.scene.control.Label;
 import javafx.scene.control.ListView;
 import javafx.scene.control.MenuItem;
@@ -126,6 +125,8 @@ public class GUIController implements Initializable {
 	public CheckBox nodeLabelCheckbox;
 	@FXML
 	public CheckBox edgeWeightCheckbox;
+	@FXML
+	public ChoiceBox<String> mapViewChoiceBox;
 
 	/**
 	 * Initializes all the references to the UI elements specified in the FXML
@@ -158,6 +159,7 @@ public class GUIController implements Initializable {
 		initializeSymbolRepToolbox();
 
 		initializeDisplayPane();
+
 		initializeWorldView();
 
 		// Setup the Keyboard Shortcuts
@@ -169,16 +171,8 @@ public class GUIController implements Initializable {
 
 		JXMapViewer mapViewer = new JXMapViewer();
 
-		// Create a TileFactoryInfo for OpenStreetMap
-		TileFactoryInfo info = new OSMTileFactoryInfo();
-		DefaultTileFactory tileFactory = new DefaultTileFactory(info);
-		mapViewer.setTileFactory(tileFactory);
-
-		// Use 8 threads in parallel to load the tiles
-		tileFactory.setThreadPoolSize(8);
-
 		swingNodeWorldView.setContent(mapViewer);
-		
+
 		// add resize Listener to the stackPane
 		stackPane.heightProperty().addListener(new ResizeListener(swingNode, stackPane));
 		stackPane.widthProperty().addListener(new ResizeListener(swingNode, stackPane));
@@ -222,6 +216,11 @@ public class GUIController implements Initializable {
 				.addListener((ov, oldVal, newVal) -> ButtonManager.labelVisibilitySwitcher(ov, oldVal, newVal));
 		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));
 	}
 
 	/**
@@ -371,6 +370,7 @@ 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'.";

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

@@ -210,7 +210,7 @@ public final class PropertiesManager {
 	 *            selected Node or Edge
 	 * @param newData
 	 */
-	private static void showNewDataSet(Element selected) {
+	public static void showNewDataSet(Element selected) {
 		if (selected == null) {
 			return;
 		}
@@ -240,6 +240,8 @@ public final class PropertiesManager {
 				break;
 			case "ui.class":
 				break;
+			case "ui.map.selected":
+				break;
 			case "xyz":
 				double[] pos = Toolkit.nodePosition((Node) selected);
 				newData.add(new KeyValuePair("x", String.valueOf(pos[0]), double.class));

+ 2 - 0
scopviz/src/main/resources/MainWindow.fxml

@@ -4,6 +4,7 @@
 <?import javafx.geometry.Insets?>
 <?import javafx.scene.control.Button?>
 <?import javafx.scene.control.CheckBox?>
+<?import javafx.scene.control.ChoiceBox?>
 <?import javafx.scene.control.ListView?>
 <?import javafx.scene.control.Menu?>
 <?import javafx.scene.control.MenuBar?>
@@ -83,6 +84,7 @@
                                                 <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
                                              </padding>
                                           </CheckBox>
+                                          <ChoiceBox fx:id="mapViewChoiceBox" prefWidth="150.0" />
                                        </children></VBox>
                                 </children>
                               </AnchorPane>