Explorar o código

Merged Matthias, finally.

Jan Enders %!s(int64=7) %!d(string=hai) anos
pai
achega
b4fea0bab2

+ 197 - 12
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/main/GraphManager.java

@@ -7,6 +7,7 @@ import java.util.LinkedList;
 
 import org.graphstream.algorithm.Toolkit;
 import org.graphstream.graph.Edge;
+import org.graphstream.graph.Element;
 import org.graphstream.graph.Graph;
 import org.graphstream.graph.Node;
 import org.graphstream.ui.geom.Point3;
@@ -14,6 +15,8 @@ import org.graphstream.ui.swingViewer.ViewPanel;
 import org.graphstream.ui.view.Viewer;
 import org.graphstream.ui.view.ViewerPipe;
 
+import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
+import de.tu_darmstadt.informatik.tk.scopviz.ui.GraphDisplayManager;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.OptionsManager;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.PropertiesManager;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.StylesheetManager;
@@ -29,6 +32,7 @@ import de.tu_darmstadt.informatik.tk.scopviz.ui.handlers.MyMouseManager;
  *
  */
 public class GraphManager {
+	public static final String UI_CLASS_PROCESSING_ENABLED = "procEn";
 
 	/** The Graph this instance of GraphManager manages. */
 	protected MyGraph g;
@@ -63,6 +67,11 @@ public class GraphManager {
 	 */
 	protected ViewerPipe fromViewer;
 
+	/**
+	 * The Id of the Node that was last clicked.
+	 */
+	protected String lastClickedID;
+
 	/**
 	 * Creates a new Manager for the given graph.
 	 * 
@@ -207,10 +216,13 @@ 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");
+			if (!hasClass(n, UI_CLASS_PROCESSING_ENABLED)
+					|| !GraphDisplayManager.getCurrentLayer().equals(Layer.MAPPING)) {
+				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();
 		}
 	}
@@ -226,8 +238,10 @@ public class GraphManager {
 			deselect();
 			this.selectedEdgeID = edgeID;
 
+			addClass(edgeID, "selected");
 			// set selected edge color to red
-			g.getEdge(getSelectedEdgeID()).changeAttribute("ui.style", "fill-color: #FF0000;");
+			// g.getEdge(getSelectedEdgeID()).changeAttribute("ui.style",
+			// "fill-color: #FF0000;");
 			PropertiesManager.setItemsProperties();
 		}
 	}
@@ -239,15 +253,18 @@ public class GraphManager {
 	public void deselect() {
 		// Set last selected Edge Color to Black
 		if (getSelectedEdgeID() != null) {
-			g.getEdge(getSelectedEdgeID()).changeAttribute("ui.style", "fill-color: #000000;");
+			removeClass(getSelectedEdgeID(), "selected");
 		}
 		// Set last selected Node color to black
 		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]);
+			if (!hasClass(n, UI_CLASS_PROCESSING_ENABLED)
+					|| !GraphDisplayManager.getCurrentLayer().equals(Layer.MAPPING)) {
+				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;
@@ -518,8 +535,7 @@ public class GraphManager {
 	}
 
 	/**
-	 * Updates the implicit Stylesheet, causing any changes to it to come into
-	 * effect.
+	 * Updates the Stylesheet, causing any changes to it to come into effect.
 	 */
 	public void updateStylesheet() {
 		setStylesheet(this.stylesheet);
@@ -538,4 +554,173 @@ public class GraphManager {
 		}
 	}
 
+	/**
+	 * Create Edges based on CreateMode
+	 * 
+	 * @param id
+	 */
+	public void createEdges(String id) {
+		switch (Main.getInstance().getCreationMode()) {
+		case CREATE_DIRECTED_EDGE:
+		case CREATE_UNDIRECTED_EDGE:
+			if (lastClickedID == null) {
+				lastClickedID = id;
+				if (!selectNodeForEdgeCreation(lastClickedID))
+					lastClickedID = null;
+			} else if (id.equals(lastClickedID) || createEdge(id, lastClickedID)) {
+				deselectNodesAfterEdgeCreation(lastClickedID);
+				lastClickedID = null;
+			}
+			break;
+		default:
+			break;
+		}
+		PropertiesManager.setItemsProperties();
+
+		// controller.createModusText.setText(Main.getInstance().getCreationMode().toString());
+
+	}
+
+	/**
+	 * creates a edge between to nodes
+	 * 
+	 * @author MW
+	 * @param to
+	 *            ID of the destination node
+	 * @param from
+	 *            ID of the origin node
+	 * @return true if the edge was created. false otherwise
+	 */
+	public boolean createEdge(String to, String from) {
+		if (getGraph().getNode(from).hasEdgeBetween(to))
+			return false;
+		String newID = Main.getInstance().getUnusedID();
+
+		if (Main.getInstance().getCreationMode() == CreationMode.CREATE_DIRECTED_EDGE) {
+			getGraph().addEdge(newID, from, to, true);
+			Debug.out("Created an directed edge with Id " + newID + " between " + from + " and " + to);
+		} else {
+			getGraph().addEdge(newID, from, to);
+			Debug.out("Created an undirected edge with Id " + newID + " between " + from + " and " + to);
+		}
+
+		selectEdge(newID);
+
+		return true;
+	}
+
+	/**
+	 * Selects a Node as the starting point for creating a new Edge.
+	 * 
+	 * @param nodeID
+	 *            the ID of the Node to select
+	 */
+	public boolean selectNodeForEdgeCreation(String nodeID) {
+		deselect();
+		Node n = getGraph().getNode(nodeID);
+		String nodeType = n.getAttribute("ui.class");
+		if (!hasClass(n, UI_CLASS_PROCESSING_ENABLED) || !GraphDisplayManager.getCurrentLayer().equals(Layer.MAPPING)) {
+			nodeType = nodeType.split("_")[0];
+			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");
+		}
+		return true;
+	}
+
+	/**
+	 * Reset the Selection of the Node after Edge has been successfully created.
+	 * 
+	 * @param nodeID
+	 *            the Id of the node to deselect.
+	 */
+	public void deselectNodesAfterEdgeCreation(String nodeID) {
+		Node n = getGraph().getNode(nodeID);
+		if (!hasClass(n, UI_CLASS_PROCESSING_ENABLED) || !GraphDisplayManager.getCurrentLayer().equals(Layer.MAPPING)) {
+			String nodeType = n.getAttribute("ui.class");
+			n.changeAttribute("ui.style", "fill-color: #000000; size: 10px;");
+			n.changeAttribute("ui.class", nodeType.split("_")[0]);
+		}
+	}
+
+	public boolean addClass(String id, String className) {
+		Element e = getGraph().getEdge(id);
+		if (e == null)
+			e = getGraph().getNode(id);
+		if (e == null)
+			return false;
+		String eClass = e.getAttribute("ui.class");
+		if (eClass == null || eClass.equals(""))
+			eClass = className;
+		else if (!(eClass.equals(className) || eClass.startsWith(className.concat(", "))
+				|| eClass.contains(", ".concat(className))))
+			eClass = className.concat(", ").concat(eClass);
+
+		e.addAttribute("ui.class", eClass);
+		Debug.out("added " + className + ": " + eClass);
+		return true;
+	}
+
+	public boolean removeClass(String id, String className) {
+		Element e = getGraph().getEdge(id);
+		if (e == null)
+			e = getGraph().getNode(id);
+		if (e == null)
+			return false;
+		String eClass = e.getAttribute("ui.class");
+		if (eClass == null || eClass.equals(className))
+			eClass = "";
+		else
+			eClass = eClass.replace(className.concat(", "), "").replace(", ".concat(className), "");
+
+		e.addAttribute("ui.class", eClass);
+		Debug.out("removed " + className + ": " + eClass);
+		return true;
+	}
+
+	public boolean toggleClass(String id, String className) {
+		Element e = getGraph().getEdge(id);
+		if (e == null)
+			e = getGraph().getNode(id);
+		if (e == null)
+			return false;
+		String eClass = e.getAttribute("ui.class");
+		if (eClass == null || !(eClass.equals(className) || eClass.startsWith(className.concat(", "))
+				|| eClass.contains(", ".concat(className))))
+			return addClass(id, className);
+		return removeClass(id, className);
+	}
+
+	public boolean hasClass(String id, String className) {
+		Element e = getGraph().getEdge(id);
+		if (e == null)
+			e = getGraph().getNode(id);
+		if (e == null)
+			return false;
+		String eClass = e.getAttribute("ui.class");
+		return (eClass != null && (eClass.equals(className) || eClass.startsWith(className.concat(", "))
+				|| eClass.contains(", ".concat(className))));
+	}
+
+	public boolean hasClass(Edge e, String className) {
+		if (e == null)
+			return false;
+		String eClass = e.getAttribute("ui.class");
+		return (eClass != null && (eClass.equals(className) || eClass.startsWith(className.concat(", "))
+				|| eClass.contains(", ".concat(className))));
+	}
+
+	public boolean hasClass(Node n, String className) {
+		if (n == null)
+			return false;
+		String nClass = n.getAttribute("ui.class");
+		/*
+		 * TODO: nochmal angucken, wenn CSS Manager steht, ist gerade gehackt
+		 * damit, Vorführung läuft. return (nClass != null &&
+		 * (nClass.equals(className) ||
+		 * nClass.startsWith(className.concat(", ")) ||
+		 * nClass.contains(", ".concat(className))));
+		 */
+		return (nClass != null && nClass.contains(className));
+	}
 }

+ 273 - 16
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/main/MappingGraphManager.java

@@ -8,76 +8,179 @@ import org.graphstream.graph.Node;
 
 import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
 
+/**
+ * Class extending GraphManager. Offers the possibility to merge an underlay and
+ * an operator graph.
+ * 
+ * 
+ * @author Matthias Wilhelm
+ *
+ */
 public class MappingGraphManager extends GraphManager implements EdgeCreatedListener, NodeCreatedListener {
-	public static final String UNDERLAYER_PREFIX = "underlay";
-	public static final String OPERATOR_PREFIX = "operator";
+	public static final String UNDERLAY = "underlay";
+	public static final String OPERATOR = "operator";
+
+	public static final String ATTRIBUTE_KEY_PROCESS_NEED = "process-need";
+	public static final String ATTRIBUTE_KEY_PROCESS_USE = "process-use";
+	public static final String ATTRIBUTE_KEY_PROCESS_MAX = "process-max";
+	public static final String ATTRIBUTE_KEY_MAPPING = "mapping";
+	public static final String ATTRIBUTE_KEY_MAPPING_PARENT = "mapping-parent";
+	public static final String ATTRIBUTE_KEY_MAPPING_PARENT_ID = "mapping-parent-id";
+	public static final String UI_CLASS_MAPPING = "mapping";
+
 	private static final double UNDERLAYER_MOVE_Y = 0;
 	private static final double OPERATOR_MOVE_Y = 1.5;
+
+	// Variables to keep track of new Nodes in the parent graphs
 	private boolean underlayNodesChanged = false;
 	private boolean operatorNodesChanged = false;
 
+	// References to the parent graphs
 	GraphManager underlay, operator;
+	HashMap<String, String> parentsID;;
 
+	/**
+	 * Creates a new manager for an empty graph. there is no need to check for
+	 * unique ID's for nodes and edges.
+	 * 
+	 * @param graph
+	 *            assumes a empty graph
+	 * @param underlay
+	 *            the underlay graph
+	 * @param operator
+	 *            the operator graph
+	 */
 	public MappingGraphManager(MyGraph graph, GraphManager underlay, GraphManager operator) {
 		super(graph);
+
+		underlay.deselect();
+		operator.deselect();
+
 		this.underlay = underlay;
 		this.operator = operator;
+
+		parentsID = new HashMap<>();
+		parentsID.put(UNDERLAY, underlay.getGraph().getId());
+		parentsID.put(OPERATOR, operator.getGraph().getId());
+
 		Debug.out("Created a new Mapping");
-		mergeGraph(underlay, UNDERLAYER_PREFIX, UNDERLAYER_MOVE_Y);
-		mergeGraph(operator, OPERATOR_PREFIX, OPERATOR_MOVE_Y);
+
+		mergeGraph(underlay, UNDERLAY, UNDERLAYER_MOVE_Y);
+		mergeGraph(operator, OPERATOR, OPERATOR_MOVE_Y);
+
 		view.getCamera().resetView();
 	}
 
+	/**
+	 * Adds all nodes and edges of the given graph, adds a prefix to the ID of
+	 * every node and edge and offsets the normalized coordinates in y
+	 * direction.
+	 * 
+	 * @param gm
+	 *            the graph to be added
+	 * @param idPrefix
+	 *            the prefix for the ID of every node and edge
+	 * @param moveY
+	 *            the offset of the y coordinate
+	 */
 	private void mergeGraph(GraphManager gm, String idPrefix, double moveY) {
-
 		mergeNodes(gm, idPrefix, moveY);
+
+		// TODO: Debug only
 		int i = 0;
+
 		for (Edge edge : gm.getGraph().getEdgeSet()) {
 			addEdge(edge, idPrefix);
+
+			// TODO: Debug only
 			i++;
 		}
+
 		Debug.out("added " + i + " Edge" + (i == 1 ? "" : "s") + " from \"" + idPrefix + "\"");
 	}
 
+	/**
+	 * Adds all nodes of the given graph, adds a prefix to the ID of every node
+	 * and offsets the normalized coordinates in y direction.
+	 * 
+	 * @param gm
+	 *            the graph to be added
+	 * @param idPrefix
+	 *            the prefix for the ID of every node
+	 * @param moveY
+	 *            the offset of the y coordinate
+	 */
 	private void mergeNodes(GraphManager gm, String idPrefix, double moveY) {
-		int i = 0;
+		// precalculate scale and offset to normalize x coordinates
 		double maxX = gm.getMaxX();
 		double minX = gm.getMinX();
 		double scaleX = 1 / (maxX - minX);
 		double addX = -minX * scaleX;
+
+		// precalculate scale and offset to normalize y coordinates
 		double maxY = gm.getMaxY();
 		double minY = gm.getMinY();
 		double scaleY = 1 / (maxY - minY);
-		double addY = -minY * scaleY;
+		double addY = -minY * scaleY + moveY;
+
+		// TODO: Debug only
+		int i = 0;
+
+		// loops through all nodes, adds them if they don't exist already and
+		// normalizes their coordinates
 		for (Node node : gm.getGraph().getNodeSet()) {
+			// add node if it doesn't exist
 			Node newNode = getGraph().getNode(idPrefix + node.getId());
 			if (newNode == null) {
 				addNode(node, idPrefix);
 				newNode = getGraph().getNode(idPrefix + node.getId());
+
+				// TODO: Debug only
 				i++;
 			}
+
+			// normalize coordinates
 			double[] n = Toolkit.nodePosition(node);
 			double cX = n[0];
 			double x = cX * scaleX + addX;
 			double cY = n[1];
-			double y = cY * scaleY + addY + moveY;
+			double y = cY * scaleY + addY;
 			newNode.changeAttribute("x", x);
 			newNode.changeAttribute("y", y);
+
+			if (hasClass(newNode, UI_CLASS_PROCESSING_ENABLED))
+				initCapacity(newNode);
+
 		}
+
 		Debug.out("added " + i + " Node" + (i == 1 ? "" : "s") + " from \"" + idPrefix + "\"");
 	}
 
+	/**
+	 * Gets invoked by the GraphDisplayManager every time the mapping layer is
+	 * loaded. Checks whether nodes have been added to the parent graphs
+	 */
 	public void activated() {
 		if (underlayNodesChanged) {
-			mergeNodes(underlay, UNDERLAYER_PREFIX, UNDERLAYER_MOVE_Y);
+			mergeNodes(underlay, UNDERLAY, UNDERLAYER_MOVE_Y);
 			underlayNodesChanged = false;
 		}
+
 		if (operatorNodesChanged) {
-			mergeNodes(operator, OPERATOR_PREFIX, OPERATOR_MOVE_Y);
+			mergeNodes(operator, OPERATOR, OPERATOR_MOVE_Y);
 			operatorNodesChanged = false;
 		}
 	}
 
+	/**
+	 * Checks whether the given graph is underlay or operator graph to this
+	 * object or not.
+	 * 
+	 * @param gm
+	 *            the graph to check
+	 * @return true if the given graph is underlay or operator graph to this
+	 *         graph. false otherwise
+	 */
 	public boolean hasGraphManagerAsParent(GraphManager gm) {
 		return (underlay.getGraph().getId().equals(gm.getGraph().getId()))
 				|| (operator.getGraph().getId().equals(gm.getGraph().getId()));
@@ -98,6 +201,11 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
 		for (String s : e.getAttributeKeySet()) {
 			attributes.put(s, e.getAttribute(s));
 		}
+
+		attributes.put(ATTRIBUTE_KEY_MAPPING, false);
+		attributes.put(ATTRIBUTE_KEY_MAPPING_PARENT, idPrefix);
+		attributes.put(ATTRIBUTE_KEY_MAPPING_PARENT_ID, parentsID.get(idPrefix));
+
 		g.addEdge(idPrefix + e.getId(), idPrefix + e.getSourceNode().getId(), idPrefix + e.getTargetNode().getId());
 		g.getEdge(idPrefix + e.getId()).addAttributes(attributes);
 	}
@@ -123,25 +231,174 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
 		for (String s : n.getAttributeKeySet()) {
 			attributes.put(s, n.getAttribute(s));
 		}
+
+		attributes.put(ATTRIBUTE_KEY_MAPPING_PARENT, idPrefix);
+		attributes.put(ATTRIBUTE_KEY_MAPPING_PARENT_ID, parentsID.get(idPrefix));
+
 		g.addNode(idPrefix + n.getId());
 		g.getNode(idPrefix + n.getId()).addAttributes(attributes);
 	}
 
 	@Override
 	public void nodeCreated(Node n, String graphID) {
-		Debug.out("Node " + n + " was added to Graph " + graphID);
 		if (graphID.equals(underlay.getGraph().getId()))
 			underlayNodesChanged = true;
-		else
+		else if (graphID.equals(operator.getGraph().getId()))
 			operatorNodesChanged = true;
 	}
 
 	@Override
 	public void edgeCreated(Edge e, String graphID) {
-		Debug.out("Edge " + e + " was added to Graph " + graphID);
 		if (graphID.equals(underlay.getGraph().getId()))
-			addEdge(e, UNDERLAYER_PREFIX);
-		else
-			addEdge(e, OPERATOR_PREFIX);
+			addEdge(e, UNDERLAY);
+		else if (graphID.equals(operator.getGraph().getId()))
+			addEdge(e, OPERATOR);
 	}
+
+	@Override
+	public void createEdges(String id) {
+		super.createEdges(id);
+
+		if (lastClickedID != null) {
+			Double need = g.getNode(lastClickedID).getAttribute(ATTRIBUTE_KEY_PROCESS_NEED);
+			if (need != null)
+				for (Node n : g.getNodeSet())
+					if (hasClass(n, UI_CLASS_PROCESSING_ENABLED))
+						showExpectedCapacity(n, need);
+		} else {
+			for (Node n : g.getNodeSet())
+				if (hasClass(n, UI_CLASS_PROCESSING_ENABLED))
+					showExpectedCapacity(n, 0);
+		}
+	}
+
+	/**
+	 * checks whether the Node can handle the load first.<br/>
+	 * creates a edge between to nodes
+	 */
+	@Override
+	public boolean createEdge(String to, String from) {
+		Node fromNode = getGraph().getNode(from);
+		Node toNode = getGraph().getNode(to);
+
+		if (fromNode.hasEdgeBetween(to))
+			return false;
+
+		String fromParent = fromNode.getAttribute(ATTRIBUTE_KEY_MAPPING_PARENT);
+		String toParent = toNode.getAttribute(ATTRIBUTE_KEY_MAPPING_PARENT);
+
+		if (fromParent == null || toParent == null)
+			return false;
+		if (fromParent.equals(toParent)) {
+			deselectNodesAfterEdgeCreation(lastClickedID);
+			lastClickedID = to;
+			selectNodeForEdgeCreation(lastClickedID);
+			return false;
+		}
+
+		String newID = Main.getInstance().getUnusedID();
+
+		Edge e;
+
+		Node underlayNode;
+		Node operatorNode;
+		if (fromParent.equals(UNDERLAY)) {
+			underlayNode = fromNode;
+			operatorNode = toNode;
+		} else if (toParent.equals(UNDERLAY)) {
+			underlayNode = toNode;
+			operatorNode = fromNode;
+		} else
+			return false;
+
+		// check if processing enabled node
+		if (!hasClass(underlayNode, UI_CLASS_PROCESSING_ENABLED))
+			return false;
+
+		// check and update capacity
+		if (!updatedCapacity(underlayNode, operatorNode))
+			return false;
+
+		e = getGraph().addEdge(newID, operatorNode, underlayNode, true);
+		Debug.out("Created an directed edge with Id " + newID + " from " + operatorNode + " to " + underlayNode);
+
+		e.addAttribute("ui.class", UI_CLASS_MAPPING);
+		e.addAttribute(ATTRIBUTE_KEY_MAPPING, true);
+
+		selectEdge(newID);
+		return true;
+	}
+
+	private void initCapacity(Node underlayNode) {
+		Double used = underlayNode.getAttribute(ATTRIBUTE_KEY_PROCESS_USE);
+		Double max = underlayNode.getAttribute(ATTRIBUTE_KEY_PROCESS_MAX);
+		if (max == null || max == 0)
+			return;
+		if (used == null)
+			used = new Double(0);
+		double[] pieValues = { used / max, 0, 1 - used / max };
+		underlayNode.setAttribute("ui.pie-values", pieValues);
+		underlayNode.setAttribute(ATTRIBUTE_KEY_PROCESS_USE, used);
+	}
+
+	private boolean updatedCapacity(Node underlayNode, Node operatorNode) {
+		Double needed = operatorNode.getAttribute(ATTRIBUTE_KEY_PROCESS_NEED);
+		Double used = underlayNode.getAttribute(ATTRIBUTE_KEY_PROCESS_USE);
+		Double max = underlayNode.getAttribute(ATTRIBUTE_KEY_PROCESS_MAX);
+
+		if (needed == null)
+			return true;
+		if (max == null || max == 0)
+			if (needed > 0)
+				return false;
+			else
+				return true;
+		if (used == null)
+			used = new Double(0);
+		if (used + needed > max)
+			return false;
+		used += needed;
+		double[] pieValues = { used / max, 0, 1 - used / max };
+		underlayNode.setAttribute("ui.pie-values", pieValues);
+		underlayNode.setAttribute(ATTRIBUTE_KEY_PROCESS_USE, used);
+		return true;
+	}
+
+	private void showExpectedCapacity(Node underlayNode, double need) {
+		Double used = underlayNode.getAttribute(ATTRIBUTE_KEY_PROCESS_USE);
+		Double max = underlayNode.getAttribute(ATTRIBUTE_KEY_PROCESS_MAX);
+		if (max == null || max == 0)
+			return;
+		if (used == null)
+			used = new Double(0);
+		double[] pieValues = { used / max, 0, 1 - used / max, 0 };
+		if (need + used > max) {
+			pieValues[3] = pieValues[2];
+			pieValues[2] = 0;
+		} else {
+			pieValues[1] = need / max;
+			pieValues[2] -= need / max;
+		}
+
+		underlayNode.setAttribute("ui.pie-values", pieValues);
+		underlayNode.setAttribute(ATTRIBUTE_KEY_PROCESS_USE, used);
+	}
+
+	@Override
+	public boolean selectNodeForEdgeCreation(String nodeID) {
+		Node n = g.getNode(nodeID);
+		String parent = n.getAttribute(ATTRIBUTE_KEY_MAPPING_PARENT);
+		if (parent == null)
+			return false;
+		if (parent.equals(OPERATOR))
+			return super.selectNodeForEdgeCreation(nodeID);
+		if (hasClass(n, UI_CLASS_PROCESSING_ENABLED))
+			return super.selectNodeForEdgeCreation(nodeID);
+		return false;
+	}
+
+	public void deleteEdge(final String id) {
+		super.deleteEdge(id);
+	}
+
 }

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

