diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java index e0ab458..9c9c048 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/InputEventCellEditor.java @@ -284,7 +284,7 @@ double i = 1; double childCount = children.size(); for (Resource childNode: children) { - Object childResource = layout.setLayout(graph,parent, childNode.getResourceIdentifier(), i, childCount); + 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, diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/SimulationLayout.java b/AlgebraicDataflowArchitectureModel/src/application/editor/SimulationLayout.java index c876581..04b533c 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/SimulationLayout.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/SimulationLayout.java @@ -19,6 +19,7 @@ int maxDivisionLevel = 1; public final double BASE_WIDTH = 400; public final double BASE_HEIGHT = BASE_WIDTH/2; + public final double MARGIN_SCALE = 0.92; SystemState systemState; public SimulationLayout(SystemState systemState){ this.systemState = systemState; @@ -63,19 +64,29 @@ double width, height, maxDiv,x,y; ResourceIdentifier parentIdentifier = ResourceIdentifier.createFrom(resourceIdentifier.getParent()); maxDiv = maxDivisionLevel; + double parentWidth = graph.getCellGeometry(parent).getWidth(); + double parentHeight = graph.getCellGeometry(parent).getHeight(); + double scale = Math.pow(MARGIN_SCALE ,getDivision(resourceIdentifier)); + if((int)length==1)scale*=MARGIN_SCALE; + + width = getScale(resourceIdentifier) * BASE_WIDTH / maxDiv * scale; - width = getScale(resourceIdentifier) * BASE_WIDTH / maxDiv; - height = getScale(resourceIdentifier) * BASE_HEIGHT/ maxDiv; + width = parentWidth / length * MARGIN_SCALE; + height = width/2; //x = width * (index - 1 - (length-1) / 2.0)*length; - x = width * ((index-1)/length)*length; - //if((int)getDivision(resourceIdentifier)==(int)getDivision(parentIdentifier)){ +// x = width * ((index-1)/length)*length; +// if(index>1) x+=width * (1 - scale)/length; + x = parentWidth * (index - 1)/length + (parentWidth/length)*(1-MARGIN_SCALE)/2; + if((int)length==1){ - y=20; + // x += width * (1 - scale)/4; + y = 20; }else{ - y = (getScale(parentIdentifier)*BASE_HEIGHT/maxDiv)/2 - height/length; + // x += index * width * (1 - scale)/length/2; + y = parentHeight/2 - height/2; // y = height/length; }