tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r1164123 [1/4] - in /tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src: main/java/org/apache/tuscany/sca/impl/artifacts/ main/java/org/apache/tuscany/sca/impl/diagram/ main/java/org/apache/tuscany/sca/impl/html/...
Date Thu, 01 Sep 2011 15:57:26 GMT
Author: rfeng
Date: Thu Sep  1 15:57:25 2011
New Revision: 1164123

URL: http://svn.apache.org/viewvc?rev=1164123&view=rev
Log:
Format the code and organize imports

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/ComponentArtifact.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/CompositeArtifact.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Constant.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/DashedWire.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Layer.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Link.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/NormalWire.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/PropertyArtifact.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ReferenceArtifact.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ServiceArtifact.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Text.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/WireArtifact.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/html/HTMLWrapper.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLReader.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLWriter.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/ComponentEntity.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/CompositeEntity.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/Entity.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/LayoutBuilder.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/TuscanyCompositeEntityBuilder.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/Main.java
    tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/test/java/org/apache/tuscany/sca/layout/LayoutBuilderTest.java

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=1164123&r1=1164122&r2=1164123&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 Thu Sep  1 15:57:25 2011
@@ -24,87 +24,97 @@ import org.w3c.dom.Element;
 
 public abstract class Artifact {
 
-	private String name;
-	private String containerName;
-	private int height;
-	private int width;
-	private int xCoordinate;
-	private int yCoordinate;
-	private Document doc;
-	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;
-	}
-	public void setHeight(int height) {
-		this.height = height;
-	}
-	public int getWidth() {
-		return width;
-	}
-	public void setWidth(int width) {
-		this.width = width;
-	}
-	public int getxCoordinate() {
-		return xCoordinate;
-	}
-	public void setxCoordinate(int xCoordinate) {
-		this.xCoordinate = xCoordinate;
-	}
-	public int getyCoordinate() {
-		return yCoordinate;
-	}
-	public void setyCoordinate(int yCoordinate) {
-		this.yCoordinate = yCoordinate;
-	}
-	public Document getDoc() {
-		return doc;
-	}
-	public void setDoc(Document doc) {
-		this.doc = doc;
-	}
-	public String getSvgNs() {
-		return svgNs;
-	}
-	public void setSvgNs(String svgNs) {
-		this.svgNs = svgNs;
-	}
-
-	public static String getRoundCorner() {
-		return ROUND_CORNER;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setContainerName(String containerName) {
-		this.containerName = containerName;
-	}
-
-	public String getContainerName() {
-		return containerName;
-	}
-	
+    private String name;
+    private String containerName;
+    private int height;
+    private int width;
+    private int xCoordinate;
+    private int yCoordinate;
+    private Document doc;
+    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;
+    }
+
+    public void setHeight(int height) {
+        this.height = height;
+    }
+
+    public int getWidth() {
+        return width;
+    }
+
+    public void setWidth(int width) {
+        this.width = width;
+    }
+
+    public int getxCoordinate() {
+        return xCoordinate;
+    }
+
+    public void setxCoordinate(int xCoordinate) {
+        this.xCoordinate = xCoordinate;
+    }
+
+    public int getyCoordinate() {
+        return yCoordinate;
+    }
+
+    public void setyCoordinate(int yCoordinate) {
+        this.yCoordinate = yCoordinate;
+    }
+
+    public Document getDoc() {
+        return doc;
+    }
+
+    public void setDoc(Document doc) {
+        this.doc = doc;
+    }
+
+    public String getSvgNs() {
+        return svgNs;
+    }
+
+    public void setSvgNs(String svgNs) {
+        this.svgNs = svgNs;
+    }
+
+    public static String getRoundCorner() {
+        return ROUND_CORNER;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setContainerName(String containerName) {
+        this.containerName = containerName;
+    }
+
+    public String getContainerName() {
+        return containerName;
+    }
+
 }

Modified: tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ComponentArtifact.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ComponentArtifact.java?rev=1164123&r1=1164122&r2=1164123&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ComponentArtifact.java (original)
+++ tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ComponentArtifact.java Thu Sep  1 15:57:25 2011
@@ -22,40 +22,38 @@ package org.apache.tuscany.sca.impl.arti
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-public class ComponentArtifact extends Artifact{
-		
+public class ComponentArtifact extends Artifact {
+
+    /**
+     * Create an element with specified height and width
+     */
+    public Element addElement(Document document, String svgNs, int x, int y, int height, int width) {
+
+        this.setHeight(height);
+        this.setWidth(width);
+        this.setxCoordinate(x);
+        this.setyCoordinate(y);
+
+        Element rectangle = document.createElementNS(svgNs, "rect");
+        rectangle.setAttributeNS(null, "x", x + "");
+        rectangle.setAttributeNS(null, "y", y + "");
+        rectangle.setAttributeNS(null, "rx", getRoundCorner());
+        rectangle.setAttributeNS(null, "ry", getRoundCorner());
+        rectangle.setAttributeNS(null, "width", width + "");
+        rectangle.setAttributeNS(null, "height", height + "");
+        rectangle.setAttributeNS(null, "fill", "#3D59AB");
+        rectangle.setAttributeNS(null, "stroke", "#104E8B");
+        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, Constant.COMPONENT_DEFAULT_HEIGHT, Constant.COMPONENT_DEFAULT_WIDTH);
+
+    }
 
-	/**
-	 * Create an element with specified height and width
-	 */
-	public Element addElement(Document document, String svgNs, int x, int y,
-			int height, int width) {
-		
-		this.setHeight(height);
-		this.setWidth(width);
-		this.setxCoordinate(x);
-		this.setyCoordinate(y);
-		
-		Element rectangle = document.createElementNS(svgNs, "rect");
-		rectangle.setAttributeNS(null, "x", x+"");
-		rectangle.setAttributeNS(null, "y", y+"");
-		rectangle.setAttributeNS(null, "rx", getRoundCorner());
-		rectangle.setAttributeNS(null, "ry", getRoundCorner());
-		rectangle.setAttributeNS(null, "width", width+"");
-		rectangle.setAttributeNS(null, "height", height+"");
-		rectangle.setAttributeNS(null, "fill", "#3D59AB");
-		rectangle.setAttributeNS(null, "stroke", "#104E8B");
-		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, Constant.COMPONENT_DEFAULT_HEIGHT, Constant.COMPONENT_DEFAULT_WIDTH);
-		
-	}
-	
 }

Modified: tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/CompositeArtifact.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/CompositeArtifact.java?rev=1164123&r1=1164122&r2=1164123&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/CompositeArtifact.java (original)
+++ tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/CompositeArtifact.java Thu Sep  1 15:57:25 2011
@@ -26,34 +26,32 @@ import org.w3c.dom.Element;
  * Structure of a "Composite" element in SCA, as a SVG element
  *
  */
