mw59miro 7 years ago
parent
commit
d2f56b62a2

+ 9 - 10
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/graphs/GraphManager.java

@@ -261,7 +261,7 @@ public class GraphManager {
 			deselect();
 			this.selectedEdgeID = edgeID;
 
-			g.<MyEdge>getEdge(edgeID).addCSSClass("selected");
+			g.<MyEdge> getEdge(edgeID).addCSSClass("selected");
 			PropertiesManager.setItemsProperties();
 		}
 	}
@@ -273,11 +273,11 @@ public class GraphManager {
 	public void deselect() {
 		// Set last selected Edge Color to Black
 		if (getSelectedEdgeID() != null && g.getEdge(getSelectedEdgeID()) != null) {
-			g.<MyEdge>getEdge(getSelectedEdgeID()).removeCSSClass("selected");
+			g.<MyEdge> getEdge(getSelectedEdgeID()).removeCSSClass("selected");
 		}
 		// Set last selected Node color to black
 		else if (getSelectedNodeID() != null && g.getNode(getSelectedNodeID()) != null) {
-			g.<MyNode>getNode(getSelectedNodeID()).removeCSSClass("selected");
+			g.<MyNode> getNode(getSelectedNodeID()).removeCSSClass("selected");
 		}
 		PropertiesManager.setItemsProperties();
 		this.selectedNodeID = null;
@@ -505,11 +505,11 @@ public class GraphManager {
 
 			if (sourceNode.getAttribute("originalGraph").equals(activeSubGraph.getId())
 					&& targetNode.getAttribute("originalGraph").equals(activeSubGraph.getId())) {
-
 				g.addEdge(newID, from, to, isDirected);
-				activeSubGraph.addEdge(newID, from.substring(activeSubGraph.getId().length()),
-						to.substring(activeSubGraph.getId().length()), isDirected);
-				g.getEdge(newID).addAttribute("originalElement", activeSubGraph.getId() + "+#" + newID);
+				String newerID = Main.getInstance().getUnusedID(activeSubGraph);
+				activeSubGraph.addEdge(newerID, sourceNode.getAttribute("originalElement").toString().split("\\+#")[1],
+						targetNode.getAttribute("originalElement").toString().split("\\+#")[1], isDirected);
+				g.getEdge(newID).addAttribute("originalElement", activeSubGraph.getId() + "+#" + newerID);
 
 			} else {
 				Debug.out(sourceNode.getAttribute("originalGraph").toString()
@@ -656,9 +656,8 @@ public class GraphManager {
 		/*
 		 * TODO: nochmal angucken, wenn CSS Manager steht, ist gerade gehackt
 		 * damit, Vorführung läuft. return (nClass != null &&
-		 * (nClass.equals(className) ||
-		 * nClass.startsWith(className.concat(", ")) ||
-		 * nClass.contains(", ".concat(className))));
+		 * (nClass.equals(className) || nClass.startsWith(className.concat(", "
+		 * )) || nClass.contains(", ".concat(className))));
 		 */
 		return (nClass != null && nClass.contains(className));
 	}

+ 14 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/main/Main.java

@@ -4,6 +4,7 @@ import java.math.BigDecimal;
 import java.math.BigInteger;
 
 import de.tu_darmstadt.informatik.tk.scopviz.graphs.GraphManager;
+import de.tu_darmstadt.informatik.tk.scopviz.graphs.MyGraph;
 import de.tu_darmstadt.informatik.tk.scopviz.io.GraphMLExporter;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.GraphDisplayManager;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.OptionsManager;
@@ -106,6 +107,19 @@ public final class Main {
 		}
 	}
 
+	public String getUnusedID(MyGraph g) {
+		int i = 0;
+		while (true) {
+			String tempID = i + "";
+			if (g.getNode(tempID) == null && g.getEdge(tempID) == null
+					&& g.getNode(g.getId() + tempID) == null) {
+				return (tempID);
+			} else {
+				i++;
+			}
+		}
+	}
+
 	/**
 	 * Returns the primary Stage for the Application Window.
 	 *