diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java index 29c0dda..3ea8a48 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java @@ -375,18 +375,18 @@ 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.getPrimaryResourcePath(); 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); - getChildResource(resource, resNode, resources, w, h); + resources.put(resNode, resource); + createChildResourceVerticies(resource, resNode, resources, w, h); } // create channel vertices @@ -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(); @@ -427,7 +426,7 @@ } else { // I/O channel if (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); @@ -437,8 +436,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 +463,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()).getInSideResource(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 +484,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,15 +496,15 @@ return graph; } - public void getChildResource(Object resource, ResourceNode resNode, Map resources, int w, int h) { + public void createChildResourceVerticies(Object resource, ResourceNode resNode, Map resources, int w, int h) { - for (ResourceNode c: resNode.getChildren()) { - ResourcePath chRes = c.getOutSideResource(); - Object chResource = graph.insertVertex(resource, null, - chRes.getName(), 0, 0, w, h, + for (ResourceNode childNode: resNode.getChildren()) { + ResourcePath childRes = childNode.getPrimaryResourcePath(); + Object childResource = graph.insertVertex(resource, null, + childRes.getName(), 0, 0, w, h, "shape=ellipse;perimeter=ellipsePerimeter"); // insert a resource as a vertex - resources.put(System.identityHashCode(chRes), chResource); - getChildResource(chResource, c, resources, w, h); + resources.put(childNode, childResource); + createChildResourceVerticies(childResource, childNode, resources, w, h); } } @@ -537,7 +535,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.getPrimaryResourcePath().equals(edgeAttr.getSource()) && channel.equals(edgeAttr.getDestination())) { edgeCell.setValue(dataFlow.getAttribute()); break; } @@ -795,6 +793,9 @@ if (srcNode != null) { for (ChannelMember dstMem: dependency.get(srcMem).getValue()) { ResourceNode dstNode = dataFlowGraph.getResourceNode(dstMem.getResource()); + while (srcNode.getResourceHierarchy().getNumParameters() == 0 && srcNode.getParent() != null) { + srcNode = srcNode.getParent(); + } resourceDpendency.add(new AbstractMap.SimpleEntry<>(srcNode, dstNode)); } }