tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r1174345 - in /tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout: CompositeEntity.java EntityBuilder.java LayoutBuilder.java TuscanyCompositeEntityBuilder.java
Date Thu, 22 Sep 2011 19:44:46 GMT
Author: rfeng
Date: Thu Sep 22 19:44:45 2011
New Revision: 1174345

URL: http://svn.apache.org/viewvc?rev=1174345&view=rev
Log:
Fix the dimension calculation based on the layout

Modified:
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/CompositeEntity.java
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/LayoutBuilder.java
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/CompositeEntity.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/CompositeEntity.java?rev=1174345&r1=1174344&r2=1174345&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/CompositeEntity.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/CompositeEntity.java
Thu Sep 22 19:44:45 2011
@@ -65,20 +65,8 @@ public class CompositeEntity extends Ent
     }
 
     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 Ent
         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;
+    }
 
 }

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java?rev=1174345&r1=1174344&r2=1174345&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/EntityBuilder.java
Thu Sep 22 19:44:45 2011
@@ -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]);
 

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/LayoutBuilder.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/LayoutBuilder.java?rev=1174345&r1=1174344&r2=1174345&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/LayoutBuilder.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/LayoutBuilder.java
Thu Sep 22 19:44:45 2011
@@ -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;
+    }
+
 }

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java?rev=1174345&r1=1174344&r2=1174345&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/layout/TuscanyCompositeEntityBuilder.java
Thu Sep 22 19:44:45 2011
@@ -81,6 +81,10 @@ public class TuscanyCompositeEntityBuild
 
         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]);
 



Mime
View raw message