summaryrefslogtreecommitdiffstats
path: root/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts
diff options
context:
space:
mode:
Diffstat (limited to 'collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts')
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Artifact.java62
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Component.java67
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Composite.java64
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Property.java50
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Reference.java77
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java75
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Text.java20
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Wire.java48
8 files changed, 463 insertions, 0 deletions
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
new file mode 100644
index 0000000000..9ba591698d
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Artifact.java
@@ -0,0 +1,62 @@
+package org.apache.tuscany.sca.impl.artifacts;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public abstract class Artifact {
+
+ 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" ;
+
+ public abstract Element addElement(Document document, String svgNs,
+ int x, int y, int height, int width);
+
+ 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;
+ }
+
+
+
+}
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
new file mode 100644
index 0000000000..a41d5b1100
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Component.java
@@ -0,0 +1,67 @@
+package org.apache.tuscany.sca.impl.artifacts;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class Component extends Artifact{
+
+// private static final String WIDTH = "200" ;
+// private static final String HEIGHT = "130" ;
+
+
+// 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;
+// }
+
+
+ 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;
+ }
+
+
+}
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
new file mode 100644
index 0000000000..b36b2f2290
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Composite.java
@@ -0,0 +1,64 @@
+package org.apache.tuscany.sca.impl.artifacts;
+
+import org.w3c.dom.Document;
+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) {
+
+ 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", "central");
+
+ return rectangle;
+ }
+
+
+
+}
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
new file mode 100644
index 0000000000..dff95520e9
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Property.java
@@ -0,0 +1,50 @@
+package org.apache.tuscany.sca.impl.artifacts;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class Property extends Artifact{
+
+// private static final String WIDTH = "20" ;
+
+// 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;
+// }
+
+
+ public Element addElement(Document document, String svgNs, int x, int y,
+ int height, int width) {
+ return this.addElement(document, svgNs, x, y, height);
+ }
+
+ public Element addElement(Document document, String svgNs, int x, int y,
+ int height) {
+
+ this.setHeight(height);
+ this.setWidth(height);
+ this.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;
+ }
+
+}
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
new file mode 100644
index 0000000000..912dc08944
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Reference.java
@@ -0,0 +1,77 @@
+package org.apache.tuscany.sca.impl.artifacts;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class Reference extends Artifact {
+
+//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;
+// }
+//
+
+
+ public Element addElement(Document document, String svgNs, int x, int y,
+ int height, int width) {
+ return this.addElement(document, svgNs, x, y, height);
+ }
+
+ /**
+ * In a Reference the (x,y) coordinates refers to the outer edge of the polygon
+ * ______
+ * \ \
+ * \ \ ___ outer edge
+ * / /
+ * /____ /
+ *
+ * @param document
+ * @param svgNs
+ * @param x
+ * @param y
+ * @param height
+ * @return
+ */
+ public Element addElement(Document document, String svgNs, int x, int y,
+ int height) {
+
+ this.setHeight(height);
+ this.setWidth(height);
+ this.setxCoordinate(x);
+ this.setyCoordinate(y);
+
+ int length = height/2;
+
+ Element polygon = document.createElementNS(svgNs, "polygon");
+ polygon.setAttributeNS(null, "points",
+ ""+ x +","+y+" " +
+ ""+ (x-length) +","+(y+length)+" " +
+ ""+ (x-length*3) +","+(y+length)+" " +
+ ""+ (x-length*2) +","+(y)+" " +
+ ""+ (x-length*3) +","+(y-length)+" " +
+ ""+ (x-length) +","+(y-length)+" "
+ );
+
+ polygon.setAttributeNS(null, "fill", "#BF3EFF");
+ polygon.setAttributeNS(null, "stroke", "#68228B");
+
+ return polygon;
+ }
+
+}
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
new file mode 100644
index 0000000000..d55d5dd9d6
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java
@@ -0,0 +1,75 @@
+package org.apache.tuscany.sca.impl.artifacts;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class Service extends Artifact{
+
+// private static final int COMMON_LENGTH = 20 ;
+
+// 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;
+// }
+
+
+ public Element addElement(Document document, String svgNs, int x, int y,
+ int height, int width) {
+ return this.addElement(document, svgNs, x, y, height);
+ }
+
+ /**
+ * In a Service the (x,y) coordinates refers to the inner edge of the polygon
+ * ______
+ * \ \
+ * inner edge ____ \ \
+ * / /
+ * /____ /
+ *
+ * @param document
+ * @param svgNs
+ * @param x
+ * @param y
+ * @param height
+ * @return
+ */
+ public Element addElement(Document document, String svgNs, int x, int y,
+ int height) {
+
+ this.setHeight(height);
+ this.setWidth(height);
+ this.setxCoordinate(x);
+ this.setyCoordinate(y);
+
+ int length = height/2;
+
+ Element polygon = document.createElementNS(svgNs, "polygon");
+ polygon.setAttributeNS(null, "points",
+ ""+ x +","+y+" " +
+ ""+ (x-length) +","+(y-length)+" " +
+ ""+ (x+length) +","+(y-length)+" " +
+ ""+ (x+(length*2)) +","+y+" " +
+ ""+ (x+length) +","+(y+length)+" " +
+ ""+ (x-length) +","+(y+length)+" "
+ );
+
+ polygon.setAttributeNS(null, "fill", "#00CD66");
+ polygon.setAttributeNS(null, "stroke", "#008B45");
+
+ return polygon;
+ }
+
+
+}
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Text.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Text.java
new file mode 100644
index 0000000000..72d3aea69c
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Text.java
@@ -0,0 +1,20 @@
+package org.apache.tuscany.sca.impl.artifacts;
+
+import org.w3c.dom.Document;
+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", "20");
+ text.setTextContent(content);
+
+ return text;
+ }
+}
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
new file mode 100644
index 0000000000..9a2a0a74b1
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Wire.java
@@ -0,0 +1,48 @@
+package org.apache.tuscany.sca.impl.artifacts;
+
+import org.w3c.dom.Document;
+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");
+ //polyline.setAttributeNS(null,"class", "Connect");
+ polyline.setAttributeNS(null, "points", aReference.getxCoordinate()+","+
+ aReference.getyCoordinate()+" "+aService.getxCoordinate()+","+
+ aService.getyCoordinate());
+ polyline.setAttributeNS(null, "stroke", "black");
+ polyline.setAttributeNS(null, "stroke-width", "2");
+
+ return polyline;
+ }
+
+
+}