@@ -2,6 +2,9 @@ package de.tu_darmstadt.informatik.tk.scopviz.ui;
 
 import java.util.ArrayList;
 
+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.main.Main;
 import javafx.application.Platform;
 import javafx.collections.FXCollections;
 import javafx.geometry.Insets;
@@ -27,11 +30,7 @@ public final class OptionsManager {
 	/** Flag whether to show the weight labels on Edges. */
 	private static boolean showWeight = true;
 	// Layer stylesheets
-	static String styleLayerUnderlay = "";
-	static String styleLayerOperator = "";
-	static String styleLayerMapping = "";
-	static String styleLayerSymbol = "";
-
+	
 	/**
 	 * Private Constructor to prevent Instantiation.
 	 */

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

@@ -238,8 +238,6 @@ public final class PropertiesManager {
 				break;
 			case "ui.clicked":
 				break;
-			case "ui.class":
-				break;
 			case "ui.map.selected":
 				break;
 			case "xyz":
@@ -248,6 +246,12 @@ public final class PropertiesManager {
 				newData.add(new KeyValuePair("y", String.valueOf(pos[1]), double.class));
 				newData.add(new KeyValuePair("z", String.valueOf(pos[2]), double.class));
 				break;
+			case "mapping":
+			case "mapping-parent":
+			case "mapping-parent-id":
+			case "ui.class":
+				if (!Debug.DEBUG_ENABLED)
+					break;
 			default:
 				Object actualAttribute = selected.getAttribute(key);
 				newData.add(new KeyValuePair(key, String.valueOf(actualAttribute), actualAttribute.getClass()));

+ 17 - 9
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/StylesheetManager.java

@@ -15,7 +15,7 @@ public class StylesheetManager {
 	 * everything correctly
 	 */
 	public static final String DEFAULT_STYLESHEET = "node{text-alignment:at-right;} \n"
-			+ "edge{text-offset: 4px,-4px;}";
+			+ "edge{text-offset: 4px,-4px;} edge.selected{fill-color: #FF0000;}";
 	/**
 	 * Part of the stylesheet that styles the different Nodes with shapes.
 	 */
@@ -33,7 +33,15 @@ public class StylesheetManager {
 	private static String nodeGraphics = allNodeGraphics[1];
 	/** The currently active Stylesheet. */
 	private static String nodeStylesheet = STYLE_NODES_SPRITES;
+	
+	private  static String styleLayerUnderlay = "";
+	private static String styleLayerOperator = "";
+	private static String styleLayerMapping = "edge.mapping {stroke-color: #33ff33; stroke-mode: dashes; fill-mode: none; size: 0px;}"
+			+ "node.procEn {fill-mode: plain; shape: pie-chart; fill-color: #555555, #cccc00, #32cd32, #8b0000; size: 20px;}";
+	private static String styleLayerSymbol = "";
 
+	
+	
 	/**
 	 * Changes the Stylesheet and updates all Nodes to use it.
 	 * 
@@ -92,13 +100,13 @@ public class StylesheetManager {
 	public static String getLayerStyle(Layer l) {
 		switch (l) {
 		case UNDERLAY:
-			return OptionsManager.styleLayerUnderlay;
+			return styleLayerUnderlay;
 		case OPERATOR:
-			return OptionsManager.styleLayerOperator;
+			return styleLayerOperator;
 		case MAPPING:
-			return OptionsManager.styleLayerMapping;
+			return styleLayerMapping;
 		case SYMBOL:
-			return OptionsManager.styleLayerSymbol;
+			return styleLayerSymbol;
 		default:
 			Debug.out("OptionsManager: Stylesheet for an unknown Layer Requested");
 			return "";
@@ -116,16 +124,16 @@ public class StylesheetManager {
 	public static void setLayerStyle(Layer l, String newStyle) {
 		switch (l) {
 		case UNDERLAY:
-			OptionsManager.styleLayerUnderlay = newStyle;
+			styleLayerUnderlay = newStyle;
 			break;
 		case OPERATOR:
-			OptionsManager.styleLayerOperator = newStyle;
+			styleLayerOperator = newStyle;
 			break;
 		case MAPPING:
-			OptionsManager.styleLayerMapping = newStyle;
+			styleLayerMapping = newStyle;
 			break;
 		case SYMBOL:
-			OptionsManager.styleLayerSymbol = newStyle;
+			styleLayerSymbol = newStyle;
 			break;
 		default:
 			Debug.out("OptionsManager: Stylesheet for an unknown Layer Requested");

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

@@ -31,11 +31,6 @@ public class MyMouseManager extends DefaultMouseManager {
 	 */
 	private GraphManager graphManager;
 
-	/**
-	 * The Id of the Node that was last clicked.
-	 */
-	private String lastClickedID;
-
 	/**
 	 * The Timestamp of when the Camera's View Center was last changed.
 	 */
@@ -170,7 +165,7 @@ public class MyMouseManager extends DefaultMouseManager {
 		// if in Creation Mode, try to create an Edge with the Node that was
 		// clicked on
 		if (Main.getInstance().getCreationMode() != CreationMode.CREATE_NONE) {
-			createEdges(id);
+			graphManager.createEdges(id);
 			return;
 		}
 
@@ -270,88 +265,5 @@ public class MyMouseManager extends DefaultMouseManager {
 		}
 	}
 
-	/**
-	 * Create Edges based on CreateMode
-	 * 
-	 * @param id
-	 */
-	private void createEdges(String id) {
-		String newID = null;
-		switch (Main.getInstance().getCreationMode()) {
-
-		case CREATE_DIRECTED_EDGE:
-
-			if (lastClickedID == null) {
-				lastClickedID = id;
-				selectNodeForEdgeCreation(lastClickedID);
-			} else {
-				if (!id.equals(lastClickedID)) {
-					newID = Main.getInstance().getUnusedID();
-					graphManager.getGraph().addEdge(newID, lastClickedID, id, true);
-					Debug.out("Created an directed edge with Id " + newID + " between " + lastClickedID + " and " + id);
-
-					deselectNodesAfterEdgeCreation(lastClickedID);
-
-					lastClickedID = null;
-					graphManager.selectEdge(newID);
-				}
-			}
-			break;
-
-		case CREATE_UNDIRECTED_EDGE:
-			if (lastClickedID == null) {
-				lastClickedID = id;
-				selectNodeForEdgeCreation(lastClickedID);
-			} else {
-				if (!id.equals(lastClickedID)) {
-					newID = Main.getInstance().getUnusedID();
-					graphManager.getGraph().addEdge(newID, lastClickedID, id);
-
-					Debug.out(
-							"Created an undirected edge with Id " + newID + " between " + lastClickedID + " and " + id);
-
-					deselectNodesAfterEdgeCreation(lastClickedID);
-					lastClickedID = null;
-					graphManager.selectEdge(newID);
-				}
-			}
-			break;
-
-		default:
-			break;
-		}
-		PropertiesManager.setItemsProperties();
-
-		// controller.createModusText.setText(Main.getInstance().getCreationMode().toString());
-
-	}
-
-	/**
-	 * Selects a Node as the starting point for creating a new Edge.
-	 * 
-	 * @param nodeID
-	 *            the ID of the Node to select
-	 */
-	private void selectNodeForEdgeCreation(String nodeID) {
-		Node n = graphManager.getGraph().getNode(nodeID);
-		String nodeType = n.getAttribute("ui.class");
-		nodeType = nodeType.split("_")[0];
-		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");
-	}
-
-	/**
-	 * Reset the Selection of the Node after Edge has been successfully created.
-	 * 
-	 * @param nodeID
-	 *            the Id of the node to deselect.
-	 */
-	private void deselectNodesAfterEdgeCreation(String nodeID) {
-		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]);
-	}
+	
 }

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

@@ -0,0 +1,59 @@
+
+<?xml version="1.0" encoding="UTF-8"?>
+<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
+	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	 xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
+	   http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
+   	<key id="attr0000" for="node" attr.name="ui.label" attr.type="string"/>
+	<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" />
+	<key id="attr0005" for="node" attr.name="process-max"  attr.type="double" />
+	<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">procEn</data>
+			<data key="attr0005">40</data>
+		</node>
+		<node id="C">
+			<data key="attr0000">C</data>
+			<data key="attr0002">100</data>
+			<data key="attr0003">200</data>
+			<data key="attr0004">procEn</data>
+			<data key="attr0005">30</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>
+			<data key="attr0005">100</data>
+		</node>
+		<node id="E">
+			<data key="attr0000">E</data>
+			<data key="attr0002">185</data>
+			<data key="attr0003">135</data>
+			<data key="attr0004">standard</data>
+		</node>
+		<edge id="AB" source="A" target="B" directed="false">
+			<data key="attr0001">test</data>
+		</edge>
+		<edge id="BC" source="B" target="C" directed="false">
+			<data key="attr0001">test</data>
+		</edge>
+		<edge id="CD" source="C" target="D" directed="false">
+		</edge>
+		<edge id="DB" source="D" target="B" directed="false">
+		</edge>
+	</graph>
+</graphml>

+ 51 - 0
scopviz/src/main/resources/Example2.graphml

@@ -0,0 +1,51 @@
+
+<?xml version="1.0" encoding="UTF-8"?>
+<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
+	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	 xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
+	   http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
+   	<key id="attr0000" for="node" attr.name="ui.label" attr.type="string"/>
+	<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" />
+	<key id="attr0005" for="node" attr.name="process-need"  attr.type="double" />
+	<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>
+			<data key="attr0005">20</data>
+		</node>
+		<node id="B">
+			<data key="attr0000">B</data>
+			<data key="attr0002">200</data>
+			<data key="attr0003">100</data>
+			<data key="attr0004">standard</data>
+			<data key="attr0005">25</data>
+		</node>
+		<node id="C">
+			<data key="attr0000">C</data>
+			<data key="attr0002">100</data>
+			<data key="attr0003">200</data>
+			<data key="attr0004">standard</data>
+			<data key="attr0005">23</data>
+		</node>
+		<node id="D">
+			<data key="attr0000">D</data>
+			<data key="attr0002">200</data>
+			<data key="attr0003">200</data>
+			<data key="attr0004">standard</data>
+			<data key="attr0005">22.34234</data>
+		</node>
+		<node id="E">
+			<data key="attr0000">E</data>
+			<data key="attr0002">185</data>
+			<data key="attr0003">135</data>
+			<data key="attr0004">standard</data>
+			<data key="attr0005">50</data>
+		</node>
+	</graph>
+</graphml>