diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2011-09-22 19:44:45 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2011-09-22 19:44:45 +0000 |
commit | 9f4dbf871c06cb8657c43204cd7fc1650f44bdf2 (patch) | |
tree | 7dab1d2ac9b72f268f89395392f1c79d8116c106 /sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org | |
parent | 9f1b3ecdad8b8ac6d305744e2a1d17cf3ef383d6 (diff) |
Fix the dimension calculation based on the layout
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1174345 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org')
4 files changed, 39 insertions, 132 deletions
diff --git a/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/CompositeEntity.java b/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/CompositeEntity.java index bd0a71431f..1520b0ae83 100755 --- a/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/CompositeEntity.java +++ b/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/CompositeEntity.java @@ -65,20 +65,8 @@ public class CompositeEntity extends Entity { } public void build() { - int h = 0; - int w = 0; - - for (ComponentEntity ent : componentList) { - - if (ent.getLevel() > maxInternalLevel) { - maxInternalLevel = ent.getLevel(); - h += (ent.getHeight() + Constant.COMPONENT_DEFAULT_HEIGHT); - } - if (ent.getLane() > maxInternalLane) { - maxInternalLane = ent.getLane(); - w += (ent.getWidth() + Constant.COMPONENT_DEFAULT_WIDTH); - } - } + int h = height; + int w = width; // Find the services height int size1 = services.size(); @@ -183,121 +171,12 @@ public class CompositeEntity extends Entity { return fileNameSuffix; } - // public int getNoOfRefs(){ - // return references.size(); - // } - // - // public int getNoOfSers(){ - // return services.size(); - // } - // - // public int getNoOfProps(){ - // return properties.size(); - // } - // - // public int getNoOfAdjacentUnits(){ - // return adjacentEntities.size(); - // } - // - // /** - // * Put a value to referenceToServiceMap - // * @param ref - // * @param ser - // * @return successfully added or not - // */ - // //assumption there can not be two services for the same reference - // public boolean addToRefToSerMap(String ref, String ser){ - // //ref = ref.toLowerCase(); - // //ser = ser.toLowerCase(); - // - // if (referenceToServiceMap.containsKey(ref)) - // return false; - // - // referenceToServiceMap.put(ref, ser); - // return true; - // } - // - // /** - // * Retrieve a service name for a given reference - // * @param ref - // * @return service name - // */ - // public String getSerOfRef(String ref){ - // //ref = ref.toLowerCase(); - // - // if (!referenceToServiceMap.containsKey(ref)) - // return null; - // - // return referenceToServiceMap.get(ref); - // } - // - // public void addAService(String serName){ - // //serName = serName.toLowerCase(); - // services.add(serName); - // - // } - // - // public void addAReference(String refName){ - // //refName = refName.toLowerCase(); - // references.add(refName); - // - // } - // - // public void addAProperty(String propName){ - // //propName = propName.toLowerCase(); - // properties.add(propName); - // - // } - // - // public void addAnAdjacentEntity(String x){ - //// System.out.println("eee "+x); - // adjacentEntities.add(x); - // - // } - // - // public void addAnConnectedEntity(String x){ - //// System.out.println("eee "+x); - // adjacentEntities.add(x); - // - // } - // - // public HashMap<String, String> getReferenceToServiceMap() { - // return referenceToServiceMap; - // } - // public void setReferenceToServiceMap( - // HashMap<String, String> referenceToServiceMap) { - // this.referenceToServiceMap = referenceToServiceMap; - // } - // public ArrayList<String> getProperties() { - // return properties; - // } - // public void setProperties(ArrayList<String> properties) { - // this.properties = properties; - // } - // public HashSet<String> getAdjacentEntities() { - // return adjacentEntities; - // } - // public void setAdjacentEntities(HashSet<String> adjacentEntities) { - // this.adjacentEntities = adjacentEntities; - // } - // public void setServices(ArrayList<String> services) { - // this.services = services; - // } - // - // public ArrayList<String> getServices() { - // return services; - // } - // - // public ArrayList<String> getReferences() { - // return references; - // } - - // public void setConnectedEntities(HashSet<String> connectedEntities) { - // this.connectedEntities = connectedEntities; - // } - // - // public HashSet<String> getConnectedEntities() { - // return connectedEntities; - // } + public void setMaxInternalLevel(int maxInternalLevel) { + this.maxInternalLevel = maxInternalLevel; + } + + public void setMaxInternalLane(int maxInternalLane) { + this.maxInternalLane = maxInternalLane; + } } diff --git a/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java b/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java index ed2d8c18c7..485ced717d 100755 --- a/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java +++ b/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java @@ -64,6 +64,10 @@ public class EntityBuilder { LayoutBuilder buildLayout = new LayoutBuilder(comps, conns, Constant.MAX_LEVELS); buildLayout.placeEntities(); + composite.setHeight(buildLayout.getTotalHeight()); + composite.setWidth(buildLayout.getTotalWidth()); + composite.setMaxInternalLane(buildLayout.getTotalLane()); + composite.setMaxInternalLevel(buildLayout.getTotalLevel()); //System.out.println("conns "+conns[0][0]); diff --git a/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/LayoutBuilder.java b/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/LayoutBuilder.java index a34e9e83b0..d67dee1629 100755 --- a/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/LayoutBuilder.java +++ b/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/LayoutBuilder.java @@ -35,7 +35,8 @@ public class LayoutBuilder { private int totalLevel; private int totalLane; - private Entity[][] grid; + private int totalHeight; + private int totalWidth; private int[][] graph; @@ -94,7 +95,7 @@ public class LayoutBuilder { sortEntities(); // Build the grid for entities - grid = new Entity[totalLane + 1][totalLevel + 1]; + Entity[][] grid = new Entity[totalLane + 1][totalLevel + 1]; int[] height = new int[totalLevel + 1]; int[] width = new int[totalLane + 1]; @@ -116,6 +117,9 @@ public class LayoutBuilder { height[j] += height[j - 1]; } + totalWidth = width[totalLane]; + totalHeight = height[totalLevel]; + for (int i = 0; i < totalLane + 1; i++) { for (int j = 0; j < totalLevel + 1; j++) { Entity ent = grid[i][j]; @@ -273,4 +277,20 @@ public class LayoutBuilder { } } + public int getTotalLevel() { + return totalLevel; + } + + public int getTotalLane() { + return totalLane; + } + + public int getTotalHeight() { + return totalHeight; + } + + public int getTotalWidth() { + return totalWidth; + } + } diff --git a/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java b/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java index c2bee79590..ef8dd3b27e 100755 --- a/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java +++ b/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java @@ -81,6 +81,10 @@ public class TuscanyCompositeEntityBuilder { LayoutBuilder buildLayout = new LayoutBuilder(comps, conns, Constant.MAX_LEVELS); buildLayout.placeEntities(); + composite.setHeight(buildLayout.getTotalHeight()); + composite.setWidth(buildLayout.getTotalWidth()); + composite.setMaxInternalLane(buildLayout.getTotalLane()); + composite.setMaxInternalLevel(buildLayout.getTotalLevel()); // System.out.println("conns " + conns[0][0]); |