diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java index 57ab5d2..e0ab458 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java @@ -203,8 +203,7 @@ } } } - final double BASE_WIDTH = 200; - final double BASE_HEIGHT = BASE_WIDTH/2; + private mxGraph constructNextSimulateGraph(Set simulateRes, DataTransferModel model,DataFlowGraph dataFlowGraph, mxGraph nextGraph) { bReflectingArchitectureModel = true; ((mxGraphModel) nextGraph.getModel()).clear(); @@ -243,21 +242,21 @@ nextGraph.getModel().beginUpdate(); - SimulationLayout simulationLayout = new SimulationLayout(simulator.getCurState().getRootResources()); + SimulationLayout simulationLayout = new SimulationLayout(simulator.getCurState()); try { Map resources = new HashMap<>(); int i = 0; // create resource vertices for (Resource resNode:simulator.getCurState().getRootResources()) { - double scale = simulationLayout.getScale(resNode); + double scale = simulationLayout.getScale(resNode.getResourceIdentifier()); double maxDiv = simulationLayout.maxDivisionLevel; - double w = BASE_WIDTH * scale /maxDiv; - double h = BASE_HEIGHT * scale /maxDiv; + double w = simulationLayout.BASE_WIDTH * scale /maxDiv; + double h = simulationLayout.BASE_HEIGHT * scale /maxDiv; - double division = simulationLayout.getDivision(resNode); - double w1 = 2*BASE_WIDTH/division; - double h1 = 2*BASE_HEIGHT/division; + double division = simulationLayout.getDivision(resNode.getResourceIdentifier()); + double w1 = 2*simulationLayout.BASE_WIDTH/division; + double h1 = 2*simulationLayout.BASE_HEIGHT/division; int childCount = simulator.getCurState().getRootResources().size(); double x = w * (1 + i - childCount / 2.0); double y = 20 ; @@ -278,30 +277,18 @@ bReflectingArchitectureModel = false; return nextGraph; } - private void createNextChildSimulateResourceVerticies(Object resource, Resource resNode, Map resources, SimulationLayout layout) { //sample + private void createNextChildSimulateResourceVerticies(Object parent, Resource resNode, Map resources, SimulationLayout layout) { //sample List children = resNode.getChildren(); if(children != null) { //List children = resNode.getChildren(); double i = 1; double childCount = children.size(); for (Resource childNode: children) { - double width, height, maxDiv; - ResourcePath childRes ; - maxDiv = layout.maxDivisionLevel; - if(!layout.isExistResource(childNode)){ - width = layout.getScale(resNode) * BASE_WIDTH / maxDiv; - height = layout.getScale(resNode) * BASE_HEIGHT/ maxDiv; - childRes = childNode.getResourceIdentifier(); - }else{ - width = layout.getScale(childNode) * BASE_WIDTH / maxDiv; - height = layout.getScale(childNode) * BASE_HEIGHT/ maxDiv; - childRes = childNode.getResourceIdentifier(); - } + Object childResource = layout.setLayout(graph,parent, childNode.getResourceIdentifier(), i, childCount); - - Object childResource = graph.insertVertex(resource, null, - childRes.toString(), width * (i - 1 - (childCount-1) / 2)*childCount, height/2, width, height, - "shape=ellipse;perimeter=ellipsePerimeter;verticalAlign=top;"); // insert a resource as a vertex +// Object childResource = graph.insertVertex(resource, null, +// childRes.toString(), width * (i - 1 - (childCount-1) / 2)*childCount, height/2, width, height, +// "shape=ellipse;perimeter=ellipsePerimeter;verticalAlign=top;"); // insert a resource as a vertex resources.put(childNode, childResource); i++; createNextChildSimulateResourceVerticies(childResource, childNode, resources,layout); @@ -309,7 +296,7 @@ } } if (children == null || children.size() == 0) { - Object state = graph.insertVertex(resource, null, + Object state = graph.insertVertex(parent, 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 } }