Selaa lähdekoodia

added Attributepropagating

cleaned up some code
jascha Bohne 7 vuotta sitten
vanhempi
commit
0b8978a2e3

+ 52 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/graphs/GraphHelper.java

@@ -6,9 +6,11 @@ import java.util.Random;
 
 import org.graphstream.algorithm.Toolkit;
 import org.graphstream.graph.Edge;
+import org.graphstream.graph.Element;
 import org.graphstream.graph.Node;
 import org.graphstream.ui.geom.Point3;
 
+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.ui.OptionsManager;
 
@@ -67,6 +69,12 @@ public class GraphHelper {
 				if (target.getEdge(newId) == null) {
 					searchingForId = false;
 					target.addEdge(newId, newIds.get(e.getSourceNode().getId()), newIds.get(e.getTargetNode().getId()));
+					if(e.getAttribute("originalElement") == null) {
+						target.getEdge(newId).addAttribute("originalElement", source.getId().concat("+#" + e.getId()));
+					} else  {
+						target.getEdge(newId).addAttribute("originalElement",(Object) e.getAttribute("originalElement"));
+					}
+				
 				} else {
 					newId = newId.concat(String.valueOf((char) (ran.nextInt(52) + 'a')));
 				}
@@ -90,6 +98,11 @@ public class GraphHelper {
 					searchingForId = false;
 					target.addNode(newId);
 					newIds.put(n.getId(), newId);
+					if(n.getAttribute("originalElement") == null) {
+						target.getNode(newId).addAttribute("originalElement", source.getId().concat("+#" + n.getId()));
+					} else  {
+						target.getNode(newId).addAttribute("originalElement",(Object) n.getAttribute("originalElement"));
+					}
 				} else {
 					newId = newId.concat(String.valueOf((char) (ran.nextInt(52) + 'a')));
 				}
@@ -215,4 +228,43 @@ public class GraphHelper {
 			}
 		}
 	}
+	
+	public static void propagateAttribute (MyGraph g, Element n, String attribute, Object value){
+		if(n.getAttribute("originalElement") == null){
+			Debug.out("Debug: Attribute originalElement does not Exist");
+			return;
+		}
+		String origGraph = n.getAttribute("originalElement").toString().split("\\+#")[0];
+		String origNode = n.getAttribute("originalElement").toString().split("\\+#")[1];
+		Node oldNode = null;
+		Edge oldEdge = null;
+		MyGraph old = null;
+		Iterator<MyGraph> graphIter = g.getAllSubGraphs().iterator();
+		while(graphIter.hasNext()){
+			old = graphIter.next();
+			if(old.getId().equals(origGraph)){
+				Iterator<Node> nodeIter = old.getNodeIterator();
+				while (nodeIter.hasNext()){
+					oldNode = nodeIter.next();
+					if(oldNode.getId().equals(origNode)){
+						oldNode.addAttribute(attribute, value);
+						Debug.out("Debug: propagating successfull");
+						return;
+					}
+				}
+				Iterator<Edge> edgeIter = old.getEdgeIterator();
+				while (edgeIter.hasNext()){
+					oldEdge = edgeIter.next();
+					if(oldEdge.getId().equals(origNode)){
+						oldEdge.addAttribute(attribute, value);
+						Debug.out("Debug: propagating successfull");
+						return;
+					}
+				}
+				Debug.out("WARNING: could not find the specified Element " + origNode + " in the Graph " + origGraph, 2);
+				return;
+			}
+		}
+		Debug.out("WARNING: could not find the specified Graph " + origGraph, 2);
+	}
 }

+ 1 - 2
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/metrics/BasicMappingOperator.java

@@ -39,10 +39,9 @@ public class BasicMappingOperator implements ScopvizGraphOperator {
 			successfull = false;
 			while (procEnIterator.hasNext() && !successfull) {
 				successfull = map.createEdge(procEnIterator.next().getId(), n.getId());
-				Debug.out(new Boolean(successfull).toString());
 			}
 			if (!successfull) {
-				Debug.out("WARNING: BasicMappingOperator could not map all Nodes");
+				Debug.out("WARNING: BasicMappingOperator could not map all Nodes", 2);
 			}
 
 		}

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

@@ -4,10 +4,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashSet;
 
-<<<<<<< HEAD
 import org.jxmapviewer.viewer.GeoPosition;
