From a8bf783d679577a3bfdf14e09dc9251c4ee258a5 Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 13 May 2011 06:03:58 +0000 Subject: TUSCANY-3496: Add Nirmal's prototype code for the composite diagram GSoC project to the collaboration area git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1102569 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tuscany/sca/impl/artifacts/Service.java | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java (limited to 'collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Service.java') 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; + } + + +} -- cgit v1.2.3