Browse Source

Finalized Multigraph selection

Jan Enders 8 years ago
parent
commit
0295637166

+ 24 - 1
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/graphs/GraphManager.java

@@ -37,6 +37,8 @@ public class GraphManager {
 	/** The Graph this instance of GraphManager manages. */
 	protected MyGraph g;
 
+	protected MyGraph activeSubGraph;
+	
 	/**
 	 * The Stylesheet for this Graph, excluding parts that can be set by
 	 * NodeGraphics.
@@ -372,6 +374,12 @@ public class GraphManager {
 		}
 		g.addEdge(e.getId(), (Node) e.getSourceNode(), (Node) e.getTargetNode(), e.isDirected());
 		g.getEdge(e.getId()).addAttributes(attributes);
+		
+		if (activeSubGraph != null){
+			activeSubGraph.addEdge(e.getId(), (Node) e.getSourceNode(), (Node) e.getTargetNode(), e.isDirected());
+			activeSubGraph.getEdge(e.getId()).addAttributes(attributes);
+			g.getEdge(e.getId()).addAttribute("originalElement", activeSubGraph.getId()+"+#"+e.getId());
+		}
 	}
 
 	/**
@@ -385,10 +393,16 @@ public class GraphManager {
 		HashMap<String, Object> attributes = new HashMap<>();
 
 		for (String s : n.getAttributeKeySet()) {
-			attributes.put(s, deletedNode.getAttribute(s));
+			attributes.put(s, n.getAttribute(s));
 		}
 		g.addNode(n.getId());
 		g.getNode(n.getId()).addAttributes(attributes);
+		
+		if (activeSubGraph != null){
+			activeSubGraph.addNode(n.getId());
+			activeSubGraph.getNode(n.getId()).addAttributes(attributes);
+			g.getNode(n.getId()).addAttribute("originalElement", activeSubGraph.getId()+"+#"+n.getId());
+		}
 	}
 
 	/**
@@ -588,6 +602,15 @@ public class GraphManager {
 			deselectNodesAfterEdgeCreation(lastClickedID);
 		lastClickedID = null;
 	}
+	
+	public void setActiveSubGraph(String id){
+		for (MyGraph subGraph: g.getAllSubGraphs()){
+			if (subGraph.getId().equals(id)){
+				activeSubGraph = subGraph;
+				return;
+			}
+		}
+	}
 
 	protected boolean addClass(String id, String className) {
 		Element e = getGraph().getEdge(id);

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

@@ -500,8 +500,6 @@ public final class ButtonManager {
 		}
 		controller.opGraphSelectionBox.getItems().add("Add...");
 
-		// Platform.runLater(() ->
-		// controller.opGraphSelectionBox.setValue(controller.opGraphSelectionBox.getItems().get(0)));
 	}
 
 	public static void addToOpGraphComboBox(String id) {
@@ -515,6 +513,7 @@ public final class ButtonManager {
 			Platform.runLater(() -> controller.opGraphSelectionBox.setValue(controller.opGraphSelectionBox.getItems()
 					.get(controller.opGraphSelectionBox.getItems().size() - 2)));
 		} else {
+			GraphDisplayManager.getGraphManager(Layer.OPERATOR).setActiveSubGraph(controller.opGraphSelectionBox.getValue());
 			// FIXME: aktuell zu bearbeitenden graphen im GraphManager setzen
 			// (erfordert Jaschas Implementierung)!
 		}

+ 1 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/ToolboxManager.java

@@ -398,6 +398,7 @@ public final class ToolboxManager {
 				GraphHelper.propagateAttribute(Main.getInstance().getGraphManager().getGraph(), actualNode,
 						"process-need", Double.parseDouble(result.get()));
 			}
+			PropertiesManager.setItemsProperties();
 		});
 	}
 }