diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java index 29c0dda..d947583 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java @@ -375,17 +375,17 @@ Map channelsIn = new HashMap<>(); Map channelsOut = new HashMap<>(); - Map resources = new HashMap<>(); + Map resources = new HashMap<>(); // create resource vertices for (ResourceNode resNode: dataFlowGraph.getRootResourceNodes()) { int w = 80; int h = 30; - ResourcePath res = resNode.getOutSideResource(); + ResourcePath res = resNode.getOutSideResources().iterator().next(); Object resource = graph.insertVertex(parent, null, res.getResourceName(), 20, 20, w, h, "shape=ellipse;perimeter=ellipsePerimeter"); // insert a resource as a vertex - resources.put(System.identityHashCode(res), resource); + resources.put(resNode, resource); getChildResource(resource, resNode, resources, w, h); } @@ -395,7 +395,7 @@ if (channel.getInputResources().size() > 0) { // Normal channel if (channelsIn.get(channel) == null || channelsOut.get(channel) == null) { - if(channel.getSelectors().toString() == "[]") { + if (channel.getSelectors().toString() == "[]") { Object chCell = graph.insertVertex(parent, null, channel.getChannelName(), 150, 20, 30, 30); // insert a channel as a vertex mxCell port_in = new mxCell(null, geo1, "shape=ellipse;perimter=ellipsePerimeter"); port_in.setVertex(true); @@ -405,8 +405,7 @@ graph.addCell(port_out, chCell); // insert the output port of a channel channelsIn.put(channel, port_in); channelsOut.put(channel, port_out); - }else { - + } else { for (Selector s: channel.getSelectors()) { Expression exp = s.getExpression(); String selName = exp.toString(); @@ -465,20 +464,20 @@ if (dfEdge.isChannelToResource()) { // output edge DataTransferChannel channel = ((ChannelNode) dfEdge.getSource()).getChannel(); - ResourcePath dstRes = ((ResourceNode) dfEdge.getDestination()).getOutSideResource(); - graph.insertEdge(parent, null, new SrcDstAttribute(channel, dstRes), channelsOut.get(channel), resources.get(System.identityHashCode(dstRes)), "movable=false"); + ResourcePath dstRes = ((ResourceNode) dfEdge.getDestination()).getOutSideResource(channel); + graph.insertEdge(parent, null, new SrcDstAttribute(channel, dstRes), channelsOut.get(channel), resources.get((ResourceNode) dfEdge.getDestination()), "movable=false"); } else { // input edge - ResourcePath srcRes = ((ResourceNode) dfEdge.getSource()).getOutSideResource(); DataTransferChannel channel = ((ChannelNode) dfEdge.getDestination()).getChannel(); + ResourcePath srcRes = ((ResourceNode) dfEdge.getSource()).getOutSideResource(channel); Set> toRes = getResourceDependencyForChannel(channel, model, dataFlowGraph); - for(Map.Entry RtoR : toRes) { + for(Map.Entry RtoR: toRes) { graph.insertEdge(parent, null, null, - resources.get(System.identityHashCode(RtoR.getValue().getOutSideResource())), - resources.get(System.identityHashCode(RtoR.getKey().getOutSideResource())), "dashed=true;movable=false"); + resources.get(RtoR.getValue()), + resources.get(RtoR.getKey()), "dashed=true;movable=false"); } - graph.insertEdge(parent, null, new SrcDstAttribute(srcRes, channel), resources.get(System.identityHashCode(srcRes)), channelsIn.get(channel), "movable=false"); + graph.insertEdge(parent, null, new SrcDstAttribute(srcRes, channel), resources.get((ResourceNode) dfEdge.getSource()), channelsIn.get(channel), "movable=false"); } } @@ -486,7 +485,7 @@ // reference edges DataTransferChannel channel = (DataTransferChannel) ch; for (ResourcePath refRes: channel.getReferenceResources()) { - graph.insertEdge(parent, null, null, resources.get(System.identityHashCode(refRes)), channelsIn.get(channel), "dashed=true;movable=false"); + graph.insertEdge(parent, null, null, resources.get(dataFlowGraph.getResourceNode(refRes)), channelsIn.get(channel), "dashed=true;movable=false"); } } } finally { @@ -498,14 +497,14 @@ return graph; } - public void getChildResource(Object resource, ResourceNode resNode, Map resources, int w, int h) { + public void getChildResource(Object resource, ResourceNode resNode, Map resources, int w, int h) { for (ResourceNode c: resNode.getChildren()) { - ResourcePath chRes = c.getOutSideResource(); + ResourcePath chRes = c.getOutSideResources().iterator().next(); Object chResource = graph.insertVertex(resource, null, chRes.getName(), 0, 0, w, h, "shape=ellipse;perimeter=ellipsePerimeter"); // insert a resource as a vertex - resources.put(System.identityHashCode(chRes), chResource); + resources.put(c, chResource); getChildResource(chResource, c, resources, w, h); } } @@ -537,7 +536,7 @@ mxCell edgeCell = (mxCell) edge; if (edgeCell.getValue() instanceof SrcDstAttribute) { SrcDstAttribute edgeAttr = (SrcDstAttribute) edgeCell.getValue(); - if (srcRes.getOutSideResource().equals(edgeAttr.getSource()) && channel.equals(edgeAttr.getDestination())) { + if (srcRes.getOutSideResources().iterator().next().equals(edgeAttr.getSource()) && channel.equals(edgeAttr.getDestination())) { edgeCell.setValue(dataFlow.getAttribute()); break; }