Jan Enders пре 8 година
родитељ
комит
8bf0bfb0d0

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

@@ -209,20 +209,14 @@ 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 +229,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 +244,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;
 	}

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

@@ -42,9 +42,9 @@ 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.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'); }";
 
 	// SETTINGS

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

@@ -59,10 +59,10 @@ 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("", ""),
 				pair(new Image(MainApp.class.getResource("/png/dirEdge.png").toString()), "Directed"),
 				pair(new Image(MainApp.class.getResource("/png/undirEdge.png").toString()), "Undirected"));
 

+ 9 - 3
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/handlers/MyMouseManager.java

@@ -317,7 +317,10 @@ 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 +330,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