diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java index c59fec4..dcad154 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java @@ -203,7 +203,7 @@ } } } - final double BASE_WIDTH = 100; + 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; @@ -251,20 +251,22 @@ // create resource vertices for (Resource resNode:simulator.getCurState().getRootResources()) { double scale = simulationLayout.getScale(resNode); - double w = BASE_WIDTH * scale; - double h = BASE_HEIGHT * scale; + double maxDiv = simulationLayout.maxDivisionLevel; + double w = BASE_WIDTH * scale /maxDiv; + double h = BASE_HEIGHT * scale /maxDiv; double division = simulationLayout.getDivision(resNode); double w1 = 2*BASE_WIDTH/division; double h1 = 2*BASE_HEIGHT/division; - double x = 40 + i * w; + int childCount = simulator.getCurState().getRootResources().size(); + double x = w * (1 + i - childCount / 2.0); double y = 20 ; ResourcePath res = resNode.getResourceIdentifier(); Object resource = nextGraph.insertVertex(parent, null, - res.toString(), x, y, w1, h1, + 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); } @@ -277,30 +279,36 @@ return nextGraph; } private void createNextChildSimulateResourceVerticies(Object resource, Resource resNode, Map resources, SimulationLayout layout) { //sample - - if(resNode.getChildren() != null) { - List children = resNode.getChildren(); + List children = resNode.getChildren(); + if(children != null) { + //List children = resNode.getChildren(); int i = 1; int 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(); + } - ResourcePath childRes = childNode.getResourceIdentifier(); - double width = layout.getScale(childNode) * BASE_WIDTH ; - double height = layout.getScale(childNode) * BASE_HEIGHT; - - double division = layout.getDivision(childNode); - double w1 = 2*BASE_WIDTH/division; - double h1 = 2*BASE_HEIGHT/division; Object childResource = graph.insertVertex(resource, null, - childRes.toString(), w1 * i - (w1 * childCount / 2.0), h1/2, w1, h1, + childRes.toString(), width * (i - childCount / 2.0), 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); + } } - if (resNode.getChildren() == null || resNode.getChildren().size() == 0) { + if (children == null || children.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 }