Author: nirmal070125
Date: Tue Jun  7 05:17:25 2011
New Revision: 1132863

URL: http://svn.apache.org/viewvc?rev=1132863&view=rev
Log:
Work up to date: not stable

Added:
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/component.svg
   (with props)
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/reference.svg
   (with props)
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/service.svg
   (with props)
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/test.svg
   (with props)
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLReader.java
   (with props)
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/Entity.java
   (with props)
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java
   (with props)
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/PropertyAllocator.java
   (with props)
Modified:
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Artifact.java
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Component.java
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Composite.java
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Property.java
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Reference.java
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java
    
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/SVGDiagramGenerator.java

Added: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/component.svg
URL: 
http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/component.svg?rev=1132863&view=auto
==============================================================================
--- 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/component.svg
 (added)
+++ 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/component.svg
 Tue Jun  7 05:17:25 2011
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><svg 
xmlns:xlink="http://www.w3.org/1999/xlink"; xmlns="http://www.w3.org/2000/svg"; 
contentScriptType="text/ecmascript" zoomAndPan="magnify" 
contentStyleType="text/css" preserveAspectRatio="xMidYMid meet" 
version="1.0"><rect x="0" y="0" fill-opacity="0.75" fill="#3D59AB" width="200" 
rx="20" ry="20" height="130" stroke="#104E8B"/><text x="100" font-size="20" 
dominant-baseline="mathematical" y="70" text-anchor="middle">SCA 
Component</text></svg>
\ No newline at end of file

Propchange: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/component.svg
------------------------------------------------------------------------------
    svn:executable = *

Added: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/reference.svg
URL: 
http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/reference.svg?rev=1132863&view=auto
==============================================================================
--- 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/reference.svg
 (added)
+++ 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/reference.svg
 Tue Jun  7 05:17:25 2011
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><svg 
xmlns:xlink="http://www.w3.org/1999/xlink"; xmlns="http://www.w3.org/2000/svg"; 
contentScriptType="text/ecmascript" zoomAndPan="magnify" 
contentStyleType="text/css" preserveAspectRatio="xMidYMid meet" 
version="1.0"><polygon fill="#BF3EFF" points="45,15 30,30 0,30 15,15 0,0 30,0 " 
stroke="#68228B"/></svg>
\ No newline at end of file

Propchange: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/reference.svg
------------------------------------------------------------------------------
    svn:executable = *

Added: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/service.svg
URL: 
http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/service.svg?rev=1132863&view=auto
==============================================================================
--- 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/service.svg
 (added)
+++ 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/service.svg
 Tue Jun  7 05:17:25 2011
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><svg 
xmlns:xlink="http://www.w3.org/1999/xlink"; xmlns="http://www.w3.org/2000/svg"; 
contentScriptType="text/ecmascript" zoomAndPan="magnify" 
contentStyleType="text/css" preserveAspectRatio="xMidYMid meet" 
version="1.0"><polygon fill="#00CD66" points="15,15 0,0 30,0 45,15 30,30 0,30 " 
stroke="#008B45"/></svg>
\ No newline at end of file

Propchange: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/service.svg
------------------------------------------------------------------------------
    svn:executable = *

Added: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/test.svg
URL: 
http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/test.svg?rev=1132863&view=auto
==============================================================================
--- 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/test.svg
 (added)
+++ 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/test.svg
 Tue Jun  7 05:17:25 2011
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?><svg 
xmlns:xlink="http://www.w3.org/1999/xlink"; xmlns="http://www.w3.org/2000/svg"; 
contentScriptType="text/ecmascript" zoomAndPan="magnify" 
contentStyleType="text/css" preserveAspectRatio="xMidYMid meet" 
version="1.0"><rect x="0" y="0" fill-opacity="0.75" fill="#3D59AB" width="200" 
rx="20" ry="20" height="130" stroke="#104E8B"/><text x="100" font-size="20" 
dominant-baseline="mathematical" y="70" text-anchor="middle">SCA 
Component</text></svg>
\ No newline at end of file

Propchange: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/test.svg
------------------------------------------------------------------------------
    svn:executable = *

