فهرست منبع

Merged everything

Jan Enders 8 سال پیش
والد
کامیت
4c86e84c7f

+ 11 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/debug/Debug.java

@@ -31,6 +31,17 @@ public class Debug {
 		return fileName;
 	}
 
+	/**
+	 * Returns the Location of the File for the testing Graph.
+	 * 
+	 * @return a sample graph for the Program
+	 */
+	public static String getDefaultGraph2() {
+		String fileName = null;
+		fileName = "/Example2.graphml";
+		return fileName;
+	}
+
 	/**
 	 * Short form for System.out.println().
 	 * 

+ 6 - 7
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/io/GraphMLImporter.java

@@ -4,11 +4,10 @@ import java.io.IOException;
 import java.net.URL;
 import java.util.LinkedList;
 
-import org.graphstream.graph.Graph;
-import org.graphstream.graph.implementations.DefaultGraph;
 import org.graphstream.graph.implementations.SingleGraph;
 
 import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
+import de.tu_darmstadt.informatik.tk.scopviz.main.MyGraph;
 import javafx.stage.FileChooser;
 import javafx.stage.Stage;
 
@@ -31,8 +30,8 @@ public class GraphMLImporter {
 	 *            path to the file on disk
 	 * @return the imported Graphstream-Graph
 	 */
