|
@@ -5,8 +5,6 @@ import java.util.HashMap;
|
|
|
import java.util.LinkedList;
|
|
|
|
|
|
import org.graphstream.algorithm.Toolkit;
|
|
|
-import org.graphstream.graph.Edge;
|
|
|
-import org.graphstream.graph.Node;
|
|
|
|
|
|
import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
|
|
|
import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
|
|
@@ -92,7 +90,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
public void loadGraph(MyGraph g) {
|
|
|
|
|
|
// reset used capacity to 0 for every procEnabled node
|
|
|
- for (Node n : this.g.getNodeSet()) {
|
|
|
+ for (MyNode n : this.g.<MyNode>getNodeSet()) {
|
|
|
if (hasClass(n, UI_CLASS_PROCESSING_ENABLED)) {
|
|
|
resetCapacity(n);
|
|
|
}
|
|
@@ -102,7 +100,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
autoMapLoadedEdgeAttributes(underlay, operator);
|
|
|
|
|
|
// recreates every mapping edge to properly calculate capacities
|
|
|
- for (Edge e : g.getEdgeSet()) {
|
|
|
+ for (MyEdge e : g.<MyEdge>getEdgeSet()) {
|
|
|
if (e.getAttribute(ATTRIBUTE_KEY_MAPPING) != null && (boolean) e.getAttribute(ATTRIBUTE_KEY_MAPPING)) {
|
|
|
createEdge(e.getSourceNode().getId(), e.getTargetNode().getId());
|
|
|
}
|
|
@@ -127,7 +125,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
// Debug only
|
|
|
int i = 0;
|
|
|
|
|
|
- for (Edge edge : gm.getGraph().getEdgeSet()) {
|
|
|
+ for (MyEdge edge : gm.getGraph().<MyEdge>getEdgeSet()) {
|
|
|
addEdge(edge, idPrefix);
|
|
|
|
|
|
// Debug only
|
|
@@ -180,9 +178,9 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
|
|
|
// loops through all nodes, adds them if they don't exist already and
|
|
|
// normalizes their coordinates
|
|
|
- for (Node node : gm.getGraph().getNodeSet()) {
|
|
|
+ for (MyNode node : gm.getGraph().<MyNode>getNodeSet()) {
|
|
|
// add node if it doesn't exist
|
|
|
- Node newNode = getGraph().getNode(idPrefix + node.getId());
|
|
|
+ MyNode newNode = getGraph().getNode(idPrefix + node.getId());
|
|
|
if (newNode == null) {
|
|
|
addNode(node, idPrefix);
|
|
|
newNode = getGraph().getNode(idPrefix + node.getId());
|
|
@@ -248,7 +246,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
* @param idPrefix
|
|
|
* the String to be added as prefix to the ID
|
|
|
*/
|
|
|
- private void addEdge(Edge e, String idPrefix) {
|
|
|
+ private void addEdge(MyEdge e, String idPrefix) {
|
|
|
HashMap<String, Object> attributes = new HashMap<>();
|
|
|
|
|
|
for (String s : e.getAttributeKeySet()) {
|
|
@@ -265,7 +263,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void addNode(Node n) {
|
|
|
+ public void addNode(MyNode n) {
|
|
|
// This function mustn't be called.
|
|
|
Debug.out("Someone called addNode(Node n) with a MappingGraphManager");
|
|
|
}
|
|
@@ -279,7 +277,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
* @param idPrefix
|
|
|
* the String to be added as prefix to the ID
|
|
|
*/
|
|
|
- private void addNode(Node n, String idPrefix) {
|
|
|
+ private void addNode(MyNode n, String idPrefix) {
|
|
|
HashMap<String, Object> attributes = new HashMap<>();
|
|
|
|
|
|
for (String s : n.getAttributeKeySet()) {
|
|
@@ -294,7 +292,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void nodeCreated(Node n, String graphID) {
|
|
|
+ public void nodeCreated(MyNode n, String graphID) {
|
|
|
if (graphID.equals(underlay.getGraph().getId()))
|
|
|
underlayNodesChanged = true;
|
|
|
else if (graphID.equals(operator.getGraph().getId()))
|
|
@@ -302,7 +300,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void edgeCreated(Edge e, String graphID) {
|
|
|
+ public void edgeCreated(MyEdge e, String graphID) {
|
|
|
if (graphID.equals(underlay.getGraph().getId()))
|
|
|
addEdge(e, UNDERLAY);
|
|
|
else if (graphID.equals(operator.getGraph().getId()))
|
|
@@ -316,7 +314,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
if (lastClickedID != null) {
|
|
|
Double need = g.getNode(lastClickedID).getAttribute(ATTRIBUTE_KEY_PROCESS_NEED);
|
|
|
if (need != null)
|
|
|
- for (Node n : g.getNodeSet())
|
|
|
+ for (MyNode n : g.<MyNode>getNodeSet())
|
|
|
if (hasClass(n, UI_CLASS_PROCESSING_ENABLED))
|
|
|
showExpectedCapacity(n, need);
|
|
|
}
|
|
@@ -331,7 +329,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
@Override
|
|
|
protected void deselectNodesAfterEdgeCreation(String nodeID) {
|
|
|
super.deselectNodesAfterEdgeCreation(nodeID);
|
|
|
- for (Node n : g.getNodeSet())
|
|
|
+ for (MyNode n : g.<MyNode>getNodeSet())
|
|
|
if (hasClass(n, UI_CLASS_PROCESSING_ENABLED))
|
|
|
showExpectedCapacity(n, 0);
|
|
|
}
|
|
@@ -342,13 +340,13 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
*/
|
|
|
@Override
|
|
|
public boolean createEdge(String to, String from) {
|
|
|
- Node fromNode = getGraph().getNode(from);
|
|
|
- Node toNode = getGraph().getNode(to);
|
|
|
+ MyNode fromNode = getGraph().getNode(from);
|
|
|
+ MyNode toNode = getGraph().getNode(to);
|
|
|
|
|
|
if (fromNode.hasEdgeBetween(to))
|
|
|
return false;
|
|
|
|
|
|
- for (Edge e : fromNode.getEdgeSet()) {
|
|
|
+ for (MyEdge e : fromNode.<MyEdge>getEdgeSet()) {
|
|
|
Boolean mapped = e.getAttribute("mapping");
|
|
|
if (mapped != null && mapped)
|
|
|
return false;
|
|
@@ -369,10 +367,10 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
|
|
|
String newID = Main.getInstance().getUnusedID();
|
|
|
|
|
|
- Edge e;
|
|
|
+ MyEdge e;
|
|
|
|
|
|
- Node underlayNode;
|
|
|
- Node operatorNode;
|
|
|
+ MyNode underlayNode;
|
|
|
+ MyNode operatorNode;
|
|
|
if (fromParent.equals(UNDERLAY)) {
|
|
|
underlayNode = fromNode;
|
|
|
operatorNode = toNode;
|
|
@@ -417,7 +415,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
* @param underlayNode
|
|
|
* The Node for which the pie chart should be initialized
|
|
|
*/
|
|
|
- private void initCapacity(Node underlayNode) {
|
|
|
+ private void initCapacity(MyNode underlayNode) {
|
|
|
Double used = underlayNode.getAttribute(ATTRIBUTE_KEY_PROCESS_USE);
|
|
|
Double max = underlayNode.getAttribute(ATTRIBUTE_KEY_PROCESS_MAX);
|
|
|
if (max == null || max == 0)
|
|
@@ -436,7 +434,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
* @param underlayNode
|
|
|
* The Node for which the pie chart should be initialized
|
|
|
*/
|
|
|
- private void resetCapacity(Node underlayNode) {
|
|
|
+ private void resetCapacity(MyNode underlayNode) {
|
|
|
Double used = new Double(0);
|
|
|
underlayNode.setAttribute(ATTRIBUTE_KEY_PROCESS_USE, used);
|
|
|
Double max = underlayNode.getAttribute(ATTRIBUTE_KEY_PROCESS_MAX);
|
|
@@ -456,7 +454,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
* The operatorNode which gets mapped
|
|
|
* @return true if the mapping was successful. false otherwise.
|
|
|
*/
|
|
|
- private boolean addMapping(Node underlayNode, Node operatorNode) {
|
|
|
+ private boolean addMapping(MyNode underlayNode, MyNode operatorNode) {
|
|
|
Double needed = operatorNode.getAttribute(ATTRIBUTE_KEY_PROCESS_NEED);
|
|
|
if (needed == null)
|
|
|
return true;
|
|
@@ -473,7 +471,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
* The operatorNode which gets mapped
|
|
|
* @return true if the mapping was successful. false otherwise.
|
|
|
*/
|
|
|
- private boolean removeMapping(Node underlayNode, Node operatorNode) {
|
|
|
+ private boolean removeMapping(MyNode underlayNode, MyNode operatorNode) {
|
|
|
Double needed = operatorNode.getAttribute(ATTRIBUTE_KEY_PROCESS_NEED);
|
|
|
if (needed == null)
|
|
|
return true;
|
|
@@ -490,7 +488,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
* The capacity. may be positive or negative
|
|
|
* @return true if the capacity change was successful. false otherwise.
|
|
|
*/
|
|
|
- private boolean changeCapacity(Node underlayNode, double capacity) {
|
|
|
+ private boolean changeCapacity(MyNode underlayNode, double capacity) {
|
|
|
Double needed = capacity;
|
|
|
Double used = underlayNode.getAttribute(ATTRIBUTE_KEY_PROCESS_USE);
|
|
|
Double max = underlayNode.getAttribute(ATTRIBUTE_KEY_PROCESS_MAX);
|
|
@@ -519,7 +517,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
* @param need
|
|
|
* the capacity change
|
|
|
*/
|
|
|
- private void showExpectedCapacity(Node underlayNode, double need) {
|
|
|
+ private void showExpectedCapacity(MyNode underlayNode, double need) {
|
|
|
Double used = underlayNode.getAttribute(ATTRIBUTE_KEY_PROCESS_USE);
|
|
|
Double max = underlayNode.getAttribute(ATTRIBUTE_KEY_PROCESS_MAX);
|
|
|
if (max == null || max == 0)
|
|
@@ -541,12 +539,12 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
|
|
|
@Override
|
|
|
protected boolean selectNodeForEdgeCreation(String nodeID) {
|
|
|
- Node n = g.getNode(nodeID);
|
|
|
+ MyNode n = g.getNode(nodeID);
|
|
|
String parent = n.getAttribute(ATTRIBUTE_KEY_MAPPING_PARENT);
|
|
|
if (parent == null)
|
|
|
return false;
|
|
|
if (parent.equals(OPERATOR)) {
|
|
|
- for (Edge e : n.getEdgeSet()) {
|
|
|
+ for (MyEdge e : n.<MyEdge>getEdgeSet()) {
|
|
|
Boolean isMapped = e.getAttribute(ATTRIBUTE_KEY_MAPPING);
|
|
|
if (isMapped != null && isMapped)
|
|
|
return false;
|
|
@@ -560,10 +558,10 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
|
|
|
@Override
|
|
|
public void deleteEdge(final String id) {
|
|
|
- Edge e = g.getEdge(id);
|
|
|
+ MyEdge e = g.getEdge(id);
|
|
|
if ((boolean) e.getAttribute(ATTRIBUTE_KEY_MAPPING)) {
|
|
|
- Node operatorNode = e.getSourceNode();
|
|
|
- Node underlayNode = e.getTargetNode();
|
|
|
+ MyNode operatorNode = e.getSourceNode();
|
|
|
+ MyNode underlayNode = e.getTargetNode();
|
|
|
|
|
|
// delete mapping attriute
|
|
|
GraphHelper.propagateAttribute(this.g, underlayNode, "mappingEdge", null);
|
|
@@ -585,7 +583,7 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
@Override
|
|
|
public void undelete() {
|
|
|
super.undelete();
|
|
|
- for (Edge e : deletedEdges) {
|
|
|
+ for (MyEdge e : deletedEdges) {
|
|
|
if ((boolean) e.getAttribute(ATTRIBUTE_KEY_MAPPING))
|
|
|
changeCapacity(e.getTargetNode(), e.getSourceNode().getAttribute(ATTRIBUTE_KEY_PROCESS_NEED));
|
|
|
}
|
|
@@ -594,13 +592,13 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
private void autoMapSourcesAndSinks(GraphManager underlay, GraphManager operator) {
|
|
|
// TODO Andere Farbe für automatisch erstellte Mappingkanten von Quellen
|
|
|
// und Senken
|
|
|
- for (Node operatorNode : getOperatorNodeSet()) {
|
|
|
+ for (MyNode operatorNode : getOperatorNodeSet()) {
|
|
|
if (operatorNode.getAttribute("typeofNode").toString().equals("source")) {
|
|
|
- for (Node underlayNode : getUnderlayNodeSet()) {
|
|
|
+ for (MyNode underlayNode : getUnderlayNodeSet()) {
|
|
|
if (operatorNode.getAttribute("identifier") != null && operatorNode.getAttribute("identifier")
|
|
|
.equals(underlayNode.getAttribute("identifier"))) {
|
|
|
String newID = Main.getInstance().getUnusedID(this);
|
|
|
- Edge e = getGraph().addEdge(newID, operatorNode, underlayNode, true);
|
|
|
+ MyEdge e = getGraph().addEdge(newID, operatorNode, underlayNode, true);
|
|
|
Debug.out("Created an directed edge with Id " + newID + " from " + operatorNode + " to "
|
|
|
+ underlayNode);
|
|
|
|
|
@@ -609,11 +607,11 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
}
|
|
|
}
|
|
|
} else if (operatorNode.getAttribute("typeofNode").equals("sink")) {
|
|
|
- for (Node underlayNode : getUnderlayNodeSet()) {
|
|
|
+ for (MyNode underlayNode : getUnderlayNodeSet()) {
|
|
|
String identifier = operatorNode.getAttribute("identifier");
|
|
|
if (identifier != null && identifier.equals(underlayNode.getAttribute("identifier"))) {
|
|
|
String newID = Main.getInstance().getUnusedID(this);
|
|
|
- Edge e = getGraph().addEdge(newID, operatorNode, underlayNode, true);
|
|
|
+ MyEdge e = getGraph().addEdge(newID, operatorNode, underlayNode, true);
|
|
|
Debug.out("Created an directed edge with Id " + newID + " from " + operatorNode + " to "
|
|
|
+ underlayNode);
|
|
|
|
|
@@ -625,9 +623,9 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private Collection<Node> getOperatorNodeSet() {
|
|
|
- LinkedList<Node> result = new LinkedList<Node>();
|
|
|
- for (Node n : getGraph().getNodeSet()) {
|
|
|
+ private Collection<MyNode> getOperatorNodeSet() {
|
|
|
+ LinkedList<MyNode> result = new LinkedList<MyNode>();
|
|
|
+ for (MyNode n : getGraph().<MyNode>getNodeSet()) {
|
|
|
if (n.getAttribute(ATTRIBUTE_KEY_MAPPING_PARENT) == OPERATOR) {
|
|
|
result.add(n);
|
|
|
}
|
|
@@ -635,9 +633,9 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private Collection<Node> getUnderlayNodeSet() {
|
|
|
- LinkedList<Node> result = new LinkedList<Node>();
|
|
|
- for (Node n : getGraph().getNodeSet()) {
|
|
|
+ private Collection<MyNode> getUnderlayNodeSet() {
|
|
|
+ LinkedList<MyNode> result = new LinkedList<MyNode>();
|
|
|
+ for (MyNode n : getGraph().<MyNode>getNodeSet()) {
|
|
|
if (n.getAttribute(ATTRIBUTE_KEY_MAPPING_PARENT) == UNDERLAY) {
|
|
|
result.add(n);
|
|
|
}
|
|
@@ -646,8 +644,8 @@ public class MappingGraphManager extends GraphManager implements EdgeCreatedList
|
|
|
}
|
|
|
|
|
|
private void autoMapLoadedEdgeAttributes(GraphManager underlay2, GraphManager operator2) {
|
|
|
- for (Node operatorNode : getOperatorNodeSet()) {
|
|
|
- for (Node underlayNode : getUnderlayNodeSet()) {
|
|
|
+ for (MyNode operatorNode : getOperatorNodeSet()) {
|
|
|
+ for (MyNode underlayNode : getUnderlayNodeSet()) {
|
|
|
String identifier = operatorNode.getAttribute("mappingEdge");
|
|
|
if (identifier != null && identifier.equals(underlayNode.getAttribute("mappingEdge"))) {
|
|
|
createEdge(operatorNode.getId(), underlayNode.getId());
|