|
@@ -1,29 +1,17 @@
|
|
|
package de.tu_darmstadt.informatik.tk.scopviz.ui;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.HashSet;
|
|
|
-import java.util.List;
|
|
|
|
|
|
-import org.graphstream.graph.Edge;
|
|
|
import org.graphstream.graph.implementations.Graphs;
|
|
|
-import org.jxmapviewer.JXMapViewer;
|
|
|
-import org.jxmapviewer.OSMTileFactoryInfo;
|
|
|
-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.debug.Debug;
|
|
|
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.MyGraph;
|
|
|
-import de.tu_darmstadt.informatik.tk.scopviz.ui.mapView.CustomMapClickListener;
|
|
|
import de.tu_darmstadt.informatik.tk.scopviz.ui.mapView.CustomWaypoint;
|
|
|
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;
|
|
|
+import de.tu_darmstadt.informatik.tk.scopviz.ui.mapView.WorldView;
|
|
|
import javafx.beans.value.ObservableValue;
|
|
|
import javafx.event.ActionEvent;
|
|
|
import javafx.scene.control.Button;
|
|
@@ -45,8 +33,6 @@ public final class ButtonManager {
|
|
|
|
|
|
private static GUIController controller;
|
|
|
|
|
|
- private static JXMapViewer internMapViewer;
|
|
|
-
|
|
|
/**
|
|
|
* Private Constructor to prevent Instantiation.
|
|
|
*/
|
|
@@ -66,16 +52,12 @@ public final class ButtonManager {
|
|
|
setBorderStyle(uButton);
|
|
|
}
|
|
|
|
|
|
- public static void setViewer(JXMapViewer mapViewer) {
|
|
|
- internMapViewer = mapViewer;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Handler for zoom in Button
|
|
|
*/
|
|
|
public static final void zoomInAction(ActionEvent event) {
|
|
|
if (GraphDisplayManager.getCurrentLayer().equals(Layer.SYMBOL)) {
|
|
|
- internMapViewer.setZoom(internMapViewer.getZoom() - 1);
|
|
|
+ WorldView.internMapViewer.setZoom(WorldView.internMapViewer.getZoom() - 1);
|
|
|
} else {
|
|
|
Main.getInstance().getGraphManager().zoomIn();
|
|
|
}
|
|
@@ -86,7 +68,7 @@ public final class ButtonManager {
|
|
|
*/
|
|
|
public static final void zoomOutAction(ActionEvent event) {
|
|
|
if (GraphDisplayManager.getCurrentLayer().equals(Layer.SYMBOL)) {
|
|
|
- internMapViewer.setZoom(internMapViewer.getZoom() + 1);
|
|
|
+ WorldView.internMapViewer.setZoom(WorldView.internMapViewer.getZoom() + 1);
|
|
|
} else {
|
|
|
Main.getInstance().getGraphManager().zoomOut();
|
|
|
}
|
|
@@ -99,17 +81,23 @@ public final class ButtonManager {
|
|
|
private static void switchfromSymbolLayer() {
|
|
|
|
|
|
if (GraphDisplayManager.getCurrentLayer().equals(Layer.SYMBOL)) {
|
|
|
+
|
|
|
+ // show toolbox and hide VBox
|
|
|
controller.toolbox.setVisible(true);
|
|
|
controller.symbolToolVBox.setVisible(false);
|
|
|
|
|
|
+ // make properties editable again
|
|
|
controller.propertiesObjectColumn.setEditable(true);
|
|
|
|
|
|
+ // show graph instead of map view
|
|
|
controller.swingNodeWorldView.setVisible(false);
|
|
|
controller.swingNode.setVisible(true);
|
|
|
|
|
|
+ // make map view mouse transparent
|
|
|
controller.stackPane.setMouseTransparent(true);
|
|
|
controller.swingNodeWorldView.setMouseTransparent(true);
|
|
|
|
|
|
+ // make graph non mouse transparent
|
|
|
controller.pane.setMouseTransparent(false);
|
|
|
controller.swingNode.setMouseTransparent(false);
|
|
|
|
|
@@ -164,15 +152,6 @@ public final class ButtonManager {
|
|
|
public static final void symbolRepAction(ActionEvent arg0) {
|
|
|
|
|
|
if (!(GraphDisplayManager.getCurrentLayer().equals(Layer.SYMBOL))) {
|
|
|
- controller.toolbox.setVisible(false);
|
|
|
- controller.swingNode.setVisible(false);
|
|
|
- controller.propertiesObjectColumn.setEditable(false);
|
|
|
- controller.stackPane.setMouseTransparent(false);
|
|
|
- controller.swingNodeWorldView.setMouseTransparent(false);
|
|
|
-
|
|
|
- controller.pane.setMouseTransparent(true);
|
|
|
- controller.swingNode.setMouseTransparent(true);
|
|
|
- controller.symbolToolVBox.setVisible(true);
|
|
|
|
|
|
// add a copy of the underlay graph to the the symbol layer
|
|
|
MyGraph gClone = (MyGraph) Graphs.clone(GraphDisplayManager.getGraphManager(Layer.UNDERLAY).getGraph());
|
|
@@ -193,49 +172,32 @@ public final class ButtonManager {
|
|
|
*/
|
|
|
private static void activateWorldView() {
|
|
|
|
|
|
- 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
|
|
|
- MapViewFunctions.fetchGraphData(nodePositions, waypoints, edges);
|
|
|
-
|
|
|
- // Create a line for all edges
|
|
|
- EdgePainter edgePainter = new EdgePainter(edges);
|
|
|
-
|
|
|
- // Create a waypoint painter that takes all the waypoints
|
|
|
- WaypointPainter<CustomWaypoint> waypointPainter = new WaypointPainter<CustomWaypoint>();
|
|
|
- waypointPainter.setWaypoints(waypoints);
|
|
|
- waypointPainter.setRenderer(new CustomWaypointRenderer());
|
|
|
-
|
|
|
- // Create a compound painter that uses all painters
|
|
|
- List<Painter<JXMapViewer>> painters = new ArrayList<Painter<JXMapViewer>>();
|
|
|
- painters.add(waypointPainter);
|
|
|
- painters.add(edgePainter);
|
|
|
+ // dont show graph and toolbox
|
|
|
+ controller.toolbox.setVisible(false);
|
|
|
+ controller.swingNode.setVisible(false);
|
|
|
|
|
|
- CompoundPainter<JXMapViewer> painter = new CompoundPainter<JXMapViewer>(painters);
|
|
|
+ // make properties uneditable
|
|
|
+ controller.propertiesObjectColumn.setEditable(false);
|
|
|
|
|
|
- // Create a TileFactoryInfo for OpenStreetMap
|
|
|
- TileFactoryInfo info = new OSMTileFactoryInfo();
|
|
|
- DefaultTileFactory tileFactory = new DefaultTileFactory(info);
|
|
|
- internMapViewer.setTileFactory(tileFactory);
|
|
|
+ // make map view non mouse transparent
|
|
|
+ controller.stackPane.setMouseTransparent(false);
|
|
|
+ controller.swingNodeWorldView.setMouseTransparent(false);
|
|
|
|
|
|
- // Use 8 threads in parallel to load the tiles
|
|
|
- tileFactory.setThreadPoolSize(8);
|
|
|
+ // make graph mouse transparent
|
|
|
+ controller.pane.setMouseTransparent(true);
|
|
|
+ controller.swingNode.setMouseTransparent(true);
|
|
|
|
|
|
- // set Zoom and Center to show all node positions
|
|
|
- internMapViewer.zoomToBestFit(nodePositions, 0.7);
|
|
|
+ // show VBox for map options
|
|
|
+ controller.symbolToolVBox.setVisible(true);
|
|
|
|
|
|
- internMapViewer.setOverlayPainter(painter);
|
|
|
-
|
|
|
- // "click on waypoints" listener
|
|
|
- internMapViewer.addMouseListener(new CustomMapClickListener(internMapViewer, waypoints, edges));
|
|
|
+ WorldView.loadWorldView();
|
|
|
|
|
|
MapViewFunctions.checkVBoxChanged();
|
|
|
|
|
|
- internMapViewer.repaint();
|
|
|
+ WorldView.internMapViewer.repaint();
|
|
|
|
|
|
- controller.swingNodeWorldView.setContent(internMapViewer);
|
|
|
+ // set content to UI Element
|
|
|
+ controller.swingNodeWorldView.setContent(WorldView.internMapViewer);
|
|
|
controller.swingNodeWorldView.setVisible(true);
|
|
|
}
|
|
|
|
|
@@ -250,16 +212,15 @@ public final class ButtonManager {
|
|
|
*/
|
|
|
public static void edgeVisibleSwitch(ObservableValue<? extends Boolean> ov, Boolean oldVal, Boolean newVal) {
|
|
|
|
|
|
- EdgePainter edgePainter = (EdgePainter) MapViewFunctions.getRequestedPainter("edge");
|
|
|
-
|
|
|
// Show edges
|
|
|
if (newVal) {
|
|
|
- edgePainter.setShowEdges(true);
|
|
|
- internMapViewer.repaint();
|
|
|
- // Hide edges
|
|
|
+ WorldView.edgePainter.setShowEdges(true);
|
|
|
+ WorldView.internMapViewer.repaint();
|
|
|
+
|
|
|
} else {
|
|
|
- edgePainter.setShowEdges(false);
|
|
|
- internMapViewer.repaint();
|
|
|
+ // Hide edges
|
|
|
+ WorldView.edgePainter.setShowEdges(false);
|
|
|
+ WorldView.internMapViewer.repaint();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -274,9 +235,7 @@ public final class ButtonManager {
|
|
|
*/
|
|
|
public static void labelVisibilitySwitcher(ObservableValue<? extends Boolean> ov, Boolean oldVal, Boolean newVal) {
|
|
|
|
|
|
- WaypointPainter<CustomWaypoint> waypointPainter = (WaypointPainter<CustomWaypoint>) MapViewFunctions
|
|
|
- .getRequestedPainter("waypoint");
|
|
|
-
|
|
|
+ WaypointPainter<CustomWaypoint> waypointPainter = WorldView.waypointPainter;
|
|
|
CustomWaypointRenderer renderer = new CustomWaypointRenderer();
|
|
|
|
|
|
// Show node labels
|
|
@@ -284,13 +243,14 @@ public final class ButtonManager {
|
|
|
renderer.setShowLabels(true);
|
|
|
waypointPainter.clearCache();
|
|
|
waypointPainter.setRenderer(renderer);
|
|
|
- internMapViewer.repaint();
|
|
|
- // Hide node labels
|
|
|
+ WorldView.internMapViewer.repaint();
|
|
|
+
|
|
|
} else {
|
|
|
+ // Hide node labels
|
|
|
renderer.setShowLabels(false);
|
|
|
waypointPainter.clearCache();
|
|
|
waypointPainter.setRenderer(renderer);
|
|
|
- internMapViewer.repaint();
|
|
|
+ WorldView.internMapViewer.repaint();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -306,15 +266,14 @@ public final class ButtonManager {
|
|
|
public static void edgeWeightVisibilitySwitcher(ObservableValue<? extends Boolean> ov, Boolean oldVal,
|
|
|
Boolean newVal) {
|
|
|
|
|
|
- EdgePainter edgePainter = (EdgePainter) MapViewFunctions.getRequestedPainter("edge");
|
|
|
// Show Edges weights
|
|
|
if (newVal) {
|
|
|
- edgePainter.setShowWeights(true);
|
|
|
- internMapViewer.repaint();
|
|
|
+ WorldView.edgePainter.setShowWeights(true);
|
|
|
+ WorldView.internMapViewer.repaint();
|
|
|
// Hide Edges weights
|
|
|
} else {
|
|
|
- edgePainter.setShowWeights(false);
|
|
|
- internMapViewer.repaint();
|
|
|
+ WorldView.edgePainter.setShowWeights(false);
|
|
|
+ WorldView.internMapViewer.repaint();
|
|
|
}
|
|
|
}
|
|
|
|