summaryrefslogtreecommitdiffstats
path: root/collaboration
diff options
context:
space:
mode:
authornirmal070125 <nirmal070125@13f79535-47bb-0310-9956-ffa450edef68>2011-06-13 07:37:39 +0000
committernirmal070125 <nirmal070125@13f79535-47bb-0310-9956-ffa450edef68>2011-06-13 07:37:39 +0000
commitb8d829dd982e8c4fa170f8bb8b095e8a1be8115e (patch)
tree98417bfacd7e8acf00c417a6c2efcf36a7916de9 /collaboration
parent4793edeb2e0b18059c965759c78f06c6b77faf67 (diff)
Another version of layout algorithm and diagram creation
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1135039 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'collaboration')
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/Calculator_diagram.svg1
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/store_diagram.svg1
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/supplychain_diagram.svg1
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Artifact.java18
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Component.java33
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Composite.java29
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Property.java13
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Reference.java29
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java24
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Wire.java35
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java174
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLReader.java5
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLWriter.java27
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/Entity.java16
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java148
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/Main.java14
16 files changed, 328 insertions, 240 deletions
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/Calculator_diagram.svg b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/Calculator_diagram.svg
new file mode 100755
index 0000000000..66318f9eb9
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/Calculator_diagram.svg
@@ -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" alignment-baseline="central" fill="#E5E5E5" width="900" rx="20" ry="20" height="1140" stroke="#919191"/><text x="450" font-size="20" dominant-baseline="mathematical" y="20" text-anchor="middle">Calculator</text><rect x="100" y="100" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="150" font-size="20" dominant-baseline="mathematical" y="250" text-anchor="middle">CalculatorServiceComponent</text><polygon fill="#BF3EFF" points="286,110 318,110 334,121 318,132 286,132 302,121 " stroke="#68228B"/><text x="286" font-size="20" dominant-baseline="mathematical" y="121" text-anchor="middle">addService</text><polygon fill="#BF3EFF" points="286,142 318,142 334,153 318,164 286,164 302,153 " stroke="#68228B"/><text x="286" font-size="20" dominant-baseline="mathematical" y="153" text-anchor="middle">subtractService</text><polygon fill="#BF3EFF" points="286,174 318,174 334,185 318,196 286,196 302,185 " stroke="#68228B"/><text x="286" font-size="20" dominant-baseline="mathematical" y="185" text-anchor="middle">multiplyService</text><polygon fill="#BF3EFF" points="286,206 318,206 334,217 318,228 286,228 302,217 " stroke="#68228B"/><text x="286" font-size="20" dominant-baseline="mathematical" y="217" text-anchor="middle">divideService</text><rect x="500" y="880" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="550" font-size="20" dominant-baseline="mathematical" y="1030" text-anchor="middle">AddServiceComponent</text><rect x="500" y="100" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="550" font-size="20" dominant-baseline="mathematical" y="250" text-anchor="middle">SubtractServiceComponent</text><rect x="500" y="620" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="550" font-size="20" dominant-baseline="mathematical" y="770" text-anchor="middle">MultiplyServiceComponent</text><rect x="500" y="360" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="550" font-size="20" dominant-baseline="mathematical" y="510" text-anchor="middle">DivideServiceComponent</text></svg> \ No newline at end of file
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/store_diagram.svg b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/store_diagram.svg
new file mode 100755
index 0000000000..eb7fece1ac
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/store_diagram.svg
@@ -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" alignment-baseline="central" fill="#E5E5E5" width="1300" rx="20" ry="20" height="620" stroke="#919191"/><text x="650" font-size="20" dominant-baseline="mathematical" y="20" text-anchor="middle">store</text><rect x="100" y="100" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="150" font-size="20" dominant-baseline="mathematical" y="250" text-anchor="middle">Store</text><polygon fill="#00CD66" points="80,110 110,110 125,125 110,140 80,140 95,125 " stroke="#008B45"/><text x="80" font-size="20" dominant-baseline="mathematical" y="125" text-anchor="middle">Widget</text><polygon fill="#BF3EFF" points="280,110 310,110 325,125 310,140 280,140 295,125 " stroke="#68228B"/><text x="280" font-size="20" dominant-baseline="mathematical" y="125" text-anchor="middle">catalog</text><polygon fill="#BF3EFF" points="280,150 310,150 325,165 310,180 280,180 295,165 " stroke="#68228B"/><text x="280" font-size="20" dominant-baseline="mathematical" y="165" text-anchor="middle">shoppingCart</text><polygon fill="#BF3EFF" points="280,190 310,190 325,205 310,220 280,220 295,205 " stroke="#68228B"/><text x="280" font-size="20" dominant-baseline="mathematical" y="205" text-anchor="middle">shoppingTotal</text><rect x="500" y="100" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="550" font-size="20" dominant-baseline="mathematical" y="250" text-anchor="middle">Catalog</text><polygon fill="#00CD66" points="480,110 510,110 525,125 510,140 480,140 495,125 " stroke="#008B45"/><text x="480" font-size="20" dominant-baseline="mathematical" y="125" text-anchor="middle">Catalog</text><polygon fill="#BF3EFF" points="680,110 710,110 725,125 710,140 680,140 695,125 " stroke="#68228B"/><text x="680" font-size="20" dominant-baseline="mathematical" y="125" text-anchor="middle">currencyConverter</text><rect fill="#EEEE00" x="520" width="20" height="20" y="90" stroke="#EEC900"/><text x="520" font-size="20" dominant-baseline="mathematical" y="90" text-anchor="middle">currencyCode</text><rect x="500" y="360" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="550" font-size="20" dominant-baseline="mathematical" y="510" text-anchor="middle">ShoppingCart</text><polygon fill="#00CD66" points="480,370 510,370 525,385 510,400 480,400 495,385 " stroke="#008B45"/><text x="480" font-size="20" dominant-baseline="mathematical" y="385" text-anchor="middle">Cart</text><polygon fill="#00CD66" points="480,410 510,410 525,425 510,440 480,440 495,425 " stroke="#008B45"/><text x="480" font-size="20" dominant-baseline="mathematical" y="425" text-anchor="middle">Total</text><rect x="900" y="100" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="950" font-size="20" dominant-baseline="mathematical" y="250" text-anchor="middle">CurrencyConverter</text><polyline stroke-width="2" points="325,205 495,425" stroke="black"/><polyline stroke-width="2" points="325,165 495,385" stroke="black"/><polyline stroke-width="2" points="325,125 495,125" stroke="black"/></svg> \ No newline at end of file
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/supplychain_diagram.svg b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/supplychain_diagram.svg
new file mode 100755
index 0000000000..6a465e70f2
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/supplychain_diagram.svg
@@ -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" alignment-baseline="central" fill="#E5E5E5" width="1700" rx="20" ry="20" height="360" stroke="#919191"/><text x="850" font-size="20" dominant-baseline="mathematical" y="20" text-anchor="middle">supplychain</text><rect x="100" y="100" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="150" font-size="20" dominant-baseline="mathematical" y="250" text-anchor="middle">CustomerComponent</text><polygon fill="#BF3EFF" points="280,110 310,110 325,125 310,140 280,140 295,125 " stroke="#68228B"/><text x="280" font-size="20" dominant-baseline="mathematical" y="125" text-anchor="middle">retailer</text><rect x="500" y="100" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="550" font-size="20" dominant-baseline="mathematical" y="250" text-anchor="middle">RetailerComponent</text><polygon fill="#BF3EFF" points="680,110 710,110 725,125 710,140 680,140 695,125 " stroke="#68228B"/><text x="680" font-size="20" dominant-baseline="mathematical" y="125" text-anchor="middle">warehouse</text><rect x="900" y="100" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="950" font-size="20" dominant-baseline="mathematical" y="250" text-anchor="middle">WarehouseComponent</text><polygon fill="#BF3EFF" points="1080,110 1110,110 1125,125 1110,140 1080,140 1095,125 " stroke="#68228B"/><text x="1080" font-size="20" dominant-baseline="mathematical" y="125" text-anchor="middle">shipper</text><rect x="1300" y="100" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="1350" font-size="20" dominant-baseline="mathematical" y="250" text-anchor="middle">ShipperComponent</text><polygon fill="#BF3EFF" points="1480,110 1510,110 1525,125 1510,140 1480,140 1495,125 " stroke="#68228B"/><text x="1480" font-size="20" dominant-baseline="mathematical" y="125" text-anchor="middle">customer</text></svg> \ No newline at end of file
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Artifact.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Artifact.java
index 9a14ecf929..849d440c2d 100644
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Artifact.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Artifact.java
@@ -24,6 +24,8 @@ import org.w3c.dom.Element;
public abstract class Artifact {
+ private String name;
+ private String containerName;
private int height;
private int width;
private int xCoordinate;
@@ -88,5 +90,21 @@ public abstract class Artifact {
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;
+ }
}
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Component.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Component.java
index 8e7d20146e..9254657547 100644
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Component.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Component.java
@@ -26,39 +26,8 @@ public class Component extends Artifact{
public static final int DEFAULT_WIDTH = 200 ;
public static final int DEFAULT_HEIGHT = 130 ;
+ public static final int TEXT_SPACING = 20 ;
-
-// public Element addElement(Document document,
-// String svgNs, int x, int y) {
-//
-//
-// //Element g = document.createElementNS(svgNs, "g");
-// //g.setAttributeNS(null, "transform", "translate(100 100)");
-// // Create the rectangle.
-// Element rectangle = document.createElementNS(svgNs, "rect");
-// rectangle.setAttributeNS(null, "x", x+"");
-// rectangle.setAttributeNS(null, "y", y+"");
-// rectangle.setAttributeNS(null, "rx", ROUND_CORNER);
-// rectangle.setAttributeNS(null, "ry", ROUND_CORNER);
-// 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");
-//
-//
-//// Element text = document.createElementNS(svgNs, "text");
-//// text.setAttributeNS(null, "text-anchor", "middle");
-//// text.setAttributeNS(null, "dominant-baseline", "mathematical");
-//// text.setAttributeNS(null, "font-size", "30");
-//// text.setTextContent("A Component");
-//
-// //document.appendChild(rectangle);
-// //g.appendChild(text);
-//
-//
-// return rectangle;
-// }
/**
* Create an element with specified height and width
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Composite.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Composite.java
index 48491efe69..8b04759bee 100644
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Composite.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Composite.java
@@ -24,37 +24,10 @@ import org.w3c.dom.Element;
/**
* Structure of a "Composite" element in SCA, as a SVG element
- * @author nirmal
*
*/
public class Composite extends Artifact{
-//
-// private Document document;
-// private String svgNs;
-//
-// public Composite(Document doc, String uri){
-// document = doc;
-// svgNs = uri;
-// }
-//
-
-
-// public static Element addCompositeElement(Document document, String svgNs,
-// int x, int y, int width, int height) {
-// // Create the rectangle.
-// Element rectangle = document.createElementNS(svgNs, "rect");
-// rectangle.setAttributeNS(null, "x", x+"");
-// rectangle.setAttributeNS(null, "y", y+"");
-// rectangle.setAttributeNS(null, "rx", ROUND_CORNER);
-// rectangle.setAttributeNS(null, "ry", ROUND_CORNER);
-// 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", "central");
-//
-// return rectangle;
-// }
+
public Element addElement(Document document, String svgNs, int x, int y,
int height, int width) {
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Property.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Property.java
index 0d236ccfaa..ea6b0b9eeb 100644
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Property.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Property.java
@@ -27,19 +27,6 @@ public class Property extends Artifact{
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) {
-// Element rectangle = document.createElementNS(svgNs, "rect");
-// rectangle.setAttributeNS(null, "x", x+"");
-// rectangle.setAttributeNS(null, "y", y+"");
-// rectangle.setAttributeNS(null, "width", WIDTH);
-// rectangle.setAttributeNS(null, "height", WIDTH);
-// rectangle.setAttributeNS(null, "fill", "#EEEE00");
-// rectangle.setAttributeNS(null, "stroke", "#EEC900");
-// //rectangle.setAttributeNS(null, "fill-opacity", "0.75");
-//
-// return rectangle;
-// }
/**
* Property is a square.
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Reference.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Reference.java
index 6a3f7ff9d1..f89fc2ab5f 100644
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Reference.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Reference.java
@@ -27,27 +27,6 @@ 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) {
-//
-// // Create the rectangle.
-// Element polygon = document.createElementNS(svgNs, "polygon");
-// polygon.setAttributeNS(null, "points",
-// ""+ (midX-COMMON_LENGTH) +","+midY+" " +
-// ""+ (midX+(COMMON_LENGTH/2)) +","+midY+" " +
-// ""+ (midX+COMMON_LENGTH) +","+(midY-COMMON_LENGTH)+" " +
-// ""+ (midX+(COMMON_LENGTH/2)) +","+(midY-COMMON_LENGTH*2)+" " +
-// ""+ (midX-COMMON_LENGTH) +","+(midY-COMMON_LENGTH*2)+" " +
-// ""+ (midX-(COMMON_LENGTH/2)) +","+(midY-COMMON_LENGTH)+" "
-// );
-// polygon.setAttributeNS(null, "fill", "#BF3EFF");
-// polygon.setAttributeNS(null, "stroke", "#68228B");
-// //rectangle.setAttributeNS(null, "alignment-baseline", "central");
-//
-// return polygon;
-// }
-//
/**
* In a Reference the (x,y) coordinates refers to the top corner edge of the polygon
@@ -72,10 +51,10 @@ public class Reference extends Artifact {
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)+" "
+ ""+ (x+3*halfOfHeight) +","+(y+halfOfHeight)+" " +
+ ""+ (x+2*halfOfHeight) +","+(y+2*halfOfHeight)+" " +
+ ""+ (x) +","+(y+2*halfOfHeight)+" " +
+ ""+ (x+halfOfHeight) +","+(y+halfOfHeight)+" "
);
polygon.setAttributeNS(null, "fill", "#BF3EFF");
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java
index 986cc1b99c..37adb65f39 100644
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java
@@ -27,22 +27,6 @@ public class Service extends Artifact{
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.
-// Element polygon = document.createElementNS(svgNs, "polygon");
-// polygon.setAttributeNS(null, "points",
-// ""+ (midX-COMMON_LENGTH) +","+midY+" " +
-// ""+ (midX+(COMMON_LENGTH/2)) +","+midY+" " +
-// ""+ (midX+COMMON_LENGTH) +","+(midY-COMMON_LENGTH)+" " +
-// ""+ (midX+(COMMON_LENGTH/2)) +","+(midY-COMMON_LENGTH*2)+" " +
-// ""+ (midX-COMMON_LENGTH) +","+(midY-COMMON_LENGTH*2)+" " +
-// ""+ (midX-(COMMON_LENGTH/2)) +","+(midY-COMMON_LENGTH)+" "
-// );
-// polygon.setAttributeNS(null, "fill", "#00CD66");
-// polygon.setAttributeNS(null, "stroke", "#008B45");
-//
-// return polygon;
-// }
/**
* In a Service the (x,y) coordinates refers to the top corner edge of the polygon
@@ -66,10 +50,10 @@ public class Service extends Artifact{
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)+" "
+ ""+ (x+3*halfOfHeight) +","+(y+halfOfHeight)+" " +
+ ""+ (x+2*halfOfHeight) +","+(y+2*halfOfHeight)+" " +
+ ""+ (x) +","+(y+2*halfOfHeight)+" " +
+ ""+ (x+halfOfHeight) +","+(y+halfOfHeight)+" "
);
polygon.setAttributeNS(null, "fill", "#00CD66");
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Wire.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Wire.java
index 143b622ec8..59ef48895a 100644
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Wire.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Wire.java
@@ -24,39 +24,20 @@ import org.w3c.dom.Element;
public class Wire {
-// <path d="M 100 100 L 300 100 L 200 300 z"
-// fill="red" stroke="blue" stroke-width="3" />
-
-// public static Element addWireElement(Document document, String svgNs, int x1, int y1,
-// int x2, int y2) {
-// // Create the rectangle.
-// Element polyline = document.createElementNS(svgNs, "polyline");
-// //polyline.setAttributeNS(null,"class", "Connect");
-// polyline.setAttributeNS(null, "points", x1+","+y1+" "+x2+","+y2);
-// polyline.setAttributeNS(null, "stroke", "black");
-// polyline.setAttributeNS(null, "stroke-width", "2");
-//// polygon.setAttributeNS(null, "points",
-//// ""+ (midX-COMMON_LENGTH) +","+midY+" " +
-//// ""+ (midX+(COMMON_LENGTH/2)) +","+midY+" " +
-//// ""+ (midX+COMMON_LENGTH) +","+(midY-COMMON_LENGTH)+" " +
-//// ""+ (midX+(COMMON_LENGTH/2)) +","+(midY-COMMON_LENGTH*2)+" " +
-//// ""+ (midX-COMMON_LENGTH) +","+(midY-COMMON_LENGTH*2)+" " +
-//// ""+ (midX-(COMMON_LENGTH/2)) +","+(midY-COMMON_LENGTH)+" "
-//// );
-// //polyline.setAttributeNS(null, "fill", "purple");
-// //rectangle.setAttributeNS(null, "alignment-baseline", "central");
-//
-// return polyline;
-// }
public Element addElement(Document document, String svgNs,
Reference aReference, Service aService){
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.setAttributeNS(null,"class", "Connect");
- polyline.setAttributeNS(null, "points", aReference.getxCoordinate()+","+
- aReference.getyCoordinate()+" "+aService.getxCoordinate()+","+
- aService.getyCoordinate());
+ polyline.setAttributeNS(null, "points", x1+","+
+ y1+" "+x2+","+y2
+ );
polyline.setAttributeNS(null, "stroke", "black");
polyline.setAttributeNS(null, "stroke-width", "2");
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java
index b4f425aeed..6b01b16a48 100755
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java
@@ -1,16 +1,188 @@
package org.apache.tuscany.sca.impl.diagram;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import org.apache.batik.dom.svg.SVGDOMImplementation;
+import org.apache.tuscany.sca.impl.artifacts.Component;
+import org.apache.tuscany.sca.impl.artifacts.Composite;
+import org.apache.tuscany.sca.impl.artifacts.Property;
+import org.apache.tuscany.sca.impl.artifacts.Reference;
+import org.apache.tuscany.sca.impl.artifacts.Service;
+import org.apache.tuscany.sca.impl.artifacts.Text;
+import org.apache.tuscany.sca.impl.artifacts.Wire;
import org.apache.tuscany.sca.impl.layout.Entity;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
public class DiagramGenerator {
Entity[] entities;
+ int height, width;
+ Document doc;
+ String compositeName;
+ String svgNS ;
+ Element svgRoot;
+ ArrayList<Reference> refs= new ArrayList<Reference>();
+ ArrayList<Service> sers= new ArrayList<Service>();
- public DiagramGenerator(Entity[] entities) {
+ public DiagramGenerator(Entity[] entities, int height, int width, String compositeName) {
this.entities = entities;
+ this.height = height;
+ this.width = width;
+ this.compositeName = compositeName;
}
+ 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();
+
+ addComposite();
+ for(Entity ent: entities){
+ addComponent(ent);
+ addService(ent);
+ addReference(ent);
+ addProperties(ent);
+ }
+
+ for(Entity ent: entities){
+ for(Iterator it= ent.getReferenceToServiceMap().entrySet().iterator();it.hasNext();){
+ Entry entry = (Entry) it.next();
+ String ref = (String)entry.getKey();
+ String ser = (String)entry.getValue();
+
+ Reference r = getRef(ref);
+ Service s = getSer(ser);
+
+ if(r != null && s != null){
+ addWire(r,s);
+ }
+ }
+ }
+ return doc;
+ }
+ private void addWire(Reference r, Service s) {
+
+ Wire edge = new Wire();
+ Element wire = edge.addElement(doc, svgNS, r, s);
+ svgRoot.appendChild(wire);
+ }
+
+ private Service getSer(String ser) {
+
+ for(Service s: sers){
+ if(s.getContainerName().equals(ser) || s.getName().equals(ser)){
+ return s;
+ }
+ }
+ return null;
+ }
+
+ private Reference getRef(String ref) {
+
+ for(Reference r: refs){
+ if(r.getContainerName().equals(ref) || r.getName().equals(ref)){
+ return r;
+ }
+ }
+ return null;
+ }
+
+ private void addProperties(Entity ent) {
+ int propLen = ent.getPropLength();
+ int x=ent.getX()+Property.SPACING;
+ int y= ent.getY()-propLen/2;
+
+ for(String prop: ent.getProperties()){
+ Property pro = new Property();
+ Element property = pro.addElement(doc, svgNS, x, y, propLen);
+ Element text = Text.addTextElement(doc, svgNS, x, y, prop);
+
+ svgRoot.appendChild(property);
+ svgRoot.appendChild(text);
+
+ x += (propLen + Property.SPACING);
+
+ pro.setName(prop);
+ pro.setContainerName(ent.getComponentName());
+ }
+ }
+
+ private void addReference(Entity ent) {
+ int refHeight = ent.getRefHeight();
+ int x=(ent.getX()+ent.getWidth())-(refHeight*2/3);
+ int y=ent.getY()+Reference.SPACING;
+
+ for(String ref: ent.getReferences()){
+ Reference refer= new Reference();
+ Element polygon = refer.addElement(doc, svgNS, x, y, refHeight);
+ Element text = Text.addTextElement(doc, svgNS, x, y+refHeight/2, ref);
+ svgRoot.appendChild(polygon);
+ svgRoot.appendChild(text);
+
+ y += (refHeight + Reference.SPACING);
+
+ refer.setName(ref);
+ refer.setContainerName(ent.getComponentName());
+ refs.add(refer);
+
+ }
+ }
+
+ private void addService(Entity ent) {
+ int serHeight = ent.getSerHeight();
+ int x=ent.getX()-(serHeight*2/3);
+ int y=ent.getY()+Service.SPACING;
+
+ for(String ser: ent.getServices()){
+ Service serve= new Service();
+ Element polygon = serve.addElement(doc, svgNS, x, y, serHeight);
+ Element text = Text.addTextElement(doc, svgNS, x, y+serHeight/2, ser);
+ svgRoot.appendChild(polygon);
+ svgRoot.appendChild(text);
+
+ y += (serHeight + Service.SPACING);
+
+ serve.setName(ser);
+ serve.setContainerName(ent.getComponentName());
+ sers.add(serve);
+ }
+ }
+
+ private void addComponent(Entity ent) {
+
+ Component comp = new Component();
+ Element com = comp.addElement(doc, svgNS, ent.getX(), ent.getY(),
+ ent.getHeight(), ent.getWidth());
+ Element text = Text.addTextElement(doc, svgNS, ent.getX()+(ent.getWidth()/4),
+ ent.getY()+(ent.getHeight()+Component.TEXT_SPACING), ent.getComponentName());
+
+ svgRoot.appendChild(com);
+ svgRoot.appendChild(text);
+
+ comp.setName(ent.getComponentName());
+ }
+
+ private void addComposite() {
+
+ Composite composite = new Composite();
+ Element composi = composite.addElement(doc, svgNS, 0, 0, height, width);
+ Element text = Text.addTextElement(doc, svgNS, width/2, 20, compositeName);
+
+ svgRoot.appendChild(composi);
+ svgRoot.appendChild(text);
+
+ composite.setName(compositeName);
+
+
+ }
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLReader.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLReader.java
index 92099a7104..e90777161a 100755
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLReader.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLReader.java
@@ -1,13 +1,8 @@
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 {
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLWriter.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLWriter.java
new file mode 100755
index 0000000000..cdd3941335
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/io/XMLWriter.java
@@ -0,0 +1,27 @@
+package org.apache.tuscany.sca.impl.io;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Document;
+
+public class XMLWriter {
+
+ public void fileWriter(Document doc, File outFile) throws Exception{
+
+ FileWriter fileWriter = new FileWriter(outFile);
+ BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+ DOMSource source = new DOMSource(doc);
+ StreamResult result = new StreamResult(bufferedWriter);
+ transformer.transform(source, result);
+
+ }
+}
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/Entity.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/Entity.java
index a9716146bb..0ae87d8816 100755
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/Entity.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/Entity.java
@@ -12,14 +12,13 @@ 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=-1, lane=-1, refHeight, serHeight, propLength;
-
+ private final int height= Component.DEFAULT_HEIGHT, width= Component.DEFAULT_WIDTH;
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);
@@ -178,6 +177,7 @@ public class Entity {
public void setServices(ArrayList<String> services) {
this.services = services;
}
+
public ArrayList<String> getServices() {
return services;
}
@@ -217,6 +217,10 @@ public class Entity {
public ArrayList<String> getRefProperties() {
return refProperties;
}
+
+ public ArrayList<String> getReferences() {
+ return references;
+ }
public void setRefProperties(ArrayList<String> refProperties) {
this.refProperties = refProperties;
@@ -258,4 +262,12 @@ public class Entity {
return connectedEntities;
}
+ public int getHeight() {
+ return height;
+ }
+
+ public int getWidth() {
+ return width;
+ }
+
}
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java
index 75dd21f5c3..156d5676e5 100755
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/EntityBuilder.java
@@ -2,23 +2,23 @@ package org.apache.tuscany.sca.impl.layout;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
-
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 initPoint = 100;//initial point
private final int spaceX = Component.DEFAULT_WIDTH*2;
private final int spaceY = Component.DEFAULT_HEIGHT*2;
private ArrayList<Integer> levelCount = new ArrayList<Integer>();//keeps track of levels used in lanes
private HashMap<String, ArrayList<String>> connectedEntities = new HashMap<String, ArrayList<String>>();
- public final int totalLength=0, totalHeight=0;
+ private int totalWidth=0;
+ private int totalHeight=0;
+ private Entity startEnt = null;
+ private String compositeName;
public EntityBuilder(Document aDom){
dom = aDom;
@@ -28,6 +28,8 @@ public class EntityBuilder {
Entity[] elts = null;
//get the root element
Element docEle = dom.getDocumentElement();
+ compositeName = docEle.getAttribute("name");
+ System.out.println("compositeName "+compositeName);
//get a nodelist of elements
NodeList nl = docEle.getElementsByTagName("component");
@@ -47,51 +49,36 @@ public class EntityBuilder {
}
}
- // //get a nodelist of elements
- // NodeList nl2 = docEle.getElementsByTagName("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;
- // }
- // }
- // }
- // }
-
- //correctMap(elts);
-
positionEntities(elts);
+ calculateProperties(elts);
print(elts);
return elts;
}
- // private void correctMap(Entity[] elts) {
- //
- // for(Entity ent: elts){
- // for(Iterator it=ent.getReferenceToServiceMap().values().iterator();it.hasNext();){
- // String target = (String)it.next();
- // if(target.startsWith("#")){
- // for(Entity e: elts){
- // if(e.getComponentName().equals(target.substring(1))){
- //
- // }
- // }
- // }
- // }
- // }
- // }
+ private void calculateProperties(Entity[] elts) {
+ int level=0, lane=0;
+
+ for(Entity ent: elts){
+ level = max(level, ent.getLevel());
+ lane = max(lane, ent.getLane());
+
+ }
+ totalHeight += spaceY*(level+1) + initPoint;
+ totalWidth += spaceX*(lane+1) + initPoint;
+
+ System.err.println(totalHeight + " :: "+totalWidth);
+ }
+
+ private int max(int a, int b){
+ if(a>=b)
+ return a;
+ return b;
+ }
+
private void print(Entity[] elts) {
for(Entity ent: elts){
@@ -101,7 +88,7 @@ public class EntityBuilder {
}
private void positionEntities(Entity[] ents){
- Entity startEnt = null;
+
for(Entity ent: ents){
if(ent.getAdjacentEntities().size() != 0 || ents.length==1){
setPosition(ent, initPoint, initPoint, 0, 0);
@@ -112,31 +99,19 @@ public class EntityBuilder {
}
}
-// for(Entity ent: ents){
-// if(ent != startEnt){
-// assignPosition(ent, ents);
-// }
-// }
if(startEnt != null)
assignPositions(ents, startEnt);
}
- private void assignPosition(Entity ent, Entity[] ents) {
-
-
- }
-
private void assignPositions(Entity[] ents, Entity ent){
int i=0;
-
- //for(Entity ent: ents){
+ if(ent.getAdjacentEntities().size()>0){
- if(ent.getAdjacentEntities().size()>0){
- System.out.println(ent.getComponentName());
+ System.out.println(ent.getComponentName());
for(String name: ent.getAdjacentEntities()){
- System.out.println("eee "+name);
+ //System.out.println("eee "+name);
for(Entity aEnt: ents){
i++;
if(name.equalsIgnoreCase(aEnt.getComponentName())){
@@ -150,7 +125,7 @@ public class EntityBuilder {
levelCount.add(lane, level+1);
setPosition(aEnt, ent.getX()+spaceX, ent.getY()+spaceY*level, level, lane);
}
- if(i<ents.length)
+ if(i<ents.length)
assignPositions(ents, aEnt);
break;
}
@@ -158,42 +133,30 @@ public class EntityBuilder {
}
}
}
-
- //}
-
- else{
- ArrayList<String> conns = connectedEntities.get(ent.getComponentName());
- System.err.println(conns.size());
- if(conns.size()>0){
-
- for(String conn: conns){
- System.err.println("conn "+conn +" : "+ent.getComponentName());
+
+
+ else{
+ ArrayList<String> conns = connectedEntities.get(ent.getComponentName());
+ System.err.println(conns.size());
+ if(conns.size()>0){
+
+ for(String conn: conns){
+ System.err.println("conn "+conn +" : "+ent.getComponentName());
for(Entity e: ents){
if(e.getLane() == -1 && e.getComponentName().equals(conn)){
-
+
int lane = ent.getLane()-1;
System.err.println(lane);
int level = levelCount.get(lane);
levelCount.add(lane, level+1);
setPosition(e, ent.getX()-spaceX, ent.getY()+spaceY*level, level, lane);
-
-// if(levelCount.size()<= lane){
-// 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);
-// }
-// System.err.println(e.getComponentName());
-// assignPositions(ents, e);
+
break;
}
}
- }
}
}
+ }
}
private void setPosition(Entity ent, int x, int y, int level, int lane){
@@ -223,9 +186,8 @@ public class EntityBuilder {
addToConnectedEntities(target.split("/")[0], ent.getComponentName());
}
else if(!target.equals("")){
- //adding a #, since this is not the name of the service
- //but the component which has only one service
- ent.addToRefToSerMap(ref, "#"+target);
+
+ ent.addToRefToSerMap(ref, target);
ent.addAnAdjacentEntity(target);
addToConnectedEntities(ent.getComponentName(), target);
addToConnectedEntities(target, ent.getComponentName());
@@ -274,6 +236,22 @@ public class EntityBuilder {
}
}
+ public void setCompositeName(String compositeName) {
+ this.compositeName = compositeName;
+ }
+
+ public String getCompositeName() {
+ return compositeName;
+ }
+
+ public int getTotalWidth() {
+ return totalWidth;
+ }
+
+ public int getTotalHeight() {
+ return totalHeight;
+ }
+
}
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/Main.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/Main.java
index 24ec643779..813549a0a8 100755
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/Main.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/Main.java
@@ -1,10 +1,16 @@
package org.apache.tuscany.sca.main;
+import java.io.File;
+
+import org.apache.tuscany.sca.impl.diagram.DiagramGenerator;
import org.apache.tuscany.sca.impl.io.XMLReader;
+import org.apache.tuscany.sca.impl.io.XMLWriter;
+import org.apache.tuscany.sca.impl.layout.Entity;
import org.apache.tuscany.sca.impl.layout.EntityBuilder;
import org.w3c.dom.Document;
public class Main {
+ private static final String outFileDir = System.getProperty("user.dir")+"/output/";
/**
* @param args
@@ -15,8 +21,12 @@ public class Main {
XMLReader reader = new XMLReader();
Document doc =reader.parseXMLFile(System.getProperty("user.dir")+"/input/composite2.xml");
EntityBuilder eb = new EntityBuilder(doc);
- eb.buildEntities();
-
+ Entity[] ents =eb.buildEntities();
+ DiagramGenerator dg = new DiagramGenerator(ents, eb.getTotalHeight(), eb.getTotalWidth(), eb.getCompositeName());
+ Document svg =dg.buildSVGDocument();
+ File outFile = new File(outFileDir+eb.getCompositeName()+"_diagram.svg");
+ XMLWriter writer = new XMLWriter();
+ writer.fileWriter(svg, outFile);
}
}