Kaynağa Gözat

added operator nodes

Jascha Bohne 8 yıl önce
ebeveyn
işleme
ae15a533c9

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

@@ -9,5 +9,5 @@ package de.tu_darmstadt.informatik.tk.scopviz.main;
  *
  */
 public enum CreationMode {
-	CREATE_STANDARD_NODE, CREATE_SOURCE_NODE, CREATE_SINK_NODE, CREATE_PROC_NODE, CREATE_UNDIRECTED_EDGE, CREATE_DIRECTED_EDGE, CREATE_NONE
+	CREATE_STANDARD_NODE, CREATE_SOURCE_NODE, CREATE_SINK_NODE, CREATE_PROC_NODE, CREATE_OPERATOR_NODE, CREATE_UNDIRECTED_EDGE, CREATE_DIRECTED_EDGE, CREATE_NONE
 }

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

@@ -215,8 +215,9 @@ public class GraphManager {
 			Node n = g.getNode(nodeID);
 			// set selected node color to red
 			String nodeType = n.getAttribute("ui.class");
-			n.changeAttribute("ui.style", "fill-mode: image-scaled; fill-image: url('src/main/resources/png/"+ nodeType +"_red.png'); size: 15px;");
-			n.changeAttribute("ui.class", nodeType+"_red");
+			n.changeAttribute("ui.style", "fill-mode: image-scaled; fill-image: url('src/main/resources/png/" + nodeType
+					+ "_red.png'); size: 15px;");
+			n.changeAttribute("ui.class", nodeType + "_red");
 			PropertiesManager.setItemsProperties();
 		}
 	}
@@ -244,11 +245,11 @@ public class GraphManager {
 	// TODO call this before save
 	public void deselect() {
 		// Set last selected Edge Color to Black
-		if (getSelectedEdgeID() != null){
+		if (getSelectedEdgeID() != null) {
 			g.getEdge(getSelectedEdgeID()).changeAttribute("ui.style", "fill-color: #000000;");
 		}
 		// Set last selected Node color to black
-		else if (getSelectedNodeID() != null){
+		else if (getSelectedNodeID() != null) {
 			Node n = g.getNode(getSelectedNodeID());
 			String nodeType = n.getAttribute("ui.class");
 			n.removeAttribute("ui.style");

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

@@ -68,15 +68,15 @@ public final class GraphDisplayManager {
 	 */
 	public static void init(GUIController guiController) {
 		GraphDisplayManager.guiController = guiController;
-		
+
 		addGraph();
-	    currentLayer=Layer.OPERATOR;
+		currentLayer = Layer.OPERATOR;
 		addGraph();
-		currentLayer=Layer.MAPPING;
+		currentLayer = Layer.MAPPING;
 		addGraph();
-		currentLayer=Layer.SYMBOL;
+		currentLayer = Layer.SYMBOL;
 		addGraph();
-		currentLayer=Layer.UNDERLAY;
+		currentLayer = Layer.UNDERLAY;
 	}
 
 	/**

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

@@ -45,7 +45,8 @@ public final class OptionsManager {
 	public static final String STYLE_NODES_SPRITES = "node.standard{fill-mode: image-scaled; fill-image: url('src/main/resources/png/standard.png'); }"
 			+ "node.source{fill-mode: image-scaled; fill-image: url('src/main/resources/png/source.png'); }"
 			+ "node.procEn{fill-mode: image-scaled; fill-image: url('src/main/resources/png/procEn.png'); }"
-			+ "node.sink{fill-mode: image-scaled; fill-image: url('src/main/resources/png/sink.png'); }";
+			+ "node.sink{fill-mode: image-scaled; fill-image: url('src/main/resources/png/sink.png'); }"
+			+ "node.operator{fill-mode: image-scaled; fill-image: url('src/main/resources/png/operator.png'); }";
 
 	// SETTINGS
 	/** The Default Weight for all new Edges. */

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

@@ -62,7 +62,8 @@ public final class ToolboxManager {
 				pair(new Image(MainApp.class.getResource("/png/standard.png").toString()), "Standard"),
 				pair(new Image(MainApp.class.getResource("/png/source.png").toString()), "Source"),
 				pair(new Image(MainApp.class.getResource("/png/sink.png").toString()), "Sink"),
-				pair(new Image(MainApp.class.getResource("/png/procEn.png").toString()), "EnProc"), pair("", ""),
+				pair(new Image(MainApp.class.getResource("/png/procEn.png").toString()), "EnProc"),
+				pair(new Image(MainApp.class.getResource("/png/operator.png").toString()), "operator"), pair("", ""),
 				pair(new Image(MainApp.class.getResource("/png/dirEdge.png").toString()), "Directed"),
 				pair(new Image(MainApp.class.getResource("/png/undirEdge.png").toString()), "Undirected"));
 
@@ -120,6 +121,12 @@ public final class ToolboxManager {
 					else
 						main.setCreationMode(CreationMode.CREATE_PROC_NODE);
 
+				} else if (rowString.equals("operator")) {
+					if (main.getCreationMode().equals(CreationMode.CREATE_OPERATOR_NODE))
+						main.setCreationMode(CreationMode.CREATE_NONE);
+					else
+						main.setCreationMode(CreationMode.CREATE_OPERATOR_NODE);
+
 				} else if (rowString.equals("Directed")) {
 					if (main.getCreationMode().equals(CreationMode.CREATE_DIRECTED_EDGE))
 						main.setCreationMode(CreationMode.CREATE_NONE);

+ 13 - 2
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/handlers/MyMouseManager.java

@@ -122,6 +122,16 @@ public class MyMouseManager extends DefaultMouseManager {
 
 			break;
 
+		case CREATE_OPERATOR_NODE:
+			n = graph.addNode(Main.getInstance().getUnusedID());
+			n.setAttribute("xyz", cursorPos);
+			n.setAttribute("ui.class", "operator");
+			graphManager.selectNode(n.getId());
+			Debug.out("Added Operator Node with ID " + n.getId() + " at Position (" + cursorPos.x + "/" + cursorPos.y
+					+ ")");
+
+			break;
+
 		default:
 			break;
 		}
@@ -319,8 +329,9 @@ public class MyMouseManager extends DefaultMouseManager {
 	private void selectNodeForEdgeCreation(String nodeID) {
 		Node n = graphManager.getGraph().getNode(nodeID);
 		String nodeType = n.getAttribute("ui.class");
-		n.changeAttribute("ui.style", "fill-mode: image-scaled; fill-image: url('src/main/resources/png/"+ nodeType +"_green.png'); size: 15px;");
-		n.changeAttribute("ui.class", nodeType+"_green");
+		n.changeAttribute("ui.style", "fill-mode: image-scaled; fill-image: url('src/main/resources/png/" + nodeType
+				+ "_green.png'); size: 15px;");
+		n.changeAttribute("ui.class", nodeType + "_green");
 	}
 
 	/**