diff --git a/AlgebraicDataflowArchitectureModel/src/application/SimulatorWindow.java b/AlgebraicDataflowArchitectureModel/src/application/SimulatorWindow.java index e36dbd1..7d043aa 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/SimulatorWindow.java +++ b/AlgebraicDataflowArchitectureModel/src/application/SimulatorWindow.java @@ -93,7 +93,6 @@ }; this.graphComponent = new mxGraphComponent(graph); - this.editor = editor; graph.getModel().addListener(mxEvent.CHANGE, new mxIEventListener() { @@ -125,34 +124,13 @@ setSize(870,640); setVisible(true); - simulator = new Simulator(this.editor.getModel()); constructSimulateGraph(simulator.getCurState().getRootResources(), this.editor.getModel(),this.editor.getDataFlowGraph()); - - graphComponent.setCellEditor(new InputEventCellEditor(graphComponent, this.editor)); - //new DataTransferModelingCellEditor(graphComponent, editor); - - //TokenStream stream = new Parser.TokenStream(); - //Parser parser = new Parser(stream); -// stream.addLine("addCompany(\"1\", \"Osaka\")"); -// try { -// Expression message = parser.parseTerm(stream, editor.getModel()); -// //Event addCompany = new Event(cio_addCompany, message, companies, initialState.getResource(ResourceIdentifier.createFrom(companies))); -// //simulator.transition(null); -// } catch (ExpectedRightBracket | WrongJsonExpression | ExpectedColon e) { -// // TODO 自動生成された catch ブロック -// e.printStackTrace(); -// } - - - for(Resource resource: simulator.getCurState().getRootResources()) { - System.out.println(resource.getResourceIdentifier().toString()); - System.out.println(resource.getResourceHierarchy().getChildren()); - } + graphComponent.setCellEditor(new InputEventCellEditor(graphComponent, simulator, this.editor, graph)); } - public mxGraph constructSimulateGraph(Set simulateRes, DataTransferModel model, DataFlowGraph dataFlowGraph) { + public mxGraph constructSimulateGraph(Set simulateRes, DataTransferModel model, DataFlowGraph dataFlowGraph) { bReflectingArchitectureModel = true; ((mxGraphModel) graph.getModel()).clear(); Object parent = graph.getDefaultParent(); @@ -170,7 +148,7 @@ res.getResourceName(), 20, 20, w, h, "shape=ellipse;perimeter=ellipsePerimeter"); // insert a resource as a vertex resources.put(resNode, resource); - createChildResourceVerticiesSample(resource, resNode, resources, w, h); + createChildSimulateResourceVerticies(resource, resNode, resources, w, h); } } finally { @@ -182,7 +160,7 @@ } - public void createChildResourceVerticiesSample(Object resource, Resource resNode, Map resources, int w, int h) { //sample + public void createChildSimulateResourceVerticies(Object resource, Resource resNode, Map resources, int w, int h) { //sample if(resNode.getChildren() != null) { for (Resource childNode: resNode.getChildren()) { @@ -191,7 +169,7 @@ childRes.getName(), 0, 0, w, h, "shape=ellipse;perimeter=ellipsePerimeter"); // insert a resource as a vertex resources.put(childNode, childResource); - createChildResourceVerticiesSample(childResource, childNode, resources, w, h); + createChildSimulateResourceVerticies(childResource, childNode, resources, w, h); } } } @@ -207,81 +185,5 @@ public void setEditor(Editor editor) { this.editor = editor; } - - public Set> getResourceDependencyForChannel(DataTransferChannel ch, DataTransferModel model, DataFlowGraph dataFlowGraph) { - Set> resourceDpendency = new HashSet<>(); - try { - Map>> dependency = ch.fillOutsideResourcePaths(ch.getOutputChannelMembers().iterator().next(), JavaCodeGenerator.pullAccessor); - for (ChannelMember srcMem: dependency.keySet()) { - ResourceNode srcNode = dataFlowGraph.getResourceNode(srcMem.getResource()); - 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)); - } - } - } - } catch (ParameterizedIdentifierIsFutureWork | ResolvingMultipleDefinitionIsFutureWork | InvalidMessage - | UnificationFailed | ValueUndefined e) { - e.printStackTrace(); - } - return resourceDpendency; - } - - public void updateEdgeAttiributes(DataFlowGraph dataFlowGraph) { - Object parent = graph.getDefaultParent(); - graph.getModel().beginUpdate(); - try { - // add input, output and reference edges - for (Edge e : dataFlowGraph.getEdges()) { - if (e instanceof DataFlowEdge) { - DataFlowEdge dataFlow = (DataFlowEdge) e; - if (!dataFlow.isChannelToResource()) { - ResourceNode srcRes = (ResourceNode) dataFlow.getSource(); - DataTransferChannel channel = ((ChannelNode) dataFlow.getDestination()).getChannel(); - // input edge - for (Object edge: graph.getChildEdges(parent)) { - mxCell edgeCell = (mxCell) edge; - if (edgeCell.getValue() instanceof SrcDstAttribute) { - SrcDstAttribute edgeAttr = (SrcDstAttribute) edgeCell.getValue(); - if (srcRes.getPrimaryResourcePath().equals(edgeAttr.getSource()) && channel.equals(edgeAttr.getDestination())) { - edgeCell.setValue(dataFlow.getAttribute()); - break; - } - } - } - } - } - } - } finally { - graph.getModel().endUpdate(); - } - graph.refresh(); - } - - public class SrcDstAttribute extends EdgeAttribute { - private Object src; - private Object dst; - - public SrcDstAttribute(Object src, Object dst) { - this.src = src; - this.dst = dst; - } - - public Object getSource() { - return src; - } - - public Object getDestination() { - return dst; - } - - public String toString() { - return ""; - } - } }