summaryrefslogtreecommitdiffstats
path: root/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java
diff options
context:
space:
mode:
Diffstat (limited to 'collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java')
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java62
1 files changed, 37 insertions, 25 deletions
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 997ea90448..986cc1b99c 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
@@ -24,7 +24,8 @@ import org.w3c.dom.Element;
public class Service extends Artifact{
-// private static final int COMMON_LENGTH = 20 ;
+ public static final int MAXIMUM_HEIGHT = 30 ; //default value
+ public static final int SPACING = 10 ; //default value
// public static Element addServiceElement(Document document, String svgNs, int midX, int midY) {
// // Create the rectangle.
@@ -43,45 +44,32 @@ public class Service extends Artifact{
// return polygon;
// }
-
- public Element addElement(Document document, String svgNs, int x, int y,
- int height, int width) {
- return this.addElement(document, svgNs, x, y, height);
- }
-
/**
- * In a Service the (x,y) coordinates refers to the inner edge of the polygon
- * ______
+ * In a Service the (x,y) coordinates refers to the top corner edge of the polygon
+ * (x,y)______
* \ \
- * inner edge ____ \ \
+ * \ \
* / /
* /____ /
- *
- * @param document
- * @param svgNs
- * @param x
- * @param y
- * @param height
- * @return
*/
public Element addElement(Document document, String svgNs, int x, int y,
- int height) {
+ int height, int width) {
this.setHeight(height);
- this.setWidth(height);
+ this.setWidth(width);
this.setxCoordinate(x);
this.setyCoordinate(y);
- int length = height/2;
+ int halfOfHeight = height/2;
Element polygon = document.createElementNS(svgNs, "polygon");
polygon.setAttributeNS(null, "points",
""+ x +","+y+" " +
- ""+ (x-length) +","+(y-length)+" " +
- ""+ (x+length) +","+(y-length)+" " +
- ""+ (x+(length*2)) +","+y+" " +
- ""+ (x+length) +","+(y+length)+" " +
- ""+ (x-length) +","+(y+length)+" "
+ ""+ (x+2*halfOfHeight) +","+(y)+" " +
+ ""+ (x+3*halfOfHeight) +","+(y-halfOfHeight)+" " +
+ ""+ (x+2*halfOfHeight) +","+(y-2*halfOfHeight)+" " +
+ ""+ (x) +","+(y-2*halfOfHeight)+" " +
+ ""+ (x+halfOfHeight) +","+(y-halfOfHeight)+" "
);
polygon.setAttributeNS(null, "fill", "#00CD66");
@@ -90,5 +78,29 @@ public class Service extends Artifact{
return polygon;
}
+ /**
+ * Width is 3/2 times of the height
+ * @param document
+ * @param svgNs
+ * @param x
+ * @param y
+ * @param height
+ * @return
+ */
+ public Element addElement(Document document, String svgNs, int x, int y,
+ int height) {
+
+ return this.addElement(document, svgNs, x, y, height, height*3/2);
+ }
+
+ /**
+ * Use default height
+ */
+ public Element addElement(Document document, String svgNs, int x, int y) {
+
+ return this.addElement(document, svgNs, x, y, MAXIMUM_HEIGHT);
+
+ }
+
}