From c6406ddd51887ba702991e960512161a92697d5e Mon Sep 17 00:00:00 2001 From: nirmal070125 Date: Tue, 7 Jun 2011 05:17:25 +0000 Subject: Work up to date: not stable git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1132863 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/impl/artifacts/Artifact.java | 13 +++++ .../tuscany/sca/impl/artifacts/Component.java | 19 +++++-- .../tuscany/sca/impl/artifacts/Composite.java | 5 ++ .../tuscany/sca/impl/artifacts/Property.java | 32 ++++++++--- .../tuscany/sca/impl/artifacts/Reference.java | 58 ++++++++++---------- .../apache/tuscany/sca/impl/artifacts/Service.java | 62 +++++++++++++--------- 6 files changed, 126 insertions(+), 63 deletions(-) (limited to 'collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts') 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 2b3ed336f5..9a14ecf929 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 @@ -32,9 +32,22 @@ public abstract class Artifact { private String svgNs; private static final String ROUND_CORNER = "20" ; + /** + * Abstract method + * @param document DOM document + * @param svgNs namespace URI + * @param x x-coordinate + * @param y y-coordinate + * @param height height of the shape + * @param width width of the shape + * @return DOM Element + */ public abstract Element addElement(Document document, String svgNs, int x, int y, int height, int width); + public abstract Element addElement(Document document, String svgNs, + int x, int y); + public int getHeight() { return height; } 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 8af5dba7b2..8e7d20146e 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 @@ -24,8 +24,8 @@ import org.w3c.dom.Element; public class Component extends Artifact{ -// private static final String WIDTH = "200" ; -// private static final String HEIGHT = "130" ; + public static final int DEFAULT_WIDTH = 200 ; + public static final int DEFAULT_HEIGHT = 130 ; // public Element addElement(Document document, @@ -60,7 +60,9 @@ public class Component extends Artifact{ // return rectangle; // } - + /** + * Create an element with specified height and width + */ public Element addElement(Document document, String svgNs, int x, int y, int height, int width) { @@ -81,6 +83,17 @@ public class Component extends Artifact{ rectangle.setAttributeNS(null, "fill-opacity", "0.75"); return rectangle; } + + /** + * Create an element with default height and width + */ + public Element addElement(Document document, String svgNs, int x, int y) { + + return addElement(document, svgNs, x, y, DEFAULT_HEIGHT, DEFAULT_WIDTH); + + } + + } 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 539a18e768..48491efe69 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 @@ -77,6 +77,11 @@ public class Composite extends Artifact{ return rectangle; } + + //OBSOLETE + public Element addElement(Document document, String svgNs, int x, int y) { + return null; + } 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 c751db9b77..0d236ccfaa 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 @@ -24,7 +24,8 @@ import org.w3c.dom.Element; public class Property extends Artifact{ -// private static final String WIDTH = "20" ; + public static final int MAXIMUM_HEIGHT = 20 ; //default value + public static final int SPACING = 20 ; //default value // public static Element addPropertyElement(Document document, // String svgNs, int x, int y) { @@ -40,17 +41,18 @@ public class Property extends Artifact{ // return rectangle; // } - + /** + * Property is a square. + * ___ + * | | + * |___| + * + */ public Element addElement(Document document, String svgNs, int x, int y, int height, int width) { - return this.addElement(document, svgNs, x, y, height); - } - - public Element addElement(Document document, String svgNs, int x, int y, - int height) { this.setHeight(height); - this.setWidth(height); + this.setWidth(width); this.setxCoordinate(x); this.setyCoordinate(y); @@ -65,5 +67,19 @@ public class Property extends Artifact{ return rectangle; } + + + public Element addElement(Document document, String svgNs, int x, int y, + int height) { + + return addElement(document, svgNs, x, y, height, height); + } + + + public Element addElement(Document document, String svgNs, int x, int y) { + + + return addElement(document, svgNs, x, y, MAXIMUM_HEIGHT); + } } 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 5f49b39ba2..6a3f7ff9d1 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 @@ -24,6 +24,9 @@ import org.w3c.dom.Element; public class Reference extends Artifact { + public static final int MAXIMUM_HEIGHT = 30 ; //default value + public static final int SPACING = 10 ; //default value + //private static final int COMMON_LENGTH = 20 ; // public static Element addReferenceElement(Document document, String svgNs, int midX, int midY) { @@ -46,45 +49,33 @@ public class Reference extends Artifact { // } // - - public Element addElement(Document document, String svgNs, int x, int y, - int height, int width) { - return this.addElement(document, svgNs, x, y, height); - } - /** - * In a Reference the (x,y) coordinates refers to the outer edge of the polygon - * ______ - * \ \ - * \ \ ___ outer edge - * / / - * /____ / - * - * @param document - * @param svgNs - * @param x - * @param y - * @param height - * @return + * In a Reference the (x,y) coordinates refers to the top corner edge of the polygon + * (x,y)______ + * \ \ + * \ \ + * / / + * /____ / */ public Element addElement(Document document, String svgNs, int x, int y, - int height) { + int height, int width) { + this.setHeight(height); - this.setWidth(height); + this.setWidth(width); this.setxCoordinate(x); this.setyCoordinate(y); - int length = height/2; + int halfOfHeight = height/2; Element polygon = document.createElementNS(svgNs, "polygon"); polygon.setAttributeNS(null, "points", ""+ x +","+y+" " + - ""+ (x-length) +","+(y+length)+" " + - ""+ (x-length*3) +","+(y+length)+" " + - ""+ (x-length*2) +","+(y)+" " + - ""+ (x-length*3) +","+(y-length)+" " + - ""+ (x-length) +","+(y-length)+" " + ""+ (x+2*halfOfHeight) +","+(y)+" " + + ""+ (x+3*halfOfHeight) +","+(y-halfOfHeight)+" " + + ""+ (x+2*halfOfHeight) +","+(y-2*halfOfHeight)+" " + + ""+ (x) +","+(y-2*halfOfHeight)+" " + + ""+ (x+halfOfHeight) +","+(y-halfOfHeight)+" " ); polygon.setAttributeNS(null, "fill", "#BF3EFF"); @@ -92,5 +83,18 @@ public class Reference extends Artifact { return polygon; } + + + public Element addElement(Document document, String svgNs, int x, int y, + int height) { + + return this.addElement(document, svgNs, x, y, height, height*3/2); + } + + + public Element addElement(Document document, String svgNs, int x, int y) { + + return this.addElement(document, svgNs, x, y, MAXIMUM_HEIGHT); + } } 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); + + } + } -- cgit v1.2.3