-=======
->>>>>>> branch 'Jascha' of https://git.tk.informatik.tu-darmstadt.de/julien.gedeon/bp-scopviz.git
 import org.jxmapviewer.viewer.WaypointPainter;
 
 import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
@@ -265,19 +262,8 @@ public final class ButtonManager {
 
 		if (!(GraphDisplayManager.getCurrentLayer().equals(Layer.SYMBOL))) {
 
-<<<<<<< HEAD
-=======
-			// add a copy of the underlay graph to the the symbol layer
-			// TODO fix problem with underlay weight popups
-			// MyGraph gClone = (MyGraph)
-			// Graphs.clone(GraphDisplayManager.getGraphManager(Layer.UNDERLAY).getGraph());
-			// gClone.removeAttribute("layer");
->>>>>>> branch 'Jascha' of https://git.tk.informatik.tu-darmstadt.de/julien.gedeon/bp-scopviz.git
 			GraphDisplayManager.setCurrentLayer(Layer.SYMBOL);
-<<<<<<< HEAD
-=======
-			// GraphDisplayManager.addGraph(gClone, true);
->>>>>>> branch 'Jascha' of https://git.tk.informatik.tu-darmstadt.de/julien.gedeon/bp-scopviz.git
+
 			controller.topLeftAPane.getChildren().add(controller.symbolToolVBox);
 
 		}

+ 9 - 2
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/PropertiesManager.java

@@ -11,6 +11,7 @@ import org.graphstream.graph.Element;
 import org.graphstream.graph.Node;
 
 import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
+import de.tu_darmstadt.informatik.tk.scopviz.graphs.GraphHelper;
 import de.tu_darmstadt.informatik.tk.scopviz.graphs.GraphManager;
 import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
 import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
@@ -122,6 +123,7 @@ public final class PropertiesManager {
 		itemVisibilityRules.put("mapping-parent", -2);
 		itemVisibilityRules.put("mapping-parent-id", -2);
 		itemVisibilityRules.put("ui.class", -2);
+		itemVisibilityRules.put("originalNode", -2);
 
 	}
 
@@ -152,27 +154,32 @@ public final class PropertiesManager {
 			Element selected = getSelected();
 
 			// Type-Check the input
-			if (classType.equals(Integer.class) && newValue.matches(IS_INT)) {
+			if (classType.equals(Integer.class) && newValue.matches(IS_INT)){
+				GraphHelper.propagateAttribute(Main.getInstance().getGraphManager().getGraph(), selected, key, newValue);
 				selected.changeAttribute(key, Integer.valueOf(newValue));
 				editedPair.setValue(newValue);
 				Debug.out("Edited integer Attribute " + key);
 
 			} else if (classType.equals(Boolean.class) && newValue.matches(IS_BOOL)) {
+				GraphHelper.propagateAttribute(Main.getInstance().getGraphManager().getGraph(), selected, key, newValue);
 				selected.changeAttribute(key, Boolean.valueOf(newValue));
 				editedPair.setValue(newValue);
 				Debug.out("Edited boolean Attribute " + key);
 
 			} else if (classType.equals(Float.class) && newValue.matches(IS_FLOAT)) {
+				GraphHelper.propagateAttribute(Main.getInstance().getGraphManager().getGraph(), selected, key, newValue);
 				selected.changeAttribute(key, Float.valueOf(newValue));
 				editedPair.setValue(newValue);
 				Debug.out("Edited float Attribute " + key);
 
 			} else if (classType.equals(Double.class) && newValue.matches(IS_FLOAT)) {
+				GraphHelper.propagateAttribute(Main.getInstance().getGraphManager().getGraph(), selected, key, newValue);
 				selected.changeAttribute(key, Double.valueOf(newValue));
 				editedPair.setValue(newValue);
 				Debug.out("Edited double Attribute " + key);
 
 			} else if (classType.equals(String.class)) {
+				GraphHelper.propagateAttribute(Main.getInstance().getGraphManager().getGraph(), selected, key, newValue);
 				selected.changeAttribute(key, newValue);
 				editedPair.setValue(newValue);
 				Debug.out("Edited String Attribute " + key);
@@ -181,7 +188,7 @@ public final class PropertiesManager {
 				editedPair.setValue(oldValue);
 				t.getTableView().getItems().get(t.getTablePosition().getRow()).setKey(oldValue);
 				setItemsProperties();
-				Debug.out("invalid input for this attribute type");
+				Debug.out("WARNING: invalid input for this attribute type", 2);
 			}
 
 			// Unselect row after updating Property