Modified: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Artifact.java
URL: 
http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Artifact.java?rev=1132863&r1=1132862&r2=1132863&view=diff
==============================================================================
--- 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Artifact.java
 (original)
+++ 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Artifact.java
 Tue Jun  7 05:17:25 2011
@@ -32,9 +32,22 @@ public abstract class Artifact {
        private String svgNs;
        private static final String ROUND_CORNER = "20" ;       
        
+       /**
+        * Abstract method
+        * @param document DOM document
+        * @param svgNs namespace URI 
+        * @param x x-coordinate
+        * @param y y-coordinate
+        * @param height height of the shape
+        * @param width width of the shape
+        * @return DOM Element
+        */
        public abstract Element addElement(Document document, String svgNs, 
                        int x, int y, int height, int width);
        
+       public abstract Element addElement(Document document, String svgNs, 
+                       int x, int y);
+       
        public int getHeight() {
                return height;
        }

Modified: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Component.java
URL: 
http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Component.java?rev=1132863&r1=1132862&r2=1132863&view=diff
==============================================================================
--- 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Component.java
 (original)
+++ 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Component.java
 Tue Jun  7 05:17:25 2011
@@ -24,8 +24,8 @@ import org.w3c.dom.Element;
 
 public class Component extends Artifact{
        
-//     private static final String WIDTH = "200" ;
-//     private static final String HEIGHT = "130" ;
+       public static final int DEFAULT_WIDTH = 200 ;
+       public static final int DEFAULT_HEIGHT = 130 ;
        
        
 //     public  Element addElement(Document document, 
@@ -60,7 +60,9 @@ public class Component extends Artifact{
 //             return rectangle;
 //     }
 
-       
+       /**
+        * Create an element with specified height and width
+        */
        public Element addElement(Document document, String svgNs, int x, int y,
                        int height, int width) {
                
@@ -81,6 +83,17 @@ public class Component extends Artifact{
                rectangle.setAttributeNS(null, "fill-opacity", "0.75");
                return rectangle;
        }
+
+       /**
+        * Create an element with default height and width
+        */
+       public Element addElement(Document document, String svgNs, int x, int 
y) {
+
+               return addElement(document, svgNs, x, y, DEFAULT_HEIGHT, 
DEFAULT_WIDTH);
+               
+       }
+       
+       
        
 
 }

Modified: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Composite.java
URL: 
http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Composite.java?rev=1132863&r1=1132862&r2=1132863&view=diff
==============================================================================
--- 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Composite.java
 (original)
+++ 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Composite.java
 Tue Jun  7 05:17:25 2011
@@ -77,6 +77,11 @@ public class Composite extends Artifact{
                
                return rectangle;
        }
+
+       //OBSOLETE
+       public Element addElement(Document document, String svgNs, int x, int 
y) {
+               return null;
+       }
        
        
 

Modified: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Property.java
URL: 
http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Property.java?rev=1132863&r1=1132862&r2=1132863&view=diff
==============================================================================
--- 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Property.java
 (original)
+++ 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Property.java
 Tue Jun  7 05:17:25 2011
@@ -24,7 +24,8 @@ import org.w3c.dom.Element;
 
 public class Property extends Artifact{
        
-//     private static final String WIDTH = "20" ;
+       public static final int MAXIMUM_HEIGHT = 20 ; //default value
+       public static final int SPACING = 20 ;  //default value
        
 //     public static Element addPropertyElement(Document document, 
 //                     String svgNs, int x, int y) {
@@ -40,17 +41,18 @@ public class Property extends Artifact{
 //             return rectangle;
 //     }
 
-       
+       /**
+        * Property is a square.
+        *                       ___
+        *                      |       |
+        *                      |___|
+        * 
+        */
        public Element addElement(Document document, String svgNs, int x, int y,
                        int height, int width) {
-               return this.addElement(document, svgNs, x, y, height);
-       }
-       
-       public Element addElement(Document document, String svgNs, int x, int y,
-                       int height) {
                
                this.setHeight(height);
-               this.setWidth(height);
+               this.setWidth(width);
                this.setxCoordinate(x);
                this.setyCoordinate(y);
                
@@ -65,5 +67,19 @@ public class Property extends Artifact{
                
                return rectangle;
        }
+       
+       
+       public Element addElement(Document document, String svgNs, int x, int y,
+                       int height) {
+               
+               return addElement(document, svgNs, x, y, height, height);
+       }
+
+       
+       public Element addElement(Document document, String svgNs, int x, int 
y) {
+               
+
+               return addElement(document, svgNs, x, y, MAXIMUM_HEIGHT);
+       }
 
 }

Modified: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Reference.java
URL: 
http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Reference.java?rev=1132863&r1=1132862&r2=1132863&view=diff
==============================================================================
--- 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Reference.java
 (original)
+++ 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Reference.java
 Tue Jun  7 05:17:25 2011
@@ -24,6 +24,9 @@ import org.w3c.dom.Element;
 
 public class Reference extends Artifact {
        
+       public static final int MAXIMUM_HEIGHT = 30 ;   //default value
+       public static final int SPACING = 10 ;  //default value
+       
 //private static final int COMMON_LENGTH = 20 ;        
        
 //     public static Element addReferenceElement(Document document, String 
svgNs, int midX, int midY) {
@@ -46,45 +49,33 @@ public class Reference extends Artifact 
 //     }
 //     
 
-       
-       public Element addElement(Document document, String svgNs, int x, int y,
-                       int height, int width) {
-               return this.addElement(document, svgNs, x, y, height);
-       }
-       
        /**
-        * In a Reference the (x,y) coordinates refers to the outer edge of the 
polygon
-        *              ______
-        *              \     \ 
-        *               \     \ ___ outer edge
-        *               /     /
-        *              /____ /
-        * 
-        * @param document
-        * @param svgNs
-        * @param x
-        * @param y
-        * @param height
-        * @return
+        * In a Reference the (x,y) coordinates refers to the top corner edge 
of the polygon
+        *                     (x,y)______
+        *                                      \     \ 
+        *                                       \     \
+        *                                       /     /
+        *                                      /____ /
         */
        public Element addElement(Document document, String svgNs, int x, int y,
-                       int height) {
+                       int height, int width) {
                
+
                this.setHeight(height);
-               this.setWidth(height);
+               this.setWidth(width);
                this.setxCoordinate(x);
                this.setyCoordinate(y);
                
-               int length = height/2;
+               int halfOfHeight = height/2;
                
                Element polygon = document.createElementNS(svgNs, "polygon");
                polygon.setAttributeNS(null, "points", 
                                ""+ x +","+y+" " +
-                               ""+ (x-length) +","+(y+length)+" " +
-                               ""+ (x-length*3) +","+(y+length)+" " +
-                               ""+ (x-length*2) +","+(y)+" " +
-                               ""+ (x-length*3) +","+(y-length)+" " +
-                               ""+ (x-length) +","+(y-length)+" "
+                               ""+ (x+2*halfOfHeight) +","+(y)+" " +
+                               ""+ (x+3*halfOfHeight) +","+(y-halfOfHeight)+" 
" +
+                               ""+ (x+2*halfOfHeight) 
+","+(y-2*halfOfHeight)+" " +
+                               ""+ (x) +","+(y-2*halfOfHeight)+" " +
+                               ""+ (x+halfOfHeight) +","+(y-halfOfHeight)+" "
                        );
                
                polygon.setAttributeNS(null, "fill", "#BF3EFF");
@@ -92,5 +83,18 @@ public class Reference extends Artifact 
                
                return polygon;
        }
+       
+       
+       public Element addElement(Document document, String svgNs, int x, int y,
+                       int height) {
+               
+               return this.addElement(document, svgNs, x, y, height, 
height*3/2);
+       }
+
+       
+       public Element addElement(Document document, String svgNs, int x, int 
y) {
+               
+               return this.addElement(document, svgNs, x, y, MAXIMUM_HEIGHT);
+       }
 
 }

Modified: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java
URL: 
http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java?rev=1132863&r1=1132862&r2=1132863&view=diff
==============================================================================
--- 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java
 (original)
+++ 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java
 Tue Jun  7 05:17:25 2011
@@ -24,7 +24,8 @@ import org.w3c.dom.Element;
 
 public class Service extends Artifact{
 
-//     private static final int COMMON_LENGTH = 20 ;   
+       public static final int MAXIMUM_HEIGHT = 30 ;   //default value
+       public static final int SPACING = 10 ;  //default value
        
 //     public static Element addServiceElement(Document document, String 
svgNs, int midX, int midY) {
 //             // Create the rectangle.
@@ -43,45 +44,32 @@ public class Service extends Artifact{
 //             return polygon;
 //     }
 
-       
-       public Element addElement(Document document, String svgNs, int x, int y,
-                       int height, int width) {
-               return this.addElement(document, svgNs, x, y, height);
-       }
-       
        /**
-        *  In a Service the (x,y) coordinates refers to the inner edge of the 
polygon
-        *                                      ______
+        * In a Service the (x,y) coordinates refers to the top corner edge of 
the polygon
+        *                     (x,y)______
         *                                      \     \ 
-        *      inner edge      ____ \     \
+        *                                       \     \
         *                                       /     /
         *                                      /____ /
-        * 
-        * @param document
-        * @param svgNs
-        * @param x
-        * @param y
-        * @param height
-        * @return
         */
        public Element addElement(Document document, String svgNs, int x, int y,
-                       int height) {
+                       int height, int width) {
                
                this.setHeight(height);
-               this.setWidth(height);
+               this.setWidth(width);
                this.setxCoordinate(x);
                this.setyCoordinate(y);
                
-               int length = height/2;
+               int halfOfHeight = height/2;
                
                Element polygon = document.createElementNS(svgNs, "polygon");
                polygon.setAttributeNS(null, "points", 
                                ""+ x +","+y+" " +
-                               ""+ (x-length) +","+(y-length)+" " +
-                               ""+ (x+length) +","+(y-length)+" " +
-                               ""+ (x+(length*2)) +","+y+" " +
-                               ""+ (x+length) +","+(y+length)+" " +
-                               ""+ (x-length) +","+(y+length)+" "
+                               ""+ (x+2*halfOfHeight) +","+(y)+" " +
+                               ""+ (x+3*halfOfHeight) +","+(y-halfOfHeight)+" 
" +
+                               ""+ (x+2*halfOfHeight) 
+","+(y-2*halfOfHeight)+" " +
+                               ""+ (x) +","+(y-2*halfOfHeight)+" " +
+                               ""+ (x+halfOfHeight) +","+(y-halfOfHeight)+" "
                        );
                
                polygon.setAttributeNS(null, "fill", "#00CD66");
@@ -90,5 +78,29 @@ public class Service extends Artifact{
                return polygon;
        }
        
+       /**
+        * Width is 3/2 times of the height
+        * @param document
+        * @param svgNs
+        * @param x
+        * @param y
+        * @param height
+        * @return
+        */
+       public Element addElement(Document document, String svgNs, int x, int y,
+                       int height) {
+               
+               return this.addElement(document, svgNs, x, y, height, 
height*3/2);
+       }
+
+       /**
+        * Use default height
+        */
+       public Element addElement(Document document, String svgNs, int x, int 
y) {
+               
+               return this.addElement(document, svgNs, x, y, MAXIMUM_HEIGHT);
+               
+       }
+       
        
 }

Added: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLReader.java
URL: 
http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLReader.java?rev=1132863&view=auto
==============================================================================
--- 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLReader.java
 (added)
+++ 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLReader.java
 Tue Jun  7 05:17:25 2011
@@ -0,0 +1,28 @@
+package org.apache.tuscany.sca.impl.io;
+
+import java.io.IOException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+public class XMLReader {
+
+       //get the factory
+       DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+       private Document dom;
+
+       public Document parseXMLFile(String file) throws Exception
+       {
+               //Using factory get an instance of document builder
+               DocumentBuilder db = dbf.newDocumentBuilder();
+
+               //parse using builder to get DOM representation of the XML file
+               dom = db.parse(file);
+
+               return dom;
+       }
+}

Propchange: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLReader.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/Entity.java
URL: 
http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/Entity.java?rev=1132863&view=auto
==============================================================================
--- 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/Entity.java
 (added)
+++ 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/Entity.java
 Tue Jun  7 05:17:25 2011
@@ -0,0 +1,246 @@
+package org.apache.tuscany.sca.impl.layout;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+
+import org.apache.tuscany.sca.impl.artifacts.Component;
+import org.apache.tuscany.sca.impl.artifacts.Property;
+import org.apache.tuscany.sca.impl.artifacts.Reference;
+import org.apache.tuscany.sca.impl.artifacts.Service;
+
+/**
+ * Represents an unit (a component including its references, services, 
properties
+ * and adjacent units) in the diagram.
+ * @author nirmal
+ *
+ */
+public class Entity {
+       
+       private String componentName;
+       private int X, Y, level, lane, refHeight, serHeight, propLength;
+       
+       public static final int defaultNoOfSers= Component.DEFAULT_HEIGHT / 
(Service.MAXIMUM_HEIGHT+Service.SPACING);
+       public static final int defaultNoOfRefs= Component.DEFAULT_HEIGHT / 
(Reference.MAXIMUM_HEIGHT+Reference.SPACING); //same value for defaultNoOfSers
+       public static final int defaultNoOfProps= Component.DEFAULT_WIDTH / 
(Property.MAXIMUM_HEIGHT+Property.SPACING); 
+       
+       private HashMap<String, String> referenceToServiceMap = new 
HashMap<String, String>();
+       
+       private ArrayList<String> references = new ArrayList<String>();
+       private ArrayList<String> refProperties = new ArrayList<String>();
+       
+       private ArrayList<String> services = new ArrayList<String>();
+       private ArrayList<String> serProperties = new ArrayList<String>();
+       
+       private ArrayList<String> properties = new ArrayList<String>();
+       private ArrayList<String> propProperties = new ArrayList<String>();
+       
+       private HashSet<String> adjacentEntities = new HashSet<String>();
+       
+       
+       public Entity(){
+               
+               
+       }
+       
+       public void referenceHeight(){
+               if(Entity.defaultNoOfRefs < getNoOfRefs()){
+
+                       refHeight = (Component.DEFAULT_HEIGHT / getNoOfRefs()) 
- Reference.SPACING;
+               }
+               else
+                       refHeight = Reference.MAXIMUM_HEIGHT;
+       }
+       
+       public void serviceHeight(){
+               if(Entity.defaultNoOfSers < getNoOfSers()){
+
+                       serHeight = (Component.DEFAULT_HEIGHT / getNoOfSers()) 
- Service.SPACING;
+               }
+               else
+                       serHeight = Service.MAXIMUM_HEIGHT;
+       }
+       
+       public void propertyLength(){
+               if(Entity.defaultNoOfProps < getNoOfProps()){
+
+                       propLength = (Component.DEFAULT_WIDTH / getNoOfProps()) 
- Property.SPACING;
+               }
+               else
+                       propLength = Property.MAXIMUM_HEIGHT;
+       }
+       
+       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){
+       
+               adjacentEntities.add(x);
+               
+       }
+       
+       public void setComponentName(String componentName) {
+               this.componentName = componentName;
+       }
+       public String getComponentName() {
+               return componentName;
+       }
+       
+       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 int getX() {
+               return X;
+       }
+
+       public void setX(int x) {
+               X = x;
+       }
+
+       public int getY() {
+               return Y;
+       }
+
+       public void setY(int y) {
+               Y = y;
+       }
+
+       public int getLevel() {
+               return level;
+       }
+
+       public void setLevel(int level) {
+               this.level = level;
+       }
+
+       public int getLane() {
+               return lane;
+       }
+
+       public void setLane(int lane) {
+               this.lane = lane;
+       }
+
+       public ArrayList<String> getRefProperties() {
+               return refProperties;
+       }
+
+       public void setRefProperties(ArrayList<String> refProperties) {
+               this.refProperties = refProperties;
+       }
+
+       public ArrayList<String> getSerProperties() {
+               return serProperties;
+       }
+
+       public void setSerProperties(ArrayList<String> serProperties) {
+               this.serProperties = serProperties;
+       }
+
+       public ArrayList<String> getPropProperties() {
+               return propProperties;
+       }
+
+       public void setPropProperties(ArrayList<String> propProperties) {
+               this.propProperties = propProperties;
+       }
+
+       public int getRefHeight() {
+               return refHeight;
+       }
+
+       public int getSerHeight() {
+               return serHeight;
+       }
+
+       public int getPropLength() {
+               return propLength;
+       }
+
+}

Propchange: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/Entity.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java
URL: 
http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java?rev=1132863&view=auto
==============================================================================
--- 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java
 (added)
+++ 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java
 Tue Jun  7 05:17:25 2011
@@ -0,0 +1,155 @@
+package org.apache.tuscany.sca.impl.layout;
+
+import java.util.ArrayList;
+
+import org.apache.tuscany.sca.impl.artifacts.Component;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class EntityBuilder {
+       
+       private Document dom;
+       private final int initPoint = 100;
+       private final int spaceX = Component.DEFAULT_WIDTH*2;
+       private final int spaceY = Component.DEFAULT_HEIGHT*2;
+       private ArrayList<Integer> levelCount = new ArrayList<Integer>();
+       
+       public EntityBuilder(Document aDom){
+               dom = aDom;
+       }
+       
+       public Entity[] buildEntities(){
+               Entity[] elts = null;
+               //get the root element
+               Element docEle = dom.getDocumentElement();
+
+               //get a nodelist of elements
+               NodeList nl = docEle.getElementsByTagName("sca:component");
+               if(nl != null && nl.getLength() > 0 ) {
+                       elts = new Entity[nl.getLength()];
+                       for(int i = 0 ; i < nl.getLength();i++) {
+                               Element nVal = (Element)nl.item(i);
+                               
elts[i].setComponentName(nVal.getAttribute("name"));
+                               setReferences(nVal, elts[i]);
+                               setServices(nVal, elts[i]);
+                               setProperties(nVal, elts[i]);
+                               elts[i].referenceHeight();
+                               elts[i].serviceHeight();
+                               elts[i].propertyLength();
+                       }
+               }
+               
+               //get a nodelist of elements
+               NodeList nl2 = docEle.getElementsByTagName("sca:wire");
+               if(nl2 != null && nl2.getLength() > 0 ) {
+                       
+                       for(int i = 0 ; i < nl2.getLength();i++) {
+                               Element nVal = (Element)nl2.item(i);
+                               String[] source = 
splitValues(nVal.getAttribute("source"));
+                               String[] target = 
splitValues(nVal.getAttribute("target"));
+                               
+                               for(Entity ent: elts){
+                                       
if(ent.getComponentName().equalsIgnoreCase(source[0])){
+                                               
ent.addAnAdjacentEntity(target[0]);
+                                               ent.addToRefToSerMap(source[1], 
target[1]);
+                                               break;
+                                       }
+                               }
+                       }
+               }
+               
+               positionEntities(elts);
+               
+               return elts;
+                       
+       }
+       
+       private void positionEntities(Entity[] ents){
+               Entity startEnt = null;
+               for(Entity ent: ents){
+                       if(ent.getAdjacentEntities().size() != 0){
+                               setPosition(ent, initPoint, initPoint, 0, 0);
+                               levelCount.add(0, 1);
+                               startEnt = ent;
+                               break;
+                       }
+               }
+               
+               if(startEnt != null)
+                       assignPositions(ents, startEnt);
+               
+       }
+       
+       private void assignPositions(Entity[] ents, Entity ent){
+               int i=0;
+               for(String name: ent.getAdjacentEntities()){
+                       for(Entity aEnt: ents){
+                               
if(name.equalsIgnoreCase(aEnt.getComponentName())){
+                                       int lane = ent.getLane()+1;
+                                       if(levelCount.get(lane) != null){
+                                               levelCount.add(lane, 1);
+                                               setPosition(aEnt, 
ent.getX()+spaceX, ent.getY(), 0, lane);
+                                       }
+                                       else{
+                                               int level = 
levelCount.get(lane);
+                                               levelCount.add(lane, level+1);
+                                               setPosition(aEnt, 
ent.getX()+spaceX, ent.getY()+spaceY*level, level, lane);
+                                       }
+                                       assignPositions(ents, aEnt);
+                                       break;
+                               }
+                       }
+                       i++;
+               }
+       }
+       
+       private void setPosition(Entity ent, int x, int y, int level, int lane){
+               ent.setX(x);
+               ent.setY(y);
+               ent.setLevel(level);
+               ent.setLane(lane);
+       }
+       
+       
+       private String[] splitValues(String str){
+               return str.split("/");
+       }
+
+       private void setReferences(Element nVal, Entity ent) {
+
+               NodeList nl = nVal.getElementsByTagName("sca:reference");
+               if(nl != null && nl.getLength() > 0 ) {
+                       for(int i = 0 ; i < nl.getLength();i++) {
+                               Element elt = (Element)nl.item(i);
+                               ent.addAReference(elt.getAttribute("name"));
+                       }
+               }
+       }
+       
+       private void setServices(Element nVal, Entity ent) {
+
+               NodeList nl = nVal.getElementsByTagName("sca:service");
+               if(nl != null && nl.getLength() > 0 ) {
+                       for(int i = 0 ; i < nl.getLength();i++) {
+                               Element elt = (Element)nl.item(i);
+                               ent.addAService(elt.getAttribute("name"));
+                       }
+               }
+       }
+       
+       private void setProperties(Element nVal, Entity ent) {
+
+               NodeList nl = nVal.getElementsByTagName("sca:property");
+               if(nl != null && nl.getLength() > 0 ) {
+                       for(int i = 0 ; i < nl.getLength();i++) {
+                               Element elt = (Element)nl.item(i);
+                               ent.addAProperty(elt.getAttribute("name"));
+                       }
+               }
+       }
+       
+       
+
+}

Propchange: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/PropertyAllocator.java
URL: 
http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/PropertyAllocator.java?rev=1132863&view=auto
==============================================================================
--- 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/PropertyAllocator.java
 (added)
+++ 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/PropertyAllocator.java
 Tue Jun  7 05:17:25 2011
@@ -0,0 +1,26 @@
+package org.apache.tuscany.sca.impl.layout;
+
+import java.util.Iterator;
+
+import org.apache.tuscany.sca.impl.artifacts.Component;
+import org.apache.tuscany.sca.impl.artifacts.Reference;
+
+public class PropertyAllocator {
+       Entity entity;
+
+       public PropertyAllocator(Entity e) {
+               entity = e;
+       }
+       
+       public void allocatePropertiesOfRefs(){
+               int height=0;
+               
+               
+               for(Iterator 
it=entity.getReferenceToServiceMap().keySet().iterator();it.hasNext();){
+                       String ref = it.next();
+                       
+               }
+       }
+
+       
+}

Propchange: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/PropertyAllocator.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/SVGDiagramGenerator.java
URL: 
http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/SVGDiagramGenerator.java?rev=1132863&r1=1132862&r2=1132863&view=diff
==============================================================================
--- 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/SVGDiagramGenerator.java
 (original)
+++ 
tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/SVGDiagramGenerator.java
 Tue Jun  7 05:17:25 2011
@@ -1,5 +1,5 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one
+un * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
  * regarding copyright ownership.  The ASF licenses this file
@@ -44,7 +44,7 @@ import org.apache.tuscany.sca.impl.artif
 public class SVGDiagramGenerator {
        
        private static final File outFile = new 
File(System.getProperty("user.dir")
-                       + "/output/test.svg");
+                       + "/output/reference.svg");
        
        /**
         * @param args
@@ -83,15 +83,15 @@ public class SVGDiagramGenerator {
                Wire edge1 = new Wire();
                Wire edge2 = new Wire();
                
-               Element rectangle1 = comp1.addElement(doc, svgNS, 50, 20, 130, 
200);    
-               Element text1 = Text.addTextElement(doc, svgNS, 150, 90, "SCA 
Component");
+               Element rectangle1 = comp1.addElement(doc, svgNS, 0, 0, 130, 
200);      
+               Element text1 = Text.addTextElement(doc, svgNS, 100, 70, "SCA 
Component");
                
                Element property1 = prop1.addElement(doc, svgNS, 120, 10, 20);
                Element property2 = prop2.addElement(doc, svgNS, 160, 10, 20);
                
-               Element polygon1 = ser1.addElement(doc, svgNS, 50, 85, 30);
+               Element polygon1 = ser1.addElement(doc, svgNS, 15, 15, 30);
                
-               Element polygon2 = ref1.addElement(doc, svgNS, 270, 60, 30);
+               Element polygon2 = ref1.addElement(doc, svgNS, 45, 15, 30);
                Element polygon3 = ref2.addElement(doc, svgNS, 270, 110, 30);
                
                //Element wire1 = edge1.addElement(doc, svgNS, 270, 60, 390, 
85);
@@ -112,37 +112,37 @@ public class SVGDiagramGenerator {
                //Element wire2 = Wire.addWireElement(doc, svgNS, 270, 110, 
390, 265);
 
                // Set the width and height attributes on the root 'svg' 
element.
-               svgRoot.setAttributeNS(null, "width", "650");
-               svgRoot.setAttributeNS(null, "height", "450");
+//             svgRoot.setAttributeNS(null, "width", "200");
+//             svgRoot.setAttributeNS(null, "height", "130");
                
                Element composi = composite.addElement(doc, svgNS, 0, 0, 350, 
650);
                Element text4 = Text.addTextElement(doc, svgNS, 75, 320, 
"Composite");
                
-               svgRoot.appendChild(composi);
-               svgRoot.appendChild(text4);
+//             svgRoot.appendChild(composi);
+//             svgRoot.appendChild(text4);
                
-               // Attach the rectangle to the root 'svg' element.
-               svgRoot.appendChild(rectangle1);
-               svgRoot.appendChild(text1);
-               svgRoot.appendChild(property1);
-               svgRoot.appendChild(property2);
-               svgRoot.appendChild(polygon1);
+//             // Attach the rectangle to the root 'svg' element.
+//             svgRoot.appendChild(rectangle1);
+//             svgRoot.appendChild(text1);
+//             svgRoot.appendChild(property1);
+//             svgRoot.appendChild(property2);
+//             svgRoot.appendChild(polygon1);
                svgRoot.appendChild(polygon2);
-               svgRoot.appendChild(polygon3);
-               
-               svgRoot.appendChild(rectangle2);
-               svgRoot.appendChild(text2);
-               svgRoot.appendChild(polygon4);
-               //svgRoot.appendChild(polygon3);
-               
-               svgRoot.appendChild(rectangle3);
-               svgRoot.appendChild(text3);
-               svgRoot.appendChild(polygon5);
-               
-               svgRoot.appendChild(wire1);
-               svgRoot.appendChild(wire2);
-               //svgRoot.setAttributeNS(null, "fill", "#CAE1FF");
-               
//System.out.println(doc.getDocumentElement().getAttribute("width"));
+//             svgRoot.appendChild(polygon3);
+//             
+//             svgRoot.appendChild(rectangle2);
+//             svgRoot.appendChild(text2);
+//             svgRoot.appendChild(polygon4);
+//             //svgRoot.appendChild(polygon3);
+//             
+//             svgRoot.appendChild(rectangle3);
+//             svgRoot.appendChild(text3);
+//             svgRoot.appendChild(polygon5);
+//             
+//             svgRoot.appendChild(wire1);
+//             svgRoot.appendChild(wire2);
+//             //svgRoot.setAttributeNS(null, "fill", "#CAE1FF");
+//             
//System.out.println(doc.getDocumentElement().getAttribute("width"));
                
                return doc;
        }


Reply via email to