-public class CompositeArtifact extends Artifact{
+public class CompositeArtifact extends Artifact {
 
+    public Element addElement(Document document, String svgNs, int x, int y, int height, int width) {
+
+        this.setHeight(height);
+        this.setWidth(width);
+        this.setxCoordinate(x);
+        this.setyCoordinate(y);
+
+        Element rectangle = document.createElementNS(svgNs, "rect");
+        rectangle.setAttributeNS(null, "x", x + "");
+        rectangle.setAttributeNS(null, "y", y + "");
+        rectangle.setAttributeNS(null, "rx", getRoundCorner());
+        rectangle.setAttributeNS(null, "ry", getRoundCorner());
+        rectangle.setAttributeNS(null, "width", width + "");
+        rectangle.setAttributeNS(null, "height", height + "");
+        rectangle.setAttributeNS(null, "fill", "#E5E5E5");
+        rectangle.setAttributeNS(null, "stroke", "#919191");
+        rectangle.setAttributeNS(null, "alignment-baseline", "middle");
+
+        return rectangle;
+    }
+
+    //	//OBSOLETE
+    //	public Element addElement(Document document, String svgNs, int x, int y) {
+    //		return null;
+    //	}
 
-	public Element addElement(Document document, String svgNs, int x, int y,
-			int height, int width) {
-		
-		this.setHeight(height);
-		this.setWidth(width);
-		this.setxCoordinate(x);
-		this.setyCoordinate(y);
-		
-		Element rectangle = document.createElementNS(svgNs, "rect");
-		rectangle.setAttributeNS(null, "x", x+"");
-		rectangle.setAttributeNS(null, "y", y+"");
-		rectangle.setAttributeNS(null, "rx", getRoundCorner());
-		rectangle.setAttributeNS(null, "ry", getRoundCorner());
-		rectangle.setAttributeNS(null, "width", width+"");
-		rectangle.setAttributeNS(null, "height", height+"");
-		rectangle.setAttributeNS(null, "fill", "#E5E5E5");
-		rectangle.setAttributeNS(null, "stroke", "#919191");
-		rectangle.setAttributeNS(null, "alignment-baseline", "middle");
-		
-		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/Constant.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Constant.java?rev=1164123&r1=1164122&r2=1164123&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Constant.java (original)
+++ tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Constant.java Thu Sep  1 15:57:25 2011
@@ -1,26 +1,26 @@
 package org.apache.tuscany.sca.impl.artifacts;
 
 public final class Constant {
-	
-	public static final int COMPONENT_DEFAULT_WIDTH = 200 ;
-	public static final int COMPONENT_DEFAULT_HEIGHT = 130 ;
-	public static final int COMPONENT_TEXT_SPACING = 20 ;
-	
-	public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPONENT_OF_PROPERTY = 20 ;	
-	public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPOSITE_OF_PROPERTY = 60 ;
-	public static final int SPACING_FOR_COMPONENT_OF_PROPERTY = 20 ;
-	public static final int SPACING_FOR_COMPOSITE_OF_PROPERTY = 60 ;
-	
-	public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPONENT_OF_REFERENCE = 30 ;	
-	public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPOSITE_OF_REFERENCE = 90 ;
-	public static final int SPACING_FOR_COMPONENT_OF_REFERENCE = 10 ;
-	public static final int SPACING_FOR_COMPOSITE_OF_REFERENCE = 50 ;
-	
-	public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPONENT_OF_SERVICE = 30 ;	
-	public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPOSITE_OF_SERVICE = 90 ;
-	public static final int SPACING_FOR_COMPONENT_OF_SERVICE = 10 ;
-	public static final int SPACING_FOR_COMPOSITE_OF_SERVICE = 50 ;
-	
-	public static final int SPACING_FOR_TEXT = 1 ;
+
+    public static final int COMPONENT_DEFAULT_WIDTH = 200;
+    public static final int COMPONENT_DEFAULT_HEIGHT = 130;
+    public static final int COMPONENT_TEXT_SPACING = 20;
+
+    public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPONENT_OF_PROPERTY = 20;
+    public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPOSITE_OF_PROPERTY = 60;
+    public static final int SPACING_FOR_COMPONENT_OF_PROPERTY = 20;
+    public static final int SPACING_FOR_COMPOSITE_OF_PROPERTY = 60;
+
+    public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPONENT_OF_REFERENCE = 30;
+    public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPOSITE_OF_REFERENCE = 90;
+    public static final int SPACING_FOR_COMPONENT_OF_REFERENCE = 10;
+    public static final int SPACING_FOR_COMPOSITE_OF_REFERENCE = 50;
+
+    public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPONENT_OF_SERVICE = 30;
+    public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPOSITE_OF_SERVICE = 90;
+    public static final int SPACING_FOR_COMPONENT_OF_SERVICE = 10;
+    public static final int SPACING_FOR_COMPOSITE_OF_SERVICE = 50;
+
+    public static final int SPACING_FOR_TEXT = 1;
 
 }

Modified: tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/DashedWire.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/DashedWire.java?rev=1164123&r1=1164122&r2=1164123&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/DashedWire.java (original)
+++ tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/DashedWire.java Thu Sep  1 15:57:25 2011
@@ -22,63 +22,60 @@ package org.apache.tuscany.sca.impl.arti
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-public class DashedWire extends WireArtifact{
-	
-	@Override
-	public Element addElement(Document document, String svgNs, Object a,
-			Object b, int changingFactor, String color) {
-		
-		Element polyline = document.createElementNS(svgNs, "polyline");
-		int x1=0,x2=0,y1=0,y2=0;
-		
-		if(a instanceof ServiceArtifact && b instanceof ServiceArtifact){
-			
-			ServiceArtifact aService1 = (ServiceArtifact)a;
-			ServiceArtifact aService2 = (ServiceArtifact)b;
-			
-			x1=aService1.getxCoordinate()+aService1.getHeight()*3/2;
-			y1=aService1.getyCoordinate()+aService1.getHeight()/2;
-			
-			x2=aService2.getxCoordinate()+aService2.getHeight()/2;
-			y2=aService2.getyCoordinate()+aService2.getHeight()/2;
-			
-		}
-		
-		else if(a instanceof ReferenceArtifact && b instanceof ReferenceArtifact){
-			
-			ReferenceArtifact aReference1 = (ReferenceArtifact)a;
-			ReferenceArtifact aReference2 = (ReferenceArtifact)b;
-			
-			x1=aReference1.getxCoordinate()+aReference1.getHeight()*3/2;
-			y1=aReference1.getyCoordinate()+aReference1.getHeight()/2;
-			
-			x2=aReference2.getxCoordinate()+aReference2.getHeight()/2;
-			y2=aReference2.getyCoordinate()+aReference2.getHeight()/2;
-			
-		}
-
-		polyline = setWireAttributes(x1, y1, x2, y2, polyline, changingFactor, color);
-
-		polyline.setAttributeNS(null, "stroke-dasharray", "3 3");
-		
-		return polyline;
-	}
-	
-	
-	/**
-	 * <script type="text/ecmascript"><![CDATA[
-		<SCRIPT LANGUAGE="JavaScript">
-
-var test = document.open("store_diagram.svg");
+public class DashedWire extends WireArtifact {
 
-</SCRIPT>
-	]]></script>
+    @Override
+    public Element addElement(Document document, String svgNs, Object a, Object b, int changingFactor, String color) {
 
-<!--rect x="0" y="0" alignment-baseline="central" fill="#E5E5D0" width="1400" rx="20" ry="20" height="560" stroke="#919191"/><rect x="200" y="100" alignment-baseline="central" fill="#E5E5E5" width="1000" rx="20" ry="20" height="360" stroke="#919191"/><text x="700" font-size="20" dominant-baseline="mathematical" y="120" text-anchor="middle">
+        Element polyline = document.createElementNS(svgNs, "polyline");
+        int x1 = 0, x2 = 0, y1 = 0, y2 = 0;
 
-<a xlink:href="store_diagram.svg" xlink:show="new">MyValueComposite2</a></text--> 
+        if (a instanceof ServiceArtifact && b instanceof ServiceArtifact) {
 
-	 */
+            ServiceArtifact aService1 = (ServiceArtifact)a;
+            ServiceArtifact aService2 = (ServiceArtifact)b;
 
+            x1 = aService1.getxCoordinate() + aService1.getHeight() * 3 / 2;
+            y1 = aService1.getyCoordinate() + aService1.getHeight() / 2;
+
+            x2 = aService2.getxCoordinate() + aService2.getHeight() / 2;
+            y2 = aService2.getyCoordinate() + aService2.getHeight() / 2;
+
+        }
+
+        else if (a instanceof ReferenceArtifact && b instanceof ReferenceArtifact) {
+
+            ReferenceArtifact aReference1 = (ReferenceArtifact)a;
+            ReferenceArtifact aReference2 = (ReferenceArtifact)b;
+
+            x1 = aReference1.getxCoordinate() + aReference1.getHeight() * 3 / 2;
+            y1 = aReference1.getyCoordinate() + aReference1.getHeight() / 2;
+
+            x2 = aReference2.getxCoordinate() + aReference2.getHeight() / 2;
+            y2 = aReference2.getyCoordinate() + aReference2.getHeight() / 2;
+
+        }
+
+        polyline = setWireAttributes(x1, y1, x2, y2, polyline, changingFactor, color);
+
+        polyline.setAttributeNS(null, "stroke-dasharray", "3 3");
+
+        return polyline;
+    }
+
+    /**
+     * <script type="text/ecmascript"><![CDATA[
+    	<SCRIPT LANGUAGE="JavaScript">
+
+    var test = document.open("store_diagram.svg");
+
+    </SCRIPT>
+    ]]></script>
+
+    <!--rect x="0" y="0" alignment-baseline="central" fill="#E5E5D0" width="1400" rx="20" ry="20" height="560" stroke="#919191"/><rect x="200" y="100" alignment-baseline="central" fill="#E5E5E5" width="1000" rx="20" ry="20" height="360" stroke="#919191"/><text x="700" font-size="20" dominant-baseline="mathematical" y="120" text-anchor="middle">
+
+    <a xlink:href="store_diagram.svg" xlink:show="new">MyValueComposite2</a></text--> 
+
+     */
 
 }

Modified: tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Layer.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Layer.java?rev=1164123&r1=1164122&r2=1164123&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Layer.java (original)
+++ tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Layer.java Thu Sep  1 15:57:25 2011
@@ -26,38 +26,35 @@ import org.w3c.dom.Element;
  * Structure of a "Outermost layer" : not a SCA artifact
  *
  */
-public class Layer extends Artifact{
+public class Layer extends Artifact {
 
+    public Element addElement(Document document, String svgNs, int x, int y, int height, int width) {
 
-	public Element addElement(Document document, String svgNs, int x, int y,
-			int height, int width) {
-		
-		this.setHeight(height);
-		this.setWidth(width);
-		this.setxCoordinate(x);
-		this.setyCoordinate(y);
-		
-		Element rectangle = document.createElementNS(svgNs, "rect");
-		rectangle.setAttributeNS(null, "x", x+"");
-		rectangle.setAttributeNS(null, "y", y+"");
-		rectangle.setAttributeNS(null, "rx", getRoundCorner());
-		rectangle.setAttributeNS(null, "ry", getRoundCorner());
-		rectangle.setAttributeNS(null, "width", width+"");
-		rectangle.setAttributeNS(null, "height", height+"");
-		rectangle.setAttributeNS(null, "fill", "#E5E5D0");
-		rectangle.setAttributeNS(null, "stroke", "#919191");
-		rectangle.setAttributeNS(null, "alignment-baseline", "middle");
-		
-		return rectangle;
-	}
-	
-	public Element addElement(Document document, String svgNs, int x, int y,
-			int height, int width, String fillColor) {
-		
-		Element rect = addElement(document, svgNs, x, y, height, width);
-		rect.setAttributeNS(null, "fill", fillColor);
-		
-		return rect;
-	}
+        this.setHeight(height);
+        this.setWidth(width);
+        this.setxCoordinate(x);
+        this.setyCoordinate(y);
+
+        Element rectangle = document.createElementNS(svgNs, "rect");
+        rectangle.setAttributeNS(null, "x", x + "");
+        rectangle.setAttributeNS(null, "y", y + "");
+        rectangle.setAttributeNS(null, "rx", getRoundCorner());
+        rectangle.setAttributeNS(null, "ry", getRoundCorner());
+        rectangle.setAttributeNS(null, "width", width + "");
+        rectangle.setAttributeNS(null, "height", height + "");
+        rectangle.setAttributeNS(null, "fill", "#E5E5D0");
+        rectangle.setAttributeNS(null, "stroke", "#919191");
+        rectangle.setAttributeNS(null, "alignment-baseline", "middle");
+
+        return rectangle;
+    }
+
+    public Element addElement(Document document, String svgNs, int x, int y, int height, int width, String fillColor) {
+
+        Element rect = addElement(document, svgNs, x, y, height, width);
+        rect.setAttributeNS(null, "fill", fillColor);
+
+        return rect;
+    }
 
 }

Modified: tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Link.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Link.java?rev=1164123&r1=1164122&r2=1164123&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Link.java (original)
+++ tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Link.java Thu Sep  1 15:57:25 2011
@@ -28,14 +28,14 @@ import org.w3c.dom.Element;
  */
 public class Link {
 
-	public Element addElement(Document document, String svgNs, String fileName, String compName) {
-		
-		Element link = document.createElementNS(svgNs, "a");
-		link.setAttributeNS(null, "xlink:href", fileName);
-		link.setAttributeNS(null, "xlink:show", "new");
-		link.setTextContent(" "+compName + " ,");
-				
-		return link;
-	}
-	
+    public Element addElement(Document document, String svgNs, String fileName, String compName) {
+
+        Element link = document.createElementNS(svgNs, "a");
+        link.setAttributeNS(null, "xlink:href", fileName);
+        link.setAttributeNS(null, "xlink:show", "new");
+        link.setTextContent(" " + compName + " ,");
+
+        return link;
+    }
+
 }

Modified: tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/NormalWire.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/NormalWire.java?rev=1164123&r1=1164122&r2=1164123&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/NormalWire.java (original)
+++ tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/NormalWire.java Thu Sep  1 15:57:25 2011
@@ -22,26 +22,24 @@ package org.apache.tuscany.sca.impl.arti
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-public class NormalWire extends WireArtifact{
-	
-	@Override
-	public Element addElement(Document document, String svgNs, Object a,
-			Object b, int changingFactor, String color) {
-		
-		ReferenceArtifact aReference = (ReferenceArtifact)a;
-		ServiceArtifact aService = (ServiceArtifact)b;
-		
-		Element polyline = document.createElementNS(svgNs, "polyline");
-		int x1=aReference.getxCoordinate()+aReference.getHeight()*3/2;
-		int y1=aReference.getyCoordinate()+aReference.getHeight()/2;
-		
-		int x2=aService.getxCoordinate()+aService.getHeight()/2;
-		int y2=aService.getyCoordinate()+aService.getHeight()/2;
-		
-		polyline = setWireAttributes(x1, y1, x2, y2, polyline, changingFactor, color);
-		
-		return polyline;
-	}
+public class NormalWire extends WireArtifact {
 
+    @Override
+    public Element addElement(Document document, String svgNs, Object a, Object b, int changingFactor, String color) {
+
+        ReferenceArtifact aReference = (ReferenceArtifact)a;
+        ServiceArtifact aService = (ServiceArtifact)b;
+
+        Element polyline = document.createElementNS(svgNs, "polyline");
+        int x1 = aReference.getxCoordinate() + aReference.getHeight() * 3 / 2;
+        int y1 = aReference.getyCoordinate() + aReference.getHeight() / 2;
+
+        int x2 = aService.getxCoordinate() + aService.getHeight() / 2;
+        int y2 = aService.getyCoordinate() + aService.getHeight() / 2;
+
+        polyline = setWireAttributes(x1, y1, x2, y2, polyline, changingFactor, color);
+
+        return polyline;
+    }
 
 }

Modified: tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/PropertyArtifact.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/PropertyArtifact.java?rev=1164123&r1=1164122&r2=1164123&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/PropertyArtifact.java (original)
+++ tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/PropertyArtifact.java Thu Sep  1 15:57:25 2011
@@ -22,41 +22,37 @@ package org.apache.tuscany.sca.impl.arti
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-public class PropertyArtifact extends Artifact{
-	
-	/**
-	 * Property is a square.
-	 * 			 ___
-	 * 			|	|
-	 * 			|___|
-	 * 
-	 */
-	public Element addElement(Document document, String svgNs, int x, int y,
-			int height, int width) {
-		
-		this.setHeight(height);
-		this.setWidth(width);
-		this.setxCoordinate(x);
-		this.setyCoordinate(y);
-		
-		Element rectangle = document.createElementNS(svgNs, "rect");
-		rectangle.setAttributeNS(null, "x", x+"");
-		rectangle.setAttributeNS(null, "y", y+"");
-		rectangle.setAttributeNS(null, "width", height+"");
-		rectangle.setAttributeNS(null, "height", height+"");
-		rectangle.setAttributeNS(null, "fill", "#EEEE00");
-		rectangle.setAttributeNS(null, "stroke", "#EEC900");
-		//rectangle.setAttributeNS(null, "fill-opacity", "0.75");
-		
-		return rectangle;
-	}
-	
-	
-	public Element addElement(Document document, String svgNs, int x, int y,
-			int height) {
-		
-		return addElement(document, svgNs, x, y, height, height);
-	}
+public class PropertyArtifact extends Artifact {
 
+    /**
+     * Property is a square.
+     * 			 ___
+     * 			|	|
+     * 			|___|
+     * 
+     */
+    public Element addElement(Document document, String svgNs, int x, int y, int height, int width) {
+
+        this.setHeight(height);
+        this.setWidth(width);
+        this.setxCoordinate(x);
+        this.setyCoordinate(y);
+
+        Element rectangle = document.createElementNS(svgNs, "rect");
+        rectangle.setAttributeNS(null, "x", x + "");
+        rectangle.setAttributeNS(null, "y", y + "");
+        rectangle.setAttributeNS(null, "width", height + "");
+        rectangle.setAttributeNS(null, "height", height + "");
+        rectangle.setAttributeNS(null, "fill", "#EEEE00");
+        rectangle.setAttributeNS(null, "stroke", "#EEC900");
+        //rectangle.setAttributeNS(null, "fill-opacity", "0.75");
+
+        return rectangle;
+    }
+
+    public Element addElement(Document document, String svgNs, int x, int y, int height) {
+
+        return addElement(document, svgNs, x, y, height, height);
+    }
 
 }

Modified: tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ReferenceArtifact.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ReferenceArtifact.java?rev=1164123&r1=1164122&r2=1164123&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ReferenceArtifact.java (original)
+++ tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ReferenceArtifact.java Thu Sep  1 15:57:25 2011
@@ -23,48 +23,64 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 public class ReferenceArtifact extends Artifact {
-	
 
-	/**
-	 * 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 width) {
-		
-
-		this.setHeight(height);
-		this.setWidth(width);
-		this.setxCoordinate(x);
-		this.setyCoordinate(y);
-		
-		int halfOfHeight = height/2;
-		
-		Element polygon = document.createElementNS(svgNs, "polygon");
-		polygon.setAttributeNS(null, "points", 
-				""+ x +","+y+" " +
-				""+ (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");
-		polygon.setAttributeNS(null, "stroke", "#68228B");
-		
-		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);
-	}
+    /**
+     * 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 width) {
+
+        this.setHeight(height);
+        this.setWidth(width);
+        this.setxCoordinate(x);
+        this.setyCoordinate(y);
+
+        int halfOfHeight = height / 2;
+
+        Element polygon = document.createElementNS(svgNs, "polygon");
+        polygon.setAttributeNS(null, "points", "" + x
+            + ","
+            + y
+            + " "
+            + ""
+            + (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");
+        polygon.setAttributeNS(null, "stroke", "#68228B");
+
+        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);
+    }
 
 }

Modified: tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ServiceArtifact.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ServiceArtifact.java?rev=1164123&r1=1164122&r2=1164123&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ServiceArtifact.java (original)
+++ tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ServiceArtifact.java Thu Sep  1 15:57:25 2011
@@ -22,58 +22,74 @@ package org.apache.tuscany.sca.impl.arti
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-public class ServiceArtifact extends Artifact{
+public class ServiceArtifact extends Artifact {
 
-	
+    /**
+     * In a Service 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 width) {
 
-	/**
-	 * In a Service 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 width) {
-		
-		this.setHeight(height);
-		this.setWidth(width);
-		this.setxCoordinate(x);
-		this.setyCoordinate(y);
-		
-		int halfOfHeight = height/2;
-		
-		Element polygon = document.createElementNS(svgNs, "polygon");
-		polygon.setAttributeNS(null, "points", 
-				""+ x +","+y+" " +
-				""+ (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");
-		polygon.setAttributeNS(null, "stroke", "#008B45");
-		
-		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);
-	}
+        this.setHeight(height);
+        this.setWidth(width);
+        this.setxCoordinate(x);
+        this.setyCoordinate(y);
+
+        int halfOfHeight = height / 2;
+
+        Element polygon = document.createElementNS(svgNs, "polygon");
+        polygon.setAttributeNS(null, "points", "" + x
+            + ","
+            + y
+            + " "
+            + ""
+            + (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");
+        polygon.setAttributeNS(null, "stroke", "#008B45");
+
+        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);
+    }
 
-		
 }

Modified: tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Text.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Text.java?rev=1164123&r1=1164122&r2=1164123&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Text.java (original)
+++ tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Text.java Thu Sep  1 15:57:25 2011
@@ -24,16 +24,15 @@ import org.w3c.dom.Element;
 
 public class Text {
 
-	public static Element addTextElement(Document document, 
-			String svgNs, int x, int y, String content) {
-		Element text = document.createElementNS(svgNs, "text");
-		text.setAttributeNS(null, "x", x+"");
-		text.setAttributeNS(null, "y", y+"");
-		//text.setAttributeNS(null, "text-anchor", "middle");
-		text.setAttributeNS(null, "dominant-baseline", "mathematical");
-		text.setAttributeNS(null, "font-size", "15");
-		text.setTextContent(content);
-		
-		return text;
-	}
+    public static Element addTextElement(Document document, String svgNs, int x, int y, String content) {
+        Element text = document.createElementNS(svgNs, "text");
+        text.setAttributeNS(null, "x", x + "");
+        text.setAttributeNS(null, "y", y + "");
+        //text.setAttributeNS(null, "text-anchor", "middle");
+        text.setAttributeNS(null, "dominant-baseline", "mathematical");
+        text.setAttributeNS(null, "font-size", "15");
+        text.setTextContent(content);
+
+        return text;
+    }
 }

Modified: tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/WireArtifact.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/WireArtifact.java?rev=1164123&r1=1164122&r2=1164123&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/WireArtifact.java (original)
+++ tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/WireArtifact.java Thu Sep  1 15:57:25 2011
@@ -23,42 +23,64 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 public abstract class WireArtifact {
-		
-	public abstract Element addElement(Document document, String svgNs, 
-			Object a, Object b, int changingFactor, String color); 
-	
-	public Element setWireAttributes(int x1, int y1, int x2, int y2, 
-			Element polyline, int changingFactor, String color){
-				
-		if(y1 == y2 && x2>x1){
-			polyline.setAttributeNS(null, "points", x1+","+
-					y1+" "+x2+","+y2
-			);
-		}
-		else if(y1 == y2 && x1>x2){
-			polyline.setAttributeNS(null, "points", x1+","+
-					y1+" "+(x1+changingFactor)+","+y1
-					+" "+(x1+changingFactor)+","+(y1-(changingFactor*2))
-					+" "+(x2-changingFactor)+","+(y1-(changingFactor*2))
-					+" "+(x2-changingFactor)+","+(y1)
-					+" "+(x2)+","+(y1)
-			);
-			
-		}
-		else{
-			polyline.setAttributeNS(null, "points", x1+","+
-					y1+" "+(x1+changingFactor)+","+y1
-					+" "+(x1+changingFactor)+","+y2
-					+" "+x2+","+y2
-			);
-		}
-		
-		polyline.setAttributeNS(null, "stroke", color);
-		polyline.setAttributeNS(null, "stroke-width", "2");
-		polyline.setAttributeNS(null, "fill", "none");
-		
-		return polyline;
-	}
 
+    public abstract Element addElement(Document document,
+                                       String svgNs,
+                                       Object a,
+                                       Object b,
+                                       int changingFactor,
+                                       String color);
+
+    public Element setWireAttributes(int x1, int y1, int x2, int y2, Element polyline, int changingFactor, String color) {
+
+        if (y1 == y2 && x2 > x1) {
+            polyline.setAttributeNS(null, "points", x1 + "," + y1 + " " + x2 + "," + y2);
+        } else if (y1 == y2 && x1 > x2) {
+            polyline.setAttributeNS(null, "points", x1 + ","
+                + y1
+                + " "
+                + (x1 + changingFactor)
+                + ","
+                + y1
+                + " "
+                + (x1 + changingFactor)
+                + ","
+                + (y1 - (changingFactor * 2))
+                + " "
+                + (x2 - changingFactor)
+                + ","
+                + (y1 - (changingFactor * 2))
+                + " "
+                + (x2 - changingFactor)
+                + ","
+                + (y1)
+                + " "
+                + (x2)
+                + ","
+                + (y1));
+
+        } else {
+            polyline.setAttributeNS(null, "points", x1 + ","
+                + y1
+                + " "
+                + (x1 + changingFactor)
+                + ","
+                + y1
+                + " "
+                + (x1 + changingFactor)
+                + ","
+                + y2
+                + " "
+                + x2
+                + ","
+                + y2);
+        }
+
+        polyline.setAttributeNS(null, "stroke", color);
+        polyline.setAttributeNS(null, "stroke-width", "2");
+        polyline.setAttributeNS(null, "fill", "none");
+
+        return polyline;
+    }
 
 }

Modified: tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java?rev=1164123&r1=1164122&r2=1164123&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java (original)
+++ tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java Thu Sep  1 15:57:25 2011
@@ -45,556 +45,558 @@ import org.w3c.dom.Element;
 
 public class DiagramGenerator {
 
-	private CompositeEntity comp;
-	private Document doc;
-	private String svgNS ;
-	private Element svgRoot;
-	private ArrayList<ReferenceArtifact> refs= new ArrayList<ReferenceArtifact>();
-	private ArrayList<ServiceArtifact> sers= new ArrayList<ServiceArtifact>();
-	private int diagramHeight, diagramWidth;
-	
-	private boolean isHtml;
-	
-	private int lastUsedChangingFactor = 0;
-	enum changingFactor{a(20), b(25), c(30), d(35), e(40), f(15);
-	
-	private final int val;
-	
-	private changingFactor(int x){
-		val = x;
-	}
-	
-	public int getVal(){
-		return val;
-	}
-	
-	};
-	
-	enum color {black}//, violet, red, green};
-	private int previousWireColor = 0;
-
-	/**
-	 * Constructor to generate a SVG diagram for a given CompositeEntity
-	 * Object.
-	 */
-	public DiagramGenerator(CompositeEntity comp, boolean isHtml) {
-
-		this.comp = comp;
-		this.isHtml = isHtml;
-		
-	}
-
-	/**
-	 * Draws the diagram.
-	 */
-	public Document buildSVGDocument(){
-
-		DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
-		svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
-		doc = impl.createDocument(svgNS, "svg", null);
-
-		// Get the root element (the 'svg' element).
-		svgRoot = doc.getDocumentElement();
-				
-		setDiagramHeight(comp.getHeight()+200);
-		setDiagramWidth(comp.getWidth()+400);
-		
-		svgRoot.setAttributeNS(null, "viewBox", "0 0 "+getDiagramWidth()+" "+getDiagramHeight());
-
-		addLayer();
-		addComposite();
-
-		for(ComponentEntity ent: comp.getComponentList()){
-
-			addComponent(ent);
-			addComponentProperties(ent);
-			addComponentService(ent);
-			addComponentReference(ent);
-		}
-
-		addCompositeProperties();
-		addCompositeService();
-		addCompositeReference();
-
-		addComponentConnections();
-		addReferencePromotion();
-		addServicePromotion();
-		
-		addInclusions();
-
-		return doc;
-	}
-
-	private void addLayer() {
-		
-		Layer outerLayer = new Layer();
-		Element layerElt = outerLayer.addElement(doc, svgNS, 0, 0, getDiagramHeight(), getDiagramWidth() );
-		svgRoot.appendChild(layerElt);
-	}
-
-	private void addReferencePromotion() {
-
-		for(Iterator it= comp.getPromoteAReference().entrySet().iterator();
-		it.hasNext();){
-			Entry entry = (Entry) it.next(); 
-			String compositeRef = (String)entry.getKey(); 
-			ArrayList<String> componentRef = (ArrayList<String>)entry.getValue();
-
-			ReferenceArtifact r1 = getRef(compositeRef);
-			
-			for(String ref: componentRef){
-				
-				ReferenceArtifact r2 = getRef(ref);
-
-				if(r1 != null && r2 != null){
-					addWire(r2, r1);
-				}
-			}
-			
-		}
-	}
-
-	private void addServicePromotion() {
-
-		for(Iterator it= comp.getPromoteAService().entrySet().iterator();
-		it.hasNext();){
-			Entry entry = (Entry) it.next(); 
-			String compositeSer = (String)entry.getKey(); 
-			String componentSer = (String)entry.getValue();
-
-			ServiceArtifact s1 = getSer(compositeSer);
-			ServiceArtifact s2 = getSer(componentSer);
-
-			if(s1 != null && s2 != null){
-				addWire(s1, s2);
-			}
-		}
-	}
-	
-	private void addInclusions() {
-
-		if(!comp.getIncludedComposites().isEmpty()){
-			
-			Layer inclusionLayer = new Layer();
-			int constant = 5;
-			int x0 = comp.getX()+constant;
-			int y0 = comp.getY()+comp.getHeight()-(Constant.COMPONENT_DEFAULT_HEIGHT/2+constant);
-			int height = Constant.COMPONENT_DEFAULT_HEIGHT/2;
-			int width = comp.getWidth()-constant*2;
-
-			Element layerElt = inclusionLayer.addElement(doc, svgNS, x0, y0, height, 
-					width , "#E5E5C0");
-
-			Element text = Text.addTextElement(doc, svgNS, x0+constant, y0+constant*2, "Included Composites");
-
-			svgRoot.appendChild(layerElt);
-			svgRoot.appendChild(text);
-
-			text = Text.addTextElement(doc, svgNS, x0+constant, y0+constant*7, "");
-			
-			String ext;
-			
-			if(isHtml){
-				ext = ".html";
-			}
-			else{
-				ext = ".svg";
-			}
-
-			for(String includedComposite : comp.getIncludedComposites()){
-
-				Link link = new Link();
-				Element aLink = link.addElement(doc, svgNS, includedComposite+comp.getFileNameSuffix()+ext, includedComposite);
-				text.appendChild(aLink);
-
-			}
-			svgRoot.appendChild(text);
-		}
-	}
-
-	/**
-	 * Connects references to services.
-	 */
-	private void addComponentConnections() {
-
-		for(Entity ent: comp.getComponentList()){
-			//if(ent instanceof ComponentEntity){
-
-				for(Iterator it= ((ComponentEntity)ent).getReferenceToServiceMap().entrySet().iterator();
-				it.hasNext();){
-					Entry entry = (Entry) it.next(); 
-					String ref = (String)entry.getKey(); 
-					String ser = (String)entry.getValue();
-
-					ReferenceArtifact r = getRef(ref);
-					ServiceArtifact s = getSer(ser);
-
-					if(r != null && s != null){
-						addWire(r,s);
-					}
-				}
-			//}
-		}
-	}
-
-	/**
-	 * This is to remove overlapping of wire elements
-	 */
-	private String getColor() {
-
-		previousWireColor =previousWireColor % color.values().length;
-		return color.values()[previousWireColor++].toString();
-	}
-
-	
-	/**
-	 * This is to remove overlapping of wire elements
-	 */
-	private int getChangingFactor() {
-		
-		lastUsedChangingFactor = lastUsedChangingFactor % changingFactor.values().length;
-		return changingFactor.values()[lastUsedChangingFactor++].getVal();
-
-	}
-
-	private void addWire(ReferenceArtifact r, ServiceArtifact s) {
-		
-		WireArtifact edge = new NormalWire();
-		Element wire = edge.addElement(doc, svgNS, r, s, getChangingFactor(), getColor());
-		svgRoot.appendChild(wire);
-	}
-
-	private void addWire(ServiceArtifact s1, ServiceArtifact s2) {
-
-		DashedWire edge = new DashedWire();
-		Element wire = edge.addElement(doc, svgNS, s1, s2, getChangingFactor(), getColor());
-		svgRoot.appendChild(wire);
-	}
-
-	private void addWire(ReferenceArtifact r1, ReferenceArtifact r2) {
-
-		DashedWire edge = new DashedWire();
-		Element wire = edge.addElement(doc, svgNS, r1, r2, getChangingFactor(), getColor());
-		svgRoot.appendChild(wire);
-	}
-
-	private ServiceArtifact getSer(String ser) {
-
-		for(ServiceArtifact s: sers){
-			if(s.getContainerName().equals(ser) || s.getName().equals(ser)){
-				return s;
-			}
-		}
-		return null;
-	}
-
-	private ReferenceArtifact getRef(String ref) {
-
-		for(ReferenceArtifact r: refs){
-
-			if(r.getContainerName().equals(ref) || r.getName().equals(ref)){
-				return r;
-			}
-		}
-		return null;
-	}
-
-	private void addComponentProperties(ComponentEntity ent) {
-		int propLen = ent.getPropLength();
-		int x= ent.getX() + Constant.SPACING_FOR_COMPONENT_OF_PROPERTY;
-		int y= ent.getY()-propLen/2;
-
-		for(String prop: ent.getProperties()){
-			PropertyArtifact pro = new PropertyArtifact();
-			Element property = pro.addElement(doc, svgNS, x, y, propLen);
-			Element text = Text.addTextElement(doc, svgNS, x, y-Constant.SPACING_FOR_TEXT, prop);
-
-			svgRoot.appendChild(property);
-			svgRoot.appendChild(text);
-
-			x += (propLen + Constant.SPACING_FOR_COMPONENT_OF_PROPERTY);
-
-			pro.setName(prop);
-			pro.setContainerName(ent.getName());
-		}
-	}
-
-	private void addComponentReference(ComponentEntity ent) {
-		
-		int refHeight = ent.getRefHeight();
-		int x=(ent.getX()+ent.getWidth())-(refHeight*2/3);
-		int y=ent.getY() + Constant.SPACING_FOR_COMPONENT_OF_REFERENCE;
-
-		for(String ref: setRefOrder(ent)){
-			ReferenceArtifact refer= new ReferenceArtifact();
-			Element polygon = refer.addElement(doc, svgNS, x, y, refHeight);
-			Element text = Text.addTextElement(doc, svgNS, x, y-Constant.SPACING_FOR_TEXT, ref);
-			svgRoot.appendChild(polygon);
-			svgRoot.appendChild(text);
-
-			y += (refHeight + Constant.SPACING_FOR_COMPONENT_OF_REFERENCE);
-
-			refer.setName(ref);
-			refer.setContainerName(ent.getName());
-			refs.add(refer);
-
-		}
-	}
-
-	/**
-	 * This method is used to organize the Component References,
-	 * in a manner where they are stay approximately in-line with the
-	 * connecting Service. This would enhance the clearness of the diagram.
-	 */
-	private String[] setRefOrder(ComponentEntity e){
-
-		ArrayList<String> refs = e.getReferences();
-		ArrayList<String> sers = new ArrayList<String>();
-		String[] orderedRefs = new String[refs.size()];
-		
-		//sers = new ArrayList<String>(e.getReferenceToServiceMap().values());
-
-		sers = buildReferenceToMappingServiceList(refs, e);
-		
-		for(String eName: e.getAdjacentEntities()){
-			for(Entity ent: comp.getComponentList()){
-
-				if(ent.getName().equals(eName)){
-					for(String s : sers){
-						for(String s1: ent.getServices()){
-							//System.err.println("XXXXX "+ s1 +" ::: "+s);
-							if(s1.equals(s) || s.equals(ent.getName())){
-								//System.err.println("|||||||| "+ sers.size()+ " ||| " + refs.size()+"|| "+orderedRefs.length);
-								if(orderedRefs[ent.getLevel()] == null){
-									//System.err.println("XXXXX "+ sers.get(1)+ " ::::::: "+refs.get(1));
-									//									System.err.println("XXXXX "+ sers.get(2)+ " ::::::: "+refs.get(2));
-									//									System.err.println("XXXXX "+ sers.get(3)+ " ::::::: "+refs.get(3));
-									//System.err.println("XXXXX "+ refs.get(sers.indexOf(s))+" ::: "+ent.getLevel()+" ::: "+ent.getName());
-									orderedRefs[ent.getLevel()] = refs.get(sers.indexOf(s));
-									break;
-								}
-								else{
-									for(int i=ent.getLevel();i<orderedRefs.length;i++){
-										if(orderedRefs[i]== null){
-
-											orderedRefs[i] = refs.get(sers.indexOf(s));
-											break;
-										}
-//										else{
-//											if(i==orderedRefs.length)
-//												System.out.println("GRRR");
-//										}
-									}
-								}
-							}
-						}
-					}
-				}
-			}
-		}
-
-		//adding references which are not connected to any service
-		for(String ref : refs){
-			for(int i=0; i<orderedRefs.length ; i++){
-				if(ref.equals(orderedRefs[i])){
-					break;
-				}
-				else if(orderedRefs[i] == null){
-					orderedRefs[i] = ref;
-					break;
-				}
-			}
-		}
-
-		return orderedRefs;
-	}
-
-	private ArrayList<String> buildReferenceToMappingServiceList(ArrayList<String> refs, ComponentEntity e) {
-		
-		ArrayList<String> sers = new ArrayList<String>();
-		
-		for(int i=0;i<refs.size();i++){
-			sers.add(i, "");
-		}
-		
-		for(Iterator it= e.getReferenceToServiceMap().entrySet().iterator();
-		it.hasNext();){
-			
-			Entry entry = (Entry) it.next(); 
-			String ref = (String)entry.getKey(); 
-			String ser = (String)entry.getValue();
-			//System.out.println("---------"+ref);
-			int idx= refs.indexOf(ref);
-			//System.out.println("---------"+sers.get(idx));
-			sers.remove(idx);
-			sers.add(idx ,ser);
-			//System.out.println(refs.get(idx)+"---"+sers.get(idx));
-
-		}
-		
-		return sers;
-	}
-
-	private void addComponentService(ComponentEntity ent) {
-		int serHeight = ent.getSerHeight();
-		int x= ent.getX()-(serHeight*2/3);
-		int y= ent.getY() + Constant.SPACING_FOR_COMPONENT_OF_SERVICE;
-
-		//System.out.println("''''''"+ent.getName() +" '''''' "+ ent.getServices().size());
-		for(String ser: ent.getServices()){
-
-			ServiceArtifact serve= new ServiceArtifact();
-			Element polygon = serve.addElement(doc, svgNS, x, y, serHeight);
-			Element text;
-			if(!ser.endsWith("Impl"))
-				text = Text.addTextElement(doc, svgNS, x, y-Constant.SPACING_FOR_TEXT, ser);
-			else
-				text = Text.addTextElement(doc, svgNS, x, y-Constant.SPACING_FOR_TEXT, "");
-
-			svgRoot.appendChild(polygon);
-			svgRoot.appendChild(text);
-
-			y += (serHeight + Constant.SPACING_FOR_COMPONENT_OF_SERVICE);
-
-			serve.setName(ser);
-			serve.setContainerName(ent.getName());
-			sers.add(serve);
-		}
-	}
-
-	private void addCompositeService() {
-
-		int serHeight = comp.getSerHeight();
-		int x= comp.getX()-(serHeight*2/3);
-		int y= comp.getY() + getStartingPoint(comp.getHeight(), serHeight, Constant.SPACING_FOR_COMPOSITE_OF_SERVICE, 
-				comp.getServices().size());
-		
-		//int y= comp.getY() + Constant.SPACING_FOR_COMPOSITE_OF_SERVICE;
-
-		//System.err.println(serHeight);
-		//System.out.println("''''''"+((CompositeEntity)comp).getName() +" '''''' "+ comp.getServices().size());
-		for(String ser: comp.getServices()){
-
-			ServiceArtifact serve= new ServiceArtifact();
-			Element polygon = serve.addElement(doc, svgNS, x, y, serHeight);
-			Element text;
-			if(!ser.endsWith("Impl"))
-				text = Text.addTextElement(doc, svgNS, x, y-Constant.SPACING_FOR_TEXT, ser);
-			else
-				text = Text.addTextElement(doc, svgNS, x, y-Constant.SPACING_FOR_TEXT, "");
-
-			svgRoot.appendChild(polygon);
-			svgRoot.appendChild(text);
-
-			y += (serHeight + Constant.SPACING_FOR_COMPOSITE_OF_SERVICE);
-
-			serve.setName(ser);
-			serve.setContainerName(comp.getName());
-			sers.add(serve);
-		}
-	}
-
-	private void addCompositeReference() {
-
-		int refHeight = comp.getRefHeight();
-		
-		int x=(comp.getX()+comp.getWidth())-(refHeight*2/3);
-		int y= comp.getY() + getStartingPoint(comp.getHeight(), refHeight, Constant.SPACING_FOR_COMPOSITE_OF_REFERENCE, 
-				comp.getReferences().size());
-
-		for(String ref: comp.getReferences()){
-			ReferenceArtifact refer= new ReferenceArtifact();
-			Element polygon = refer.addElement(doc, svgNS, x, y, refHeight);
-			Element text = Text.addTextElement(doc, svgNS, x, y-Constant.SPACING_FOR_TEXT, ref);
-			svgRoot.appendChild(polygon);
-			svgRoot.appendChild(text);
-
-			y += (refHeight + Constant.SPACING_FOR_COMPOSITE_OF_REFERENCE);
-
-			refer.setName(ref);
-			refer.setContainerName(comp.getName());
-			refs.add(refer);
-
-		}
-
-	}
-
-	//Algorithm to position in center
-	private int getStartingPoint(int compDim, int artifactDim, int gap, int artifactQty) {
-
-		int x = (compDim - artifactQty * artifactDim - (artifactQty-1) * gap ) / 2;
-		return x;
-	}
-
-	private void addCompositeProperties() {
-		int propLen = comp.getPropLength();
-		
-		int x= comp.getX() + getStartingPoint(comp.getWidth(), propLen, Constant.SPACING_FOR_COMPOSITE_OF_PROPERTY, 
-				comp.getProperties().size());
-		//int x= comp.getX() + Constant.SPACING_FOR_COMPOSITE_OF_PROPERTY;
-		int y= comp.getY()-propLen/2;
-
-		for(String prop: comp.getProperties()){
-			PropertyArtifact pro = new PropertyArtifact();
-			Element property = pro.addElement(doc, svgNS, x, y, propLen);
-			Element text = Text.addTextElement(doc, svgNS, x, y-Constant.SPACING_FOR_TEXT, prop);
-
-			svgRoot.appendChild(property);
-			svgRoot.appendChild(text);
-
-			x += (propLen + Constant.SPACING_FOR_COMPOSITE_OF_PROPERTY);
-
-			pro.setName(prop);
-			pro.setContainerName(comp.getName());
-		}
-	}
-
-	private void addComponent(Entity ent) {
-
-		ComponentArtifact comp = new ComponentArtifact();
-		//System.err.println(ent.getX());
-		Element com = comp.addElement(doc, svgNS, ent.getX(), ent.getY(), 
-				ent.getHeight(), ent.getWidth());	
-		Element text = Text.addTextElement(doc, svgNS, ent.getX(), 
-				ent.getY()+(ent.getHeight()+Constant.COMPONENT_TEXT_SPACING), ent.getName());
-
-		svgRoot.appendChild(com);
-		svgRoot.appendChild(text);
-
-		comp.setName(ent.getName());
-	}
-
-	private void addComposite() {
-
-		CompositeArtifact composite = new CompositeArtifact();
-
-		Element composi = composite.addElement(doc, svgNS, comp.getX(), comp.getY(), comp.getHeight(), comp.getWidth());
-		Element text = Text.addTextElement(doc, svgNS, comp.getX()+20, comp.getY() +20, comp.getName());
-
-		svgRoot.appendChild(composi);
-		svgRoot.appendChild(text);
-
-		composite.setName(comp.getName());
-
-
-	}
-
-	public void setDiagramHeight(int diagramHeight) {
-		this.diagramHeight = diagramHeight;
-	}
-
-	public int getDiagramHeight() {
-		return diagramHeight;
-	}
-
-	public void setDiagramWidth(int diagramWidth) {
-		this.diagramWidth = diagramWidth;
-	}
-
-	public int getDiagramWidth() {
-		return diagramWidth;
-	}
+    private CompositeEntity comp;
+    private Document doc;
+    private String svgNS;
+    private Element svgRoot;
+    private ArrayList<ReferenceArtifact> refs = new ArrayList<ReferenceArtifact>();
+    private ArrayList<ServiceArtifact> sers = new ArrayList<ServiceArtifact>();
+    private int diagramHeight, diagramWidth;
 
+    private boolean isHtml;
 
+    private int lastUsedChangingFactor = 0;
+
+    enum changingFactor {
+        a(20), b(25), c(30), d(35), e(40), f(15);
+
+        private final int val;
+
+        private changingFactor(int x) {
+            val = x;
+        }
+
+        public int getVal() {
+            return val;
+        }
+
+    };
+
+    enum color {
+        black
+    }//, violet, red, green};
+
+    private int previousWireColor = 0;
+
+    /**
+     * Constructor to generate a SVG diagram for a given CompositeEntity
+     * Object.
+     */
+    public DiagramGenerator(CompositeEntity comp, boolean isHtml) {
+
+        this.comp = comp;
+        this.isHtml = isHtml;
+
+    }
+
+    /**
+     * Draws the diagram.
+     */
+    public Document buildSVGDocument() {
+
+        DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
+        svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
+        doc = impl.createDocument(svgNS, "svg", null);
+
+        // Get the root element (the 'svg' element).
+        svgRoot = doc.getDocumentElement();
+
+        setDiagramHeight(comp.getHeight() + 200);
+        setDiagramWidth(comp.getWidth() + 400);
+
+        svgRoot.setAttributeNS(null, "viewBox", "0 0 " + getDiagramWidth() + " " + getDiagramHeight());
+
+        addLayer();
+        addComposite();
+
+        for (ComponentEntity ent : comp.getComponentList()) {
+
+            addComponent(ent);
+            addComponentProperties(ent);
+            addComponentService(ent);
+            addComponentReference(ent);
+        }
+
+        addCompositeProperties();
+        addCompositeService();
+        addCompositeReference();
+
+        addComponentConnections();
+        addReferencePromotion();
+        addServicePromotion();
+
+        addInclusions();
+
+        return doc;
+    }
+
+    private void addLayer() {
+
+        Layer outerLayer = new Layer();
+        Element layerElt = outerLayer.addElement(doc, svgNS, 0, 0, getDiagramHeight(), getDiagramWidth());
+        svgRoot.appendChild(layerElt);
+    }
+
+    private void addReferencePromotion() {
+
+        for (Iterator it = comp.getPromoteAReference().entrySet().iterator(); it.hasNext();) {
+            Entry entry = (Entry)it.next();
+            String compositeRef = (String)entry.getKey();
+            ArrayList<String> componentRef = (ArrayList<String>)entry.getValue();
+
+            ReferenceArtifact r1 = getRef(compositeRef);
+
+            for (String ref : componentRef) {
+
+                ReferenceArtifact r2 = getRef(ref);
+
+                if (r1 != null && r2 != null) {
+                    addWire(r2, r1);
+                }
+            }
+
+        }
+    }
+
+    private void addServicePromotion() {
+
+        for (Iterator it = comp.getPromoteAService().entrySet().iterator(); it.hasNext();) {
+            Entry entry = (Entry)it.next();
+            String compositeSer = (String)entry.getKey();
+            String componentSer = (String)entry.getValue();
+
+            ServiceArtifact s1 = getSer(compositeSer);
+            ServiceArtifact s2 = getSer(componentSer);
+
+            if (s1 != null && s2 != null) {
+                addWire(s1, s2);
+            }
+        }
+    }
+
+    private void addInclusions() {
+
+        if (!comp.getIncludedComposites().isEmpty()) {
+
+            Layer inclusionLayer = new Layer();
+            int constant = 5;
+            int x0 = comp.getX() + constant;
+            int y0 = comp.getY() + comp.getHeight() - (Constant.COMPONENT_DEFAULT_HEIGHT / 2 + constant);
+            int height = Constant.COMPONENT_DEFAULT_HEIGHT / 2;
+            int width = comp.getWidth() - constant * 2;
+
+            Element layerElt = inclusionLayer.addElement(doc, svgNS, x0, y0, height, width, "#E5E5C0");
+
+            Element text = Text.addTextElement(doc, svgNS, x0 + constant, y0 + constant * 2, "Included Composites");
+
+            svgRoot.appendChild(layerElt);
+            svgRoot.appendChild(text);
+
+            text = Text.addTextElement(doc, svgNS, x0 + constant, y0 + constant * 7, "");
+
+            String ext;
+
+            if (isHtml) {
+                ext = ".html";
+            } else {
+                ext = ".svg";
+            }
+
+            for (String includedComposite : comp.getIncludedComposites()) {
+
+                Link link = new Link();
+                Element aLink =
+                    link.addElement(doc, svgNS, includedComposite + comp.getFileNameSuffix() + ext, includedComposite);
+                text.appendChild(aLink);
+
+            }
+            svgRoot.appendChild(text);
+        }
+    }
+
+    /**
+     * Connects references to services.
+     */
+    private void addComponentConnections() {
+
+        for (Entity ent : comp.getComponentList()) {
+            //if(ent instanceof ComponentEntity){
+
+            for (Iterator it = ((ComponentEntity)ent).getReferenceToServiceMap().entrySet().iterator(); it.hasNext();) {
+                Entry entry = (Entry)it.next();
+                String ref = (String)entry.getKey();
+                String ser = (String)entry.getValue();
+
+                ReferenceArtifact r = getRef(ref);
+                ServiceArtifact s = getSer(ser);
+
+                if (r != null && s != null) {
+                    addWire(r, s);
+                }
+            }
+            //}
+        }
+    }
+
+    /**
+     * This is to remove overlapping of wire elements
+     */
+    private String getColor() {
+
+        previousWireColor = previousWireColor % color.values().length;
+        return color.values()[previousWireColor++].toString();
+    }
+
+    /**
+     * This is to remove overlapping of wire elements
+     */
+    private int getChangingFactor() {
+
+        lastUsedChangingFactor = lastUsedChangingFactor % changingFactor.values().length;
+        return changingFactor.values()[lastUsedChangingFactor++].getVal();
+
+    }
+
+    private void addWire(ReferenceArtifact r, ServiceArtifact s) {
+
+        WireArtifact edge = new NormalWire();
+        Element wire = edge.addElement(doc, svgNS, r, s, getChangingFactor(), getColor());
+        svgRoot.appendChild(wire);
+    }
+
+    private void addWire(ServiceArtifact s1, ServiceArtifact s2) {
+
+        DashedWire edge = new DashedWire();
+        Element wire = edge.addElement(doc, svgNS, s1, s2, getChangingFactor(), getColor());
+        svgRoot.appendChild(wire);
+    }
+
+    private void addWire(ReferenceArtifact r1, ReferenceArtifact r2) {
+
+        DashedWire edge = new DashedWire();
+        Element wire = edge.addElement(doc, svgNS, r1, r2, getChangingFactor(), getColor());
+        svgRoot.appendChild(wire);
+    }
+
+    private ServiceArtifact getSer(String ser) {
+
+        for (ServiceArtifact s : sers) {
+            if (s.getContainerName().equals(ser) || s.getName().equals(ser)) {
+                return s;
+            }
+        }
+        return null;
+    }
+
+    private ReferenceArtifact getRef(String ref) {
+
+        for (ReferenceArtifact r : refs) {
+
+            if (r.getContainerName().equals(ref) || r.getName().equals(ref)) {
+                return r;
+            }
+        }
+        return null;
+    }
+
+    private void addComponentProperties(ComponentEntity ent) {
+        int propLen = ent.getPropLength();
+        int x = ent.getX() + Constant.SPACING_FOR_COMPONENT_OF_PROPERTY;
+        int y = ent.getY() - propLen / 2;
+
+        for (String prop : ent.getProperties()) {
+            PropertyArtifact pro = new PropertyArtifact();
+            Element property = pro.addElement(doc, svgNS, x, y, propLen);
+            Element text = Text.addTextElement(doc, svgNS, x, y - Constant.SPACING_FOR_TEXT, prop);
+
+            svgRoot.appendChild(property);
+            svgRoot.appendChild(text);
+
+            x += (propLen + Constant.SPACING_FOR_COMPONENT_OF_PROPERTY);
+
+            pro.setName(prop);
+            pro.setContainerName(ent.getName());
+        }
+    }
+
+    private void addComponentReference(ComponentEntity ent) {
+
+        int refHeight = ent.getRefHeight();
+        int x = (ent.getX() + ent.getWidth()) - (refHeight * 2 / 3);
+        int y = ent.getY() + Constant.SPACING_FOR_COMPONENT_OF_REFERENCE;
+
+        for (String ref : setRefOrder(ent)) {
+            ReferenceArtifact refer = new ReferenceArtifact();
+            Element polygon = refer.addElement(doc, svgNS, x, y, refHeight);
+            Element text = Text.addTextElement(doc, svgNS, x, y - Constant.SPACING_FOR_TEXT, ref);
+            svgRoot.appendChild(polygon);
+            svgRoot.appendChild(text);
+
+            y += (refHeight + Constant.SPACING_FOR_COMPONENT_OF_REFERENCE);
+
+            refer.setName(ref);
+            refer.setContainerName(ent.getName());
+            refs.add(refer);
+
+        }
+    }
+
+    /**
+     * This method is used to organize the Component References,
+     * in a manner where they are stay approximately in-line with the
+     * connecting Service. This would enhance the clearness of the diagram.
+     */
+    private String[] setRefOrder(ComponentEntity e) {
+
+        ArrayList<String> refs = e.getReferences();
+        ArrayList<String> sers = new ArrayList<String>();
+        String[] orderedRefs = new String[refs.size()];
+
+        //sers = new ArrayList<String>(e.getReferenceToServiceMap().values());
+
+        sers = buildReferenceToMappingServiceList(refs, e);
+
+        for (String eName : e.getAdjacentEntities()) {
+            for (Entity ent : comp.getComponentList()) {
+
+                if (ent.getName().equals(eName)) {
+                    for (String s : sers) {
+                        for (String s1 : ent.getServices()) {
+                            //System.err.println("XXXXX "+ s1 +" ::: "+s);
+                            if (s1.equals(s) || s.equals(ent.getName())) {
+                                //System.err.println("|||||||| "+ sers.size()+ " ||| " + refs.size()+"|| "+orderedRefs.length);
+                                if (orderedRefs[ent.getLevel()] == null) {
+                                    //System.err.println("XXXXX "+ sers.get(1)+ " ::::::: "+refs.get(1));
+                                    //									System.err.println("XXXXX "+ sers.get(2)+ " ::::::: "+refs.get(2));
+                                    //									System.err.println("XXXXX "+ sers.get(3)+ " ::::::: "+refs.get(3));
+                                    //System.err.println("XXXXX "+ refs.get(sers.indexOf(s))+" ::: "+ent.getLevel()+" ::: "+ent.getName());
+                                    orderedRefs[ent.getLevel()] = refs.get(sers.indexOf(s));
+                                    break;
+                                } else {
+                                    for (int i = ent.getLevel(); i < orderedRefs.length; i++) {
+                                        if (orderedRefs[i] == null) {
+
+                                            orderedRefs[i] = refs.get(sers.indexOf(s));
+                                            break;
+                                        }
+                                        //										else{
+                                        //											if(i==orderedRefs.length)
+                                        //												System.out.println("GRRR");
+                                        //										}
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        //adding references which are not connected to any service
+        for (String ref : refs) {
+            for (int i = 0; i < orderedRefs.length; i++) {
+                if (ref.equals(orderedRefs[i])) {
+                    break;
+                } else if (orderedRefs[i] == null) {
+                    orderedRefs[i] = ref;
+                    break;
+                }
+            }
+        }
+
+        return orderedRefs;
+    }
+
+    private ArrayList<String> buildReferenceToMappingServiceList(ArrayList<String> refs, ComponentEntity e) {
+
+        ArrayList<String> sers = new ArrayList<String>();
+
+        for (int i = 0; i < refs.size(); i++) {
+            sers.add(i, "");
+        }
+
+        for (Iterator it = e.getReferenceToServiceMap().entrySet().iterator(); it.hasNext();) {
+
+            Entry entry = (Entry)it.next();
+            String ref = (String)entry.getKey();
+            String ser = (String)entry.getValue();
+            //System.out.println("---------"+ref);
+            int idx = refs.indexOf(ref);
+            //System.out.println("---------"+sers.get(idx));
+            sers.remove(idx);
+            sers.add(idx, ser);
+            //System.out.println(refs.get(idx)+"---"+sers.get(idx));
+
+        }
+
+        return sers;
+    }
+
+    private void addComponentService(ComponentEntity ent) {
+        int serHeight = ent.getSerHeight();
+        int x = ent.getX() - (serHeight * 2 / 3);
+        int y = ent.getY() + Constant.SPACING_FOR_COMPONENT_OF_SERVICE;
+
+        //System.out.println("''''''"+ent.getName() +" '''''' "+ ent.getServices().size());
+        for (String ser : ent.getServices()) {
+
+            ServiceArtifact serve = new ServiceArtifact();
+            Element polygon = serve.addElement(doc, svgNS, x, y, serHeight);
+            Element text;
+            if (!ser.endsWith("Impl"))
+                text = Text.addTextElement(doc, svgNS, x, y - Constant.SPACING_FOR_TEXT, ser);
+            else
+                text = Text.addTextElement(doc, svgNS, x, y - Constant.SPACING_FOR_TEXT, "");
+
+            svgRoot.appendChild(polygon);
+            svgRoot.appendChild(text);
+
+            y += (serHeight + Constant.SPACING_FOR_COMPONENT_OF_SERVICE);
+
+            serve.setName(ser);
+            serve.setContainerName(ent.getName());
+            sers.add(serve);
+        }
+    }
+
+    private void addCompositeService() {
+
+        int serHeight = comp.getSerHeight();
+        int x = comp.getX() - (serHeight * 2 / 3);
+        int y =
+            comp.getY() + getStartingPoint(comp.getHeight(), serHeight, Constant.SPACING_FOR_COMPOSITE_OF_SERVICE, comp
+                .getServices().size());
+
+        //int y= comp.getY() + Constant.SPACING_FOR_COMPOSITE_OF_SERVICE;
+
+        //System.err.println(serHeight);
+        //System.out.println("''''''"+((CompositeEntity)comp).getName() +" '''''' "+ comp.getServices().size());
+        for (String ser : comp.getServices()) {
+
+            ServiceArtifact serve = new ServiceArtifact();
+            Element polygon = serve.addElement(doc, svgNS, x, y, serHeight);
+            Element text;
+            if (!ser.endsWith("Impl"))
+                text = Text.addTextElement(doc, svgNS, x, y - Constant.SPACING_FOR_TEXT, ser);
+            else
+                text = Text.addTextElement(doc, svgNS, x, y - Constant.SPACING_FOR_TEXT, "");
+
+            svgRoot.appendChild(polygon);
+            svgRoot.appendChild(text);
+
+            y += (serHeight + Constant.SPACING_FOR_COMPOSITE_OF_SERVICE);
+
+            serve.setName(ser);
+            serve.setContainerName(comp.getName());
+            sers.add(serve);
+        }
+    }
+
+    private void addCompositeReference() {
+
+        int refHeight = comp.getRefHeight();
+
+        int x = (comp.getX() + comp.getWidth()) - (refHeight * 2 / 3);
+        int y =
+            comp.getY() + getStartingPoint(comp.getHeight(),
+                                           refHeight,
+                                           Constant.SPACING_FOR_COMPOSITE_OF_REFERENCE,
+                                           comp.getReferences().size());
+
+        for (String ref : comp.getReferences()) {
+            ReferenceArtifact refer = new ReferenceArtifact();
+            Element polygon = refer.addElement(doc, svgNS, x, y, refHeight);
+            Element text = Text.addTextElement(doc, svgNS, x, y - Constant.SPACING_FOR_TEXT, ref);
+            svgRoot.appendChild(polygon);
+            svgRoot.appendChild(text);
+
+            y += (refHeight + Constant.SPACING_FOR_COMPOSITE_OF_REFERENCE);
+
+            refer.setName(ref);
+            refer.setContainerName(comp.getName());
+            refs.add(refer);
+
+        }
+
+    }
+
+    //Algorithm to position in center
+    private int getStartingPoint(int compDim, int artifactDim, int gap, int artifactQty) {
+
+        int x = (compDim - artifactQty * artifactDim - (artifactQty - 1) * gap) / 2;
+        return x;
+    }
+
+    private void addCompositeProperties() {
+        int propLen = comp.getPropLength();
+
+        int x =
+            comp.getX() + getStartingPoint(comp.getWidth(), propLen, Constant.SPACING_FOR_COMPOSITE_OF_PROPERTY, comp
+                .getProperties().size());
+        //int x= comp.getX() + Constant.SPACING_FOR_COMPOSITE_OF_PROPERTY;
+        int y = comp.getY() - propLen / 2;
+
+        for (String prop : comp.getProperties()) {
+            PropertyArtifact pro = new PropertyArtifact();
+            Element property = pro.addElement(doc, svgNS, x, y, propLen);
+            Element text = Text.addTextElement(doc, svgNS, x, y - Constant.SPACING_FOR_TEXT, prop);
+
+            svgRoot.appendChild(property);
+            svgRoot.appendChild(text);
+
+            x += (propLen + Constant.SPACING_FOR_COMPOSITE_OF_PROPERTY);
+
+            pro.setName(prop);
+            pro.setContainerName(comp.getName());
+        }
+    }
+
+    private void addComponent(Entity ent) {
+
+        ComponentArtifact comp = new ComponentArtifact();
+        //System.err.println(ent.getX());
+        Element com = comp.addElement(doc, svgNS, ent.getX(), ent.getY(), ent.getHeight(), ent.getWidth());
+        Element text =
+            Text.addTextElement(doc,
+                                svgNS,
+                                ent.getX(),
+                                ent.getY() + (ent.getHeight() + Constant.COMPONENT_TEXT_SPACING),
+                                ent.getName());
+
+        svgRoot.appendChild(com);
+        svgRoot.appendChild(text);
+
+        comp.setName(ent.getName());
+    }
+
+    private void addComposite() {
+
+        CompositeArtifact composite = new CompositeArtifact();
+
+        Element composi = composite.addElement(doc, svgNS, comp.getX(), comp.getY(), comp.getHeight(), comp.getWidth());
+        Element text = Text.addTextElement(doc, svgNS, comp.getX() + 20, comp.getY() + 20, comp.getName());
+
+        svgRoot.appendChild(composi);
+        svgRoot.appendChild(text);
+
+        composite.setName(comp.getName());
+
+    }
+
+    public void setDiagramHeight(int diagramHeight) {
+        this.diagramHeight = diagramHeight;
+    }
+
+    public int getDiagramHeight() {
+        return diagramHeight;
+    }
+
+    public void setDiagramWidth(int diagramWidth) {
+        this.diagramWidth = diagramWidth;
+    }
+
+    public int getDiagramWidth() {
+        return diagramWidth;
+    }
 
 }

Modified: tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/html/HTMLWrapper.java
URL: http://svn.apache.org/viewvc/tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/html/HTMLWrapper.java?rev=1164123&r1=1164122&r2=1164123&view=diff
==============================================================================
--- tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/html/HTMLWrapper.java (original)
+++ tuscany/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/html/HTMLWrapper.java Thu Sep  1 15:57:25 2011
@@ -22,76 +22,69 @@ package org.apache.tuscany.sca.impl.html
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
-import java.io.StringWriter;
-
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Document;
-
 
 public class HTMLWrapper {
-	
-	private File htmlFilePath;
-	private String compositeName;
-	private String svg;
-	
-	
-	/**
-	 * 
-	 * @param svg
-	 * @param compositeName
-	 * @param htmlFilePath
-	 */
-	public HTMLWrapper(String svg, String compositeName, File htmlFilePath) {
-		
-		this.svg = svg;
-		this.compositeName = compositeName;
-		this.htmlFilePath = htmlFilePath;
-	}
-	
-	public String buildHTML() throws Exception{
-		String content = "" +
-				"<html>\n" +
-				"<head>\n" +
-				"<h1 align='center'>Apache Tuscany - Composite Diagram Generator</h1>\n" +
-				"<h2 align='center'>"+compositeName+"</h2>\n" +
-				"</br>\n" +
-//				"<script type=\"text/javascript\" src=\""+CANVG_LIB_DIR+RGB_FILE+"\"></script>\n" +
-//				"<script type=\"text/javascript\" src=\""+CANVG_LIB_DIR+CANVG_FILE+"\"></script>\n" +
-//				"<script type=\"text/javascript\">\n" +
-//				"window.onload = function() {\n" +
-//				"//load '../path/to/your.svg' in the canvas with id = 'canvas'\n" +
-//				"canvg('canvas', '"+svgFileName+"')\n" +
-//				"//load a svg snippet in the canvas with id = 'drawingArea'\n" +
-//				"canvg(document.getElementById('drawingArea'), '<svg>...</svg>')\n" +
-//				"canvg('canvas', '"+svgFileName+"', {})\n" +
-//				"}\n" +
-//				"</script>\n" +
-				"</head>\n" +
-				"<body>\n" +
-				svg+"\n"+
-//				"<canvas id=\"canvas\" width=\""+compositeWidth+"px\" height=\""+compositeHeight+"px\">\n" +
-//				"</canvas>\n" +
-				"</body>\n" +
-				"</html>";
-		
-		fileWriter(content);
-		
-		return content;
-		
-	}
-
-
-	private void fileWriter(String content) throws Exception{
-
-		FileWriter fileWriter = new FileWriter(htmlFilePath);
-		BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
-		bufferedWriter.append(content);
-		bufferedWriter.close();
 
-	}
+    private File htmlFilePath;
+    private String compositeName;
+    private String svg;
+
+    /**
+     * 
+     * @param svg
+     * @param compositeName
+     * @param htmlFilePath
+     */
+    public HTMLWrapper(String svg, String compositeName, File htmlFilePath) {
+
+        this.svg = svg;
+        this.compositeName = compositeName;
+        this.htmlFilePath = htmlFilePath;
+    }
+
+    public String buildHTML() throws Exception {
+        String content =
+            "" + "<html>\n"
+                + "<head>\n"
+                + "<h1 align='center'>Apache Tuscany - Composite Diagram Generator</h1>\n"
+                + "<h2 align='center'>"
+                + compositeName
+                + "</h2>\n"
+                + "</br>\n"
+                +
+                //				"<script type=\"text/javascript\" src=\""+CANVG_LIB_DIR+RGB_FILE+"\"></script>\n" +
+                //				"<script type=\"text/javascript\" src=\""+CANVG_LIB_DIR+CANVG_FILE+"\"></script>\n" +
+                //				"<script type=\"text/javascript\">\n" +
+                //				"window.onload = function() {\n" +
+                //				"//load '../path/to/your.svg' in the canvas with id = 'canvas'\n" +
+                //				"canvg('canvas', '"+svgFileName+"')\n" +
+                //				"//load a svg snippet in the canvas with id = 'drawingArea'\n" +
+                //				"canvg(document.getElementById('drawingArea'), '<svg>...</svg>')\n" +
+                //				"canvg('canvas', '"+svgFileName+"', {})\n" +
+                //				"}\n" +
+                //				"</script>\n" +
+                "</head>\n"
+                + "<body>\n"
+                + svg
+                + "\n"
+                +
+                //				"<canvas id=\"canvas\" width=\""+compositeWidth+"px\" height=\""+compositeHeight+"px\">\n" +
+                //				"</canvas>\n" +
+                "</body>\n"
+                + "</html>";
+
+        fileWriter(content);
+
+        return content;
+
+    }
+
+    private void fileWriter(String content) throws Exception {
+
+        FileWriter fileWriter = new FileWriter(htmlFilePath);
+        BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
+        bufferedWriter.append(content);
+        bufferedWriter.close();
+
+    }
 }



Mime
View raw message