Browse Source

Merge remote-tracking branch 'origin/Jascha'

Jan Enders 8 years ago
parent
commit
46abbc0144

+ 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
 }

+ 16 - 25
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/main/GraphManager.java

@@ -209,20 +209,15 @@ public class GraphManager {
 	 */
 	public void selectNode(String nodeID) {
 		if (nodeID != null && g.getNode(nodeID) != null) {
-
-			// set last selected node color to null
-			if (getSelectedNodeID() != null)
-				g.getNode(getSelectedNodeID()).changeAttribute("ui.style", "fill-color: #000000; size: 10px;");
-
-			// set last selected edge color to black
-			else if (getSelectedEdgeID() != null)
-				g.getEdge(getSelectedEdgeID()).changeAttribute("ui.style", "fill-color: #000000;");
-
+			deselect();
 			this.selectedNodeID = nodeID;
-			this.selectedEdgeID = null;
 
+			Node n = g.getNode(nodeID);
 			// set selected node color to red
-			g.getNode(nodeID).changeAttribute("ui.style", "fill-color: #FF0000; size: 15px;");
+			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");
 			PropertiesManager.setItemsProperties();
 		}
 	}
@@ -235,15 +230,7 @@ public class GraphManager {
 	 */
 	public void selectEdge(String edgeID) {
 		if (edgeID != null && g.getEdge(edgeID) != null) {
-			// Set last selected Edge Color to Black
-			if (getSelectedEdgeID() != null)
-				g.getEdge(getSelectedEdgeID()).changeAttribute("ui.style", "fill-color: #000000;");
-
-			// Set last selected Node color to black
-			else if (getSelectedNodeID() != null)
-				g.getNode(getSelectedNodeID()).changeAttribute("ui.style", "fill-color: #000000; size: 10px;");
-
-			this.selectedNodeID = null;
+			deselect();
 			this.selectedEdgeID = edgeID;
 
 			// set selected edge color to red
@@ -258,13 +245,17 @@ 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)
-			g.getNode(getSelectedNodeID()).changeAttribute("ui.style", "fill-color: #000000; size: 10px;");
-
+		else if (getSelectedNodeID() != null) {
+			Node n = g.getNode(getSelectedNodeID());
+			String nodeType = n.getAttribute("ui.class");
+			n.removeAttribute("ui.style");
+			n.changeAttribute("ui.style", "fill-color: #000000; size: 10px;");
+			n.changeAttribute("ui.class", nodeType.split("_")[0]);
+		}
 		this.selectedNodeID = null;
 		this.selectedEdgeID = null;
 	}

+ 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;
 	}
 
 	/**

+ 4 - 3
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/OptionsManager.java

@@ -42,10 +42,11 @@ public final class OptionsManager {
 	/**
 	 * Part of the stylesheet that styles the different Nodes with sprites.
 	 */
-	public static final String STYLE_NODES_SPRITES = "node.standard{fill-mode: image-scaled; fill-image: url('src/main/resources/png/node.png'); }"
+	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/enProc.png'); }"
-			+ "node.sink{fill-mode: image-scaled; fill-image: url('src/main/resources/png/sink.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.operator{fill-mode: image-scaled; fill-image: url('src/main/resources/png/operator.png'); }";
 
 	// SETTINGS
 	/** The Default Weight for all new Edges. */

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

@@ -59,10 +59,11 @@ public final class ToolboxManager {
 
 		@SuppressWarnings("unchecked")
 		ObservableList<Pair<Object, String>> data = FXCollections.observableArrayList(
-				pair(new Image(MainApp.class.getResource("/png/node.png").toString()), "Standard"),
+				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/enProc.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);

+ 20 - 3
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;
 		}
@@ -317,7 +327,11 @@ public class MyMouseManager extends DefaultMouseManager {
 	 *            the ID of the Node to select
 	 */
 	private void selectNodeForEdgeCreation(String nodeID) {
-		graphManager.getGraph().getNode(nodeID).changeAttribute("ui.style", "fill-color: #00FF00; size: 15px;");
+		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");
 	}
 
 	/**
@@ -327,7 +341,10 @@ public class MyMouseManager extends DefaultMouseManager {
 	 *            the Id of the node to deselect.
 	 */
 	private void deselectNodesAfterEdgeCreation(String nodeID) {
-		String uiStyle = "fill-color: #000000; size: 10px;";
-		graphManager.getGraph().getNode(nodeID).changeAttribute("ui.style", uiStyle);
+		Node n = graphManager.getGraph().getNode(nodeID);
+		String nodeType = n.getAttribute("ui.class");
+		n.removeAttribute("ui.style");
+		n.changeAttribute("ui.style", "fill-color: #000000; size: 10px;");
+		n.changeAttribute("ui.class", nodeType.split("_")[0]);
 	}
 }

+ 6 - 0
scopviz/src/main/resources/Example.graphml

@@ -7,32 +7,38 @@
 	<key id="attr0001" for="node" attr.name="Eigenschaft" attr.type="string"/>
 	<key id="attr0002" for="node" attr.name="y" attr.type="double"/>
 	<key id="attr0003" for="node" attr.name="x" attr.type="double"/>
+	<key id="attr0004" for="node" attr.name="ui.class"  attr.type="string" />
 	<graph id="Example" edgedefault="undirected">
 		<node id="A">
 			<data key="attr0000">A</data>
 			<data key="attr0001">test</data>
 			<data key="attr0002">100</data>
 			<data key="attr0003">100</data>
+			<data key="attr0004">standard</data>
 		</node>
 		<node id="B">
 			<data key="attr0000">B</data>
 			<data key="attr0002">200</data>
 			<data key="attr0003">100</data>
+			<data key="attr0004">sink</data>
 		</node>
 		<node id="C">
 			<data key="attr0000">C</data>
 			<data key="attr0002">100</data>
 			<data key="attr0003">200</data>
+			<data key="attr0004">source</data>
 		</node>
 		<node id="D">
 			<data key="attr0000">D</data>
 			<data key="attr0002">200</data>
 			<data key="attr0003">200</data>
+			<data key="attr0004">procEn</data>
 		</node>
 		<node id="E">
 			<data key="attr0000">E</data>
 			<data key="attr0002">185</data>
 			<data key="attr0003">135</data>
+			<data key="attr0004">operator</data>
 		</node>
 		<edge id="AB" source="A" target="B" directed="false">
 			<data key="attr0001">test</data>

BIN
scopviz/src/main/resources/png/node.png


BIN
scopviz/src/main/resources/png/operator.png


BIN
scopviz/src/main/resources/png/operator_green.png


BIN
scopviz/src/main/resources/png/operator_red.png


+ 0 - 0
scopviz/src/main/resources/png/enProc.png → scopviz/src/main/resources/png/procEn.png


BIN
scopviz/src/main/resources/png/procEn_green.png


BIN
scopviz/src/main/resources/png/procEn_red.png


BIN
scopviz/src/main/resources/png/sink.png


BIN
scopviz/src/main/resources/png/sink_green.png


BIN
scopviz/src/main/resources/png/sink_red.png


BIN
scopviz/src/main/resources/png/source_green.png


BIN
scopviz/src/main/resources/png/source_red.png


BIN
scopviz/src/main/resources/png/standard.png


BIN
scopviz/src/main/resources/png/standard_green.png


BIN
scopviz/src/main/resources/png/standard_red.png