-	public Graph readGraph(String id, final String fileName) {
-		Graph g = new DefaultGraph(id);
+	public MyGraph readGraph(String id, final String fileName) {
+		MyGraph g = new MyGraph(id);
 		fs.addSink(g);
 		try {
 			fs.readAll(fileName);
@@ -52,7 +51,7 @@ public class GraphMLImporter {
 	 *            the parent window of the open file window
 	 * @return the imported Graphstream-Graph
 	 */
-	public Graph readGraph(final String id, final Stage stage) {
+	public MyGraph readGraph(final String id, final Stage stage) {
 		FileChooser fileChooser = new FileChooser();
 		fileChooser.setTitle("open graph");
 		try {
@@ -74,8 +73,8 @@ public class GraphMLImporter {
 	 * @return the imported Graphstream-Graph
 	 */
 	// TODO backup reader/Exception handling
-	public Graph readGraph(String id, final URL fileURL) {
-		Graph g = new DefaultGraph(id);
+	public MyGraph readGraph(String id, final URL fileURL) {
+		MyGraph g = new MyGraph(id);
 		fs.addSink(g);
 		try {
 			fs.readAll(fileURL);

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

@@ -4,5 +4,5 @@ import org.graphstream.graph.Edge;
 
 public interface EdgeCreatedListener {
 
-	public void edgeCreated(Edge e);
+	public void edgeCreated(Edge e, String graphID);
 }

+ 4 - 13
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/main/GraphManager.java

@@ -13,7 +13,6 @@ import org.graphstream.ui.swingViewer.ViewPanel;
 import org.graphstream.ui.view.Viewer;
 import org.graphstream.ui.view.ViewerPipe;
 
-import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.OptionsManager;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.PropertiesManager;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.handlers.MyMouseManager;
@@ -30,7 +29,7 @@ import de.tu_darmstadt.informatik.tk.scopviz.ui.handlers.MyMouseManager;
 public class GraphManager {
 
 	/** The Graph this instance of GraphManager manages. */
-	protected Graph g;
+	protected MyGraph g;
 
 	/**
 	 * The Stylesheet for this Graph, excluding parts that can be set by
@@ -68,7 +67,7 @@ public class GraphManager {
 	 * @param graph
 	 *            the graph this visualizer should handle
 	 */
-	public GraphManager(Graph graph) {
+	public GraphManager(MyGraph graph) {
 		g = graph;
 		/* Viewer */ viewer = new Viewer(g, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
 		view = viewer.addDefaultView(false);
@@ -376,9 +375,7 @@ public class GraphManager {
 			if (n.hasAttribute("x") && currentMin > (Double) n.getAttribute("x")) {
 				currentMin = (Double) n.getAttribute("x");
 			}
-			Debug.out(Double.toString(currentMin));
 		}
-		Debug.out(Double.toString(currentMin));
 		return currentMin;
 	}
 
@@ -388,7 +385,7 @@ public class GraphManager {
 	 * @return the biggest X Coordinate in the Graph
 	 */
 	public double getMaxX() {
-		double currentMax = Double.MAX_VALUE;
+		double currentMax = Double.MIN_VALUE;
 		Node n = null;
 		Iterator<Node> allNodes = g.getNodeIterator();
 
@@ -397,9 +394,7 @@ public class GraphManager {
 			if (n.hasAttribute("x") && currentMax < (Double) n.getAttribute("x")) {
 				currentMax = (Double) n.getAttribute("x");
 			}
-			Debug.out(Double.toString(currentMax));
 		}
-		Debug.out(Double.toString(currentMax));
 		return currentMax;
 	}
 
@@ -418,9 +413,7 @@ public class GraphManager {
 			if (n.hasAttribute("y") && currentMin > (Double) n.getAttribute("y")) {
 				currentMin = (Double) n.getAttribute("y");
 			}
-			Debug.out(Double.toString(currentMin));
 		}
-		Debug.out(Double.toString(currentMin));
 		return currentMin;
 	}
 
@@ -430,7 +423,7 @@ public class GraphManager {
 	 * @return the biggest Y Coordinate in the Graph
 	 */
 	public double getMaxY() {
-		double currentMax = Double.MAX_VALUE;
+		double currentMax = Double.MIN_VALUE;
 		Node n = null;
 		Iterator<Node> allNodes = g.getNodeIterator();
 
@@ -439,9 +432,7 @@ public class GraphManager {
 			if (n.hasAttribute("y") && currentMax < (Double) n.getAttribute("y")) {
 				currentMax = (Double) n.getAttribute("y");
 			}
-			Debug.out(Double.toString(currentMax));
 		}
-		Debug.out(Double.toString(currentMax));
 		return currentMax;
 	}
 

+ 3 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/main/MainApp.java

@@ -66,6 +66,9 @@ public class MainApp extends Application {
 		Main.getInstance().setPrimaryStage(this.primaryStage);
 		initRootLayout();
 		if (Debug.DEBUG_ENABLED) {
+			GraphDisplayManager.setCurrentLayer(Layer.OPERATOR);
+			GraphDisplayManager.addGraph(Debug.getDefaultGraph2(), true);
+			GraphDisplayManager.setCurrentLayer(Layer.UNDERLAY);
 			GraphDisplayManager.addGraph(Debug.getDefaultGraph(), true);
 		}
 	}

+ 147 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/main/MappingGraphManager.java

@@ -0,0 +1,147 @@
+package de.tu_darmstadt.informatik.tk.scopviz.main;
+
+import java.util.HashMap;
+
+import org.graphstream.algorithm.Toolkit;
+import org.graphstream.graph.Edge;
+import org.graphstream.graph.Node;
+
+import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
+
+public class MappingGraphManager extends GraphManager implements EdgeCreatedListener, NodeCreatedListener {
+	public static final String UNDERLAYER_PREFIX = "underlay";
+	public static final String OPERATOR_PREFIX = "operator";
+	private static final double UNDERLAYER_MOVE_Y = 0;
+	private static final double OPERATOR_MOVE_Y = 1.5;
+	private boolean underlayNodesChanged = false;
+	private boolean operatorNodesChanged = false;
+
+	GraphManager underlay, operator;
+
+	public MappingGraphManager(MyGraph graph, GraphManager underlay, GraphManager operator) {
+		super(graph);
+		this.underlay = underlay;
+		this.operator = operator;
+		Debug.out("Created a new Mapping");
+		mergeGraph(underlay, UNDERLAYER_PREFIX, UNDERLAYER_MOVE_Y);
+		mergeGraph(operator, OPERATOR_PREFIX, OPERATOR_MOVE_Y);
+		view.getCamera().resetView();
+	}
+
+	private void mergeGraph(GraphManager gm, String idPrefix, double moveY) {
+
+		mergeNodes(gm, idPrefix, moveY);
+		int i = 0;
+		for (Edge edge : gm.getGraph().getEdgeSet()) {
+			addEdge(edge, idPrefix);
+			i++;
+		}
+		Debug.out("added " + i + " Edge" + (i == 1 ? "" : "s") + " from \"" + idPrefix + "\"");
+	}
+
+	private void mergeNodes(GraphManager gm, String idPrefix, double moveY) {
+		int i = 0;
+		double maxX = gm.getMaxX();
+		double minX = gm.getMinX();
+		double scaleX = 1 / (maxX - minX);
+		double addX = -minX * scaleX;
+		double maxY = gm.getMaxY();
+		double minY = gm.getMinY();
+		double scaleY = 1 / (maxY - minY);
+		double addY = -minY * scaleY;
+		for (Node node : gm.getGraph().getNodeSet()) {
+			Node newNode = getGraph().getNode(idPrefix + node.getId());
+			if (newNode == null) {
+				addNode(node, idPrefix);
+				newNode = getGraph().getNode(idPrefix + node.getId());
+				i++;
+			}
+			double[] n = Toolkit.nodePosition(node);
+			double cX = n[0];
+			double x = cX * scaleX + addX;
+			double cY = n[1];
+			double y = cY * scaleY + addY + moveY;
+			newNode.changeAttribute("x", x);
+			newNode.changeAttribute("y", y);
+		}
+		Debug.out("added " + i + " Node" + (i == 1 ? "" : "s") + " from \"" + idPrefix + "\"");
+	}
+
+	public void activated() {
+		if (underlayNodesChanged) {
+			mergeNodes(underlay, UNDERLAYER_PREFIX, UNDERLAYER_MOVE_Y);
+			underlayNodesChanged = false;
+		}
+		if (operatorNodesChanged) {
+			mergeNodes(operator, OPERATOR_PREFIX, OPERATOR_MOVE_Y);
+			operatorNodesChanged = false;
+		}
+	}
+
+	public boolean hasGraphManagerAsParent(GraphManager gm) {
+		return (underlay.getGraph().getId().equals(gm.getGraph().getId()))
+				|| (operator.getGraph().getId().equals(gm.getGraph().getId()));
+	}
+
+	/**
+	 * Adds a <b>Copy</b> of the given Edge to the graph. The Copy retains the
+	 * ID and all attributes but adds the ID prefix in front of the all old IDs.
+	 * 
+	 * @param e
+	 *            the Edge to be added to the graph
+	 * @param idPrefix
+	 *            the String to be added as prefix to the ID
+	 */
+	private void addEdge(Edge e, String idPrefix) {
+		HashMap<String, Object> attributes = new HashMap<>();
+
+		for (String s : e.getAttributeKeySet()) {
+			attributes.put(s, e.getAttribute(s));
+		}
+		g.addEdge(idPrefix + e.getId(), idPrefix + e.getSourceNode().getId(), idPrefix + e.getTargetNode().getId());
+		g.getEdge(idPrefix + e.getId()).addAttributes(attributes);
+	}
+
+	@Override
+	public void addNode(Node n) {
+		// This function mustn't be called.
+		Debug.out("Someone called addNode(Node n) with a MappingGraphManager");
+	}
+
+	/**
+	 * Adds a <b>Copy</b> of the given Node to the graph. The Copy retains the
+	 * ID and all attributes but adds the ID prefix in front of the old ID.
+	 * 
+	 * @param n
+	 *            the Node to be added to the graph
+	 * @param idPrefix
+	 *            the String to be added as prefix to the ID
+	 */
+	private void addNode(Node n, String idPrefix) {
+		HashMap<String, Object> attributes = new HashMap<>();
+
+		for (String s : n.getAttributeKeySet()) {
+			attributes.put(s, n.getAttribute(s));
+		}
+		g.addNode(idPrefix + n.getId());
+		g.getNode(idPrefix + n.getId()).addAttributes(attributes);
+	}
+
+	@Override
+	public void nodeCreated(Node n, String graphID) {
+		Debug.out("Node " + n + " was added to Graph " + graphID);
+		if (graphID.equals(underlay.getGraph().getId()))
+			underlayNodesChanged = true;
+		else
+			operatorNodesChanged = true;
+	}
+
+	@Override
+	public void edgeCreated(Edge e, String graphID) {
+		Debug.out("Edge " + e + " was added to Graph " + graphID);
+		if (graphID.equals(underlay.getGraph().getId()))
+			addEdge(e, UNDERLAYER_PREFIX);
+		else
+			addEdge(e, OPERATOR_PREFIX);
+	}
+}

+ 2 - 2
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/main/MyGraph.java

@@ -89,7 +89,7 @@ public class MyGraph extends SingleGraph {
 	 */
 	private void edgeCreatedNotify(Edge e) {
 		for (EdgeCreatedListener list : allEdgeListeners) {
-			list.edgeCreated(e);
+			list.edgeCreated(e, id);
 		}
 	}
 
@@ -112,7 +112,7 @@ public class MyGraph extends SingleGraph {
 	 */
 	private void nodeCreatedNotify(Node n) {
 		for (NodeCreatedListener list : allNodeListeners) {
-			list.nodeCreated(n);
+			list.nodeCreated(n, id);
 		}
 	}
 

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

@@ -4,5 +4,5 @@ import org.graphstream.graph.Node;
 
 public interface NodeCreatedListener {
 
-	public void nodeCreated(Node n);
+	public void nodeCreated(Node n, String graphID);
 }

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

@@ -5,12 +5,12 @@ import java.util.ArrayList;
 import org.graphstream.graph.Edge;
 import org.graphstream.graph.Graph;
 import org.graphstream.graph.Node;
-import org.graphstream.graph.implementations.DefaultGraph;
 import org.graphstream.graph.implementations.Graphs;
 
 import de.tu_darmstadt.informatik.tk.scopviz.main.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.MyGraph;
 import javafx.beans.value.ObservableValue;
 import javafx.event.ActionEvent;
 import javafx.scene.control.Button;
@@ -120,8 +120,7 @@ public final class ButtonManager {
 		}
 
 		// add a copy of the underlay graph to the the symbol layer
-		DefaultGraph gClone = (DefaultGraph) Graphs
-				.clone(GraphDisplayManager.getGraphManager(Layer.UNDERLAY).getGraph());
+		MyGraph gClone = (MyGraph) Graphs.clone(GraphDisplayManager.getGraphManager(Layer.UNDERLAY).getGraph());
 		gClone.removeAttribute("layer");
 		GraphDisplayManager.setCurrentLayer(Layer.SYMBOL);
 		GraphDisplayManager.addGraph(gClone, true);

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

@@ -187,9 +187,12 @@ public class GUIController implements Initializable {
 		// Hide SymbolRep Toolbox View
 		symbolToolVBox.setVisible(false);
 
-		edgesVisibleCheckbox.selectedProperty().addListener((ov, oldVal, newVal) -> ButtonManager.edgeVisibleSwitch(ov, oldVal, newVal));
-		nodeLabelCheckbox.selectedProperty().addListener((ov, oldVal, newVal) -> ButtonManager.labelVisibilitySwitcher(ov, oldVal, newVal));
-		edgeWeightCheckbox.selectedProperty().addListener((ov, oldVal, newVal) -> ButtonManager.edgeWeightVisibilitySwitcher(ov, oldVal, newVal));
+		edgesVisibleCheckbox.selectedProperty()
+				.addListener((ov, oldVal, newVal) -> ButtonManager.edgeVisibleSwitch(ov, oldVal, newVal));
+		nodeLabelCheckbox.selectedProperty()
+				.addListener((ov, oldVal, newVal) -> ButtonManager.labelVisibilitySwitcher(ov, oldVal, newVal));
+		edgeWeightCheckbox.selectedProperty()
+				.addListener((ov, oldVal, newVal) -> ButtonManager.edgeWeightVisibilitySwitcher(ov, oldVal, newVal));
 	}
 
 	/**
@@ -200,13 +203,13 @@ public class GUIController implements Initializable {
 		operatorButton.setOnAction((event) -> ButtonManager.operatorAction(event));
 		mappingButton.setOnAction((event) -> ButtonManager.mappingAction(event));
 		symbolRepButton.setOnAction((event) -> ButtonManager.symbolRepAction(event));
-		
+
 		ArrayList<Button> layerButtons = new ArrayList<Button>();
 		layerButtons.add(underlayButton);
 		layerButtons.add(operatorButton);
 		layerButtons.add(mappingButton);
 		layerButtons.add(symbolRepButton);
-		ButtonManager.initialize(layerButtons, this,underlayButton);
+		ButtonManager.initialize(layerButtons, this, underlayButton);
 	}
 
 	/**

+ 61 - 16
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/GraphDisplayManager.java

@@ -5,14 +5,14 @@ import java.net.URL;
 import java.util.ArrayList;
 
 import org.apache.commons.math3.exception.NullArgumentException;
-import org.graphstream.graph.Graph;
-import org.graphstream.graph.implementations.SingleGraph;
 
+import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
 import de.tu_darmstadt.informatik.tk.scopviz.io.GraphMLImporter;
 import de.tu_darmstadt.informatik.tk.scopviz.main.CreationMode;
 import de.tu_darmstadt.informatik.tk.scopviz.main.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.MappingGraphManager;
 import de.tu_darmstadt.informatik.tk.scopviz.main.MyGraph;
 import javafx.event.EventHandler;
 import javafx.scene.input.ScrollEvent;
@@ -48,7 +48,7 @@ public final class GraphDisplayManager {
 	 * An empty GraphManager to use with Layers not yet filled with another
 	 * GraphManager.
 	 */
-	private final static GraphManager emptyLayer = new GraphManager(new SingleGraph("g"));
+	private final static GraphManager emptyLayer = new GraphManager(new MyGraph("g"));
 
 	/** Importer for loading Graphs from Disk */
 	private static GraphMLImporter importer = new GraphMLImporter();
@@ -72,8 +72,9 @@ public final class GraphDisplayManager {
 		addGraph();
 		currentLayer = Layer.OPERATOR;
 		addGraph();
-		currentLayer = Layer.MAPPING;
-		addGraph();
+		/*
+		 * currentLayer = Layer.MAPPING; addGraph();
+		 */
 		currentLayer = Layer.SYMBOL;
 		addGraph();
 		currentLayer = Layer.UNDERLAY;
@@ -86,7 +87,7 @@ public final class GraphDisplayManager {
 	 */
 	public static int addGraph() {
 		String id = getGraphStringID(count);
-		Graph g = new MyGraph(id);
+		MyGraph g = new MyGraph(id);
 		return addGraph(g, true);
 	}
 
@@ -103,7 +104,7 @@ public final class GraphDisplayManager {
 	 */
 	public static int addGraph(String fileName, boolean replaceCurrent) {
 		String id = getGraphStringID(count);
-		Graph g = importer.readGraph(id, Main.class.getResource(fileName));
+		MyGraph g = importer.readGraph(id, Main.class.getResource(fileName));
 		return addGraph(g, replaceCurrent);
 	}
 
@@ -119,7 +120,7 @@ public final class GraphDisplayManager {
 	 */
 	public static int addGraph(Stage stage, boolean replaceCurrent) {
 		String id = getGraphStringID(count);
-		Graph g = importer.readGraph(id, stage);
+		MyGraph g = importer.readGraph(id, stage);
 		if (g == null) {
 			return currentGraphManager;
 		}
@@ -138,7 +139,7 @@ public final class GraphDisplayManager {
 	 */
 	public static int addGraph(URL fileURL, boolean currentLayer) {
 		String id = getGraphStringID(count);
-		Graph g = importer.readGraph(id, fileURL);
+		MyGraph g = importer.readGraph(id, fileURL);
 		return addGraph(g, currentLayer);
 	}
 
@@ -153,7 +154,7 @@ public final class GraphDisplayManager {
 	 *            the current layer, if false they will be merged.
 	 * @return the id to access the specific graph
 	 */
-	public static int addGraph(Graph g, boolean replaceCurrent) {
+	public static int addGraph(MyGraph g, boolean replaceCurrent) {
 		if (g == null) {
 			throw new NullArgumentException();
 		}
@@ -185,12 +186,12 @@ public final class GraphDisplayManager {
 	 * Removes all GraphManagers from the current Layer.
 	 */
 	private static void removeAllCurrentGraphs() {
-		// TODO weird multithread behavior
+		// TODO weird multithread behavior, count auskommentier fuer matthias
 		for (int i = 0; i < vList.size(); i++) {
 			GraphManager man = vList.get(i);
 			if (man.getGraph().getAttribute("layer").equals(currentLayer)) {
 				vList.remove(i);
-				count--;
+				// count--;
 			}
 		}
 	}
@@ -247,13 +248,14 @@ public final class GraphDisplayManager {
 		}
 		return emptyLayer;
 	}
-	
+
 	/**
 	 * Returns the GraphManager for the given layer.
 	 * 
-	 * @param l the given layer
-	 * @return the GraphManager for the given Layer, or an empty GraphManager
-	 *         if none is found
+	 * @param l
+	 *            the given layer
+	 * @return the GraphManager for the given Layer, or an empty GraphManager if
+	 *         none is found
 	 */
 	public static GraphManager getGraphManager(Layer l) {
 		for (GraphManager man : vList) {
@@ -280,9 +282,52 @@ public final class GraphDisplayManager {
 	 *            the layer to switch to
 	 */
 	public static void setCurrentLayer(Layer currentLayer) {
+		if (currentLayer.equals(Layer.MAPPING)) {
+			initMappingLayer();
+		}
 		GraphDisplayManager.currentLayer = currentLayer;
 	}
 
+	private static void initMappingLayer() {
+		GraphManager underlay = null, operator = null;
+		MappingGraphManager mapping = null;
+		for (GraphManager man : vList) {
+			if (man.getGraph().getAttribute("layer").equals(Layer.UNDERLAY))
+				underlay = man;
+			else if (man.getGraph().getAttribute("layer").equals(Layer.OPERATOR))
+				operator = man;
+			else if (man.getGraph().getAttribute("layer").equals(Layer.MAPPING)
+					&& MappingGraphManager.class.isInstance(man))
+				mapping = (MappingGraphManager) man;
+		}
+		if (underlay == null) {
+			Debug.out("no Underlay found");
+			return;
+		}
+		if (operator == null) {
+			Debug.out("no Operator found");
+			return;
+		}
+		if (mapping == null || !mapping.hasGraphManagerAsParent(underlay)
+				|| !mapping.hasGraphManagerAsParent(operator)) {
+			Debug.out("no Mapping found");
+			MyGraph g;
+			g = new MyGraph(getGraphStringID(count));
+			count++;
+			mapping = new MappingGraphManager(g, underlay, operator);
+			g.addAttribute("layer", Layer.MAPPING);
+			g.addAttribute("ui.antialias");
+			mapping.setStylesheet(OptionsManager.DEFAULT_STYLESHEET);
+			vList.add(mapping);
+
+			underlay.addEdgeCreatedListener(mapping);
+			underlay.addNodeCreatedListener(mapping);
+			operator.addEdgeCreatedListener(mapping);
+			operator.addNodeCreatedListener(mapping);
+		}
+		mapping.activated();
+	}
+
 	/**
 	 * Handler for Scrolling while the Mouse is over the Graph Display Window.
 	 */

+ 5 - 4
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/PropertiesManager.java

@@ -154,7 +154,7 @@ public final class PropertiesManager {
 			final ContextMenu menuOnNonEmptyRows = new ContextMenu();
 			final MenuItem addPropMenuItem = new MenuItem("Add..");
 			final MenuItem deletePropMenuItem = new MenuItem("Delete");
-			
+
 			// ContextMenu on empty rows (only add)
 			final ContextMenu menuOnEmptyRows = new ContextMenu();
 			final MenuItem onlyAddPropMenuItem = new MenuItem("Add..");
@@ -162,9 +162,9 @@ public final class PropertiesManager {
 			// add functionality
 			onlyAddPropMenuItem.setOnAction(addPropHandler);
 			addPropMenuItem.setOnAction(addPropHandler);
-			
+
 			// delete functionality
-			deletePropMenuItem.setOnAction(new EventHandler<ActionEvent>() { 
+			deletePropMenuItem.setOnAction(new EventHandler<ActionEvent>() {
 				@Override
 				public void handle(ActionEvent event) {
 					Debug.out("Remove Element");
@@ -177,7 +177,8 @@ public final class PropertiesManager {
 			menuOnEmptyRows.getItems().add(onlyAddPropMenuItem);
 			menuOnNonEmptyRows.getItems().addAll(addPropMenuItem, deletePropMenuItem);
 
-			// when empty row right-clicked open special menu (only add), otherwise normal menu (add & delete)
+			// when empty row right-clicked open special menu (only add),
+			// otherwise normal menu (add & delete)
 			row.contextMenuProperty().bind(Bindings.when(Bindings.isNotNull(row.itemProperty()))
 					.then(menuOnNonEmptyRows).otherwise(menuOnEmptyRows));
 

+ 9 - 11
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/ToolboxManager.java

@@ -1,7 +1,5 @@
 package de.tu_darmstadt.informatik.tk.scopviz.ui;
 
-import javax.swing.text.ChangedCharSetException;
-
 import de.tu_darmstadt.informatik.tk.scopviz.main.CreationMode;
 import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
 import de.tu_darmstadt.informatik.tk.scopviz.main.MainApp;
@@ -91,7 +89,7 @@ public final class ToolboxManager {
 				// clicking on text part
 				row = (TableRow<Pair<Object, String>>) node.getParent();
 			}
-			
+
 			// Set CreateModus based on pressed TableRow
 			if (!row.isEmpty()) {
 
@@ -111,10 +109,10 @@ public final class ToolboxManager {
 
 				} else if (rowString.equals("operator")) {
 					changeCreationMode(CreationMode.CREATE_OPERATOR_NODE);
-					
+
 				} else if (rowString.equals("Directed")) {
 					changeCreationMode(CreationMode.CREATE_DIRECTED_EDGE);
-					
+
 				} else if (rowString.equals("Undirected")) {
 					changeCreationMode(CreationMode.CREATE_UNDIRECTED_EDGE);
 				}
@@ -127,20 +125,20 @@ public final class ToolboxManager {
 		}
 
 	};
-	
+
 	/**
-	 * If currentMode already selected then deselect, otherwise set mode on currentMode
+	 * If currentMode already selected then deselect, otherwise set mode on
+	 * currentMode
+	 * 
 	 * @param currentMode
 	 */
-	private static void changeCreationMode(CreationMode currentMode){
-		
+	private static void changeCreationMode(CreationMode currentMode) {
+
 		if (Main.getInstance().getCreationMode().equals(currentMode))
 			Main.getInstance().setCreationMode(CreationMode.CREATE_NONE);
 		else
 			Main.getInstance().setCreationMode(currentMode);
 	}
-	
-	
 
 	// TODO: Create Documentation for this, together with Dominik, ich versteh
 	// das zeug hier net.

BIN
scopviz/src/main/resources/png/Thumbs.db