| |
---|
| | private Simulator simulator; |
---|
| | private JComboBox<String> pulldownMenu; |
---|
| | private Editor editor; |
---|
| | private boolean bReflectingArchitectureModel = false; |
---|
| | private mxGraph graph; |
---|
| | |
---|
| | public InputEventCellEditor(mxGraphComponent graphComponent, Simulator simulator, Editor editor, mxGraph graph) { |
---|
| | |
---|
| | public InputEventCellEditor(mxGraphComponent graphComponent, Simulator simulator, Editor editor) { |
---|
| | this.graphComponent = graphComponent; |
---|
| | this.simulator = simulator; |
---|
| | this.editor = editor; |
---|
| | this.graph = graph; |
---|
| | } |
---|
| | |
---|
| | @Override |
---|
| | public Object getEditingCell() { |
---|
| |
---|
| | |
---|
| | Event newEvent = new Event(eventChs.get(eventNum), eventMessage, eventResPath, simulator.getCurState().getResource(resId)); |
---|
| | simulator.transition(newEvent); |
---|
| | |
---|
| | SimulationLayout layout = new SimulationLayout(simulator.getCurState()); |
---|
| | layout.constructSimulateGraph(graph, simulator); |
---|
| | |
---|
| | graphComponent.setCellEditor(new InputEventCellEditor(graphComponent, simulator, this.editor, graph)); |
---|
| | // SimulationLayout layout = new SimulationLayout(simulator.getCurState()); |
---|
| | // layout.constructSimulateGraph(graph, simulator); |
---|
| | |
---|
| | graphComponent.setCellEditor(new InputEventCellEditor(graphComponent, simulator, this.editor)); |
---|
| | |
---|
| | } catch (ParameterizedIdentifierIsFutureWork | ResolvingMultipleDefinitionIsFutureWork |
---|
| | | InvalidMessage | UnificationFailed | ValueUndefined | ExpectedRightBracket | WrongJsonExpression | ExpectedColon e) { |
---|
| | e.printStackTrace(); |
---|
| |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | private mxGraph constructNextSimulateGraph(Set<Resource> simulateRes, DataTransferModel model,DataFlowGraph dataFlowGraph, mxGraph nextGraph) { |
---|
| | bReflectingArchitectureModel = true; |
---|
| | ((mxGraphModel) nextGraph.getModel()).clear(); |
---|
| | Object parent = nextGraph.getDefaultParent(); |
---|
| | nextGraph.getModel().beginUpdate(); |
---|
| | |
---|
| | try { |
---|
| | Map<Resource, Object> resources = new HashMap<>(); |
---|
| | |
---|
| | // create resource vertices |
---|
| | for (Resource resNode: simulateRes) { |
---|
| | int w = 400; |
---|
| | int h = 150; |
---|
| | ResourcePath res = resNode.getResourceIdentifier(); |
---|
| | Object resource = nextGraph.insertVertex(parent, null, |
---|
| | res.toString(), x, y, w, h, |
---|
| | "shape=ellipse;perimeter=ellipsePerimeter;verticalAlign=top;"); // insert a resource as a vertex |
---|
| | resources.put(resNode, resource); |
---|
| | |
---|
| | createNextChildSimulateResourceVerticies(resource, resNode, resources, w, h); |
---|
| | x+=400; |
---|
| | } |
---|
| | |
---|
| | } finally { |
---|
| | nextGraph.getModel().endUpdate(); |
---|
| | } |
---|
| | |
---|
| | bReflectingArchitectureModel = false; |
---|
| | return nextGraph; |
---|
| | } |
---|
| | |
---|
| | private void createNextChildSimulateResourceVerticies(Object resource, Resource resNode, Map<Resource, Object> resources, int w, int h) { //sample |
---|
| | |
---|
| | if(resNode.getChildren() != null) { |
---|
| | for (Resource childNode: resNode.getChildren()) { |
---|
| | int i = 1; |
---|
| | ResourcePath childRes = childNode.getResourceIdentifier(); |
---|
| | Object childResource = graph.insertVertex(resource, null, |
---|
| | childRes.toString(), x/i, 0, w/(i+1), h/(i+2), |
---|
| | "shape=ellipse;perimeter=ellipsePerimeter;verticalAlign=top;"); // insert a resource as a vertex |
---|
| | resources.put(childNode, childResource); |
---|
| | i++; |
---|
| | createNextChildSimulateResourceVerticies(childResource, childNode, resources, w, h); |
---|
| | } |
---|
| | } |
---|
| | if (resNode.getChildren() == null || resNode.getChildren().size() == 0) { |
---|
| | Object state = graph.insertVertex(resource, null, |
---|
| | resNode.getState().getValue().toString(), 0.5, 0.5, 0.25, 0.25, "opacity=0;verticalAlign=down;", true); // insert a state label as a vertex |
---|
| | } |
---|
| | } |
---|
| | // private mxGraph constructNextSimulateGraph(Set<Resource> simulateRes, DataTransferModel model,DataFlowGraph dataFlowGraph, mxGraph nextGraph) { |
---|
| | // bReflectingArchitectureModel = true; |
---|
| | // ((mxGraphModel) nextGraph.getModel()).clear(); |
---|
| | // Object parent = nextGraph.getDefaultParent(); |
---|
| | // nextGraph.getModel().beginUpdate(); |
---|
| | // |
---|
| | // try { |
---|
| | // Map<Resource, Object> resources = new HashMap<>(); |
---|
| | // |
---|
| | // // create resource vertices |
---|
| | // for (Resource resNode: simulateRes) { |
---|
| | // int w = 400; |
---|
| | // int h = 150; |
---|
| | // ResourcePath res = resNode.getResourceIdentifier(); |
---|
| | // Object resource = nextGraph.insertVertex(parent, null, |
---|
| | // res.toString(), x, y, w, h, |
---|
| | // "shape=ellipse;perimeter=ellipsePerimeter;verticalAlign=top;"); // insert a resource as a vertex |
---|
| | // resources.put(resNode, resource); |
---|
| | // |
---|
| | // createNextChildSimulateResourceVerticies(resource, resNode, resources, w, h); |
---|
| | // x+=400; |
---|
| | // } |
---|
| | // |
---|
| | // } finally { |
---|
| | // nextGraph.getModel().endUpdate(); |
---|
| | // } |
---|
| | // |
---|
| | // bReflectingArchitectureModel = false; |
---|
| | // return nextGraph; |
---|
| | // } |
---|
| | // |
---|
| | // private void createNextChildSimulateResourceVerticies(Object resource, Resource resNode, Map<Resource, Object> resources, int w, int h) { //sample |
---|
| | // |
---|
| | // if(resNode.getChildren() != null) { |
---|
| | // for (Resource childNode: resNode.getChildren()) { |
---|
| | // int i = 1; |
---|
| | // ResourcePath childRes = childNode.getResourceIdentifier(); |
---|
| | // Object childResource = graph.insertVertex(resource, null, |
---|
| | // childRes.toString(), x/i, 0, w/(i+1), h/(i+2), |
---|
| | // "shape=ellipse;perimeter=ellipsePerimeter;verticalAlign=top;"); // insert a resource as a vertex |
---|
| | // resources.put(childNode, childResource); |
---|
| | // i++; |
---|
| | // createNextChildSimulateResourceVerticies(childResource, childNode, resources, w, h); |
---|
| | // } |
---|
| | // } |
---|
| | // if (resNode.getChildren() == null || resNode.getChildren().size() == 0) { |
---|
| | // Object state = graph.insertVertex(resource, null, |
---|
| | // resNode.getState().getValue().toString(), 0.5, 0.5, 0.25, 0.25, "opacity=0;verticalAlign=down;", true); // insert a state label as a vertex |
---|
| | // } |
---|
| | // } |
---|
| | |
---|
| | @Override |
---|
| | public void stopEditing(boolean cancel) { |
---|
| | if (editingCell != null) { |
---|
| |
---|
| | |