diff --git a/AlgebraicDataflowArchitectureModel/src/application/SimulatorWindow.java b/AlgebraicDataflowArchitectureModel/src/application/SimulatorWindow.java index 509eaa6..0d2add1 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/SimulatorWindow.java +++ b/AlgebraicDataflowArchitectureModel/src/application/SimulatorWindow.java @@ -127,44 +127,10 @@ setVisible(true); simulator = new Simulator(this.editor.getModel()); - constructSimulateGraph(simulator); - graphComponent.setCellEditor(new InputEventCellEditor(graphComponent, simulator, this.editor, graph)); - } - mxGraph constructSimulateGraph(Simulator simulator){ - bReflectingArchitectureModel = true; - ((mxGraphModel) graph.getModel()).clear(); - Object parent = graph.getDefaultParent(); - graph.getModel().beginUpdate(); - SimulationLayout simulationLayout = new SimulationLayout(simulator.getCurState()); + SimulationLayout layout = new SimulationLayout(simulator.getCurState()); + layout.constructSimulateGraph(graph, simulator); - try { - Map resources = new HashMap<>(); - int i = 0; - // create resource vertices - for (Resource resNode: simulator.getCurState().getRootResources()) { - double scale = simulationLayout.getScale(resNode.getResourceIdentifier()); - double maxDiv = simulationLayout.getMaxDivisionLevel(); - double w = simulationLayout.BASE_WIDTH * scale /maxDiv; - double h = simulationLayout.BASE_HEIGHT * scale /maxDiv; - int childCount = simulator.getCurState().getRootResources().size(); - double x = w * (1 + i - childCount / 2.0); - double y = 20 ; - ResourcePath res = resNode.getResourceIdentifier(); - Object resource = graph.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); - i++; - createNextChildSimulateResourceVerticies(resource, resNode, resources, simulationLayout); - - } - - } finally { - graph.getModel().endUpdate(); - } - - bReflectingArchitectureModel = false; - return graph; + graphComponent.setCellEditor(new InputEventCellEditor(graphComponent, simulator, this.editor, graph)); } private void createNextChildSimulateResourceVerticies(Object parent, Resource resNode, Map resources, SimulationLayout layout) { //sample List children = resNode.getChildren();