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')
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ComponentArtifact.java61
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/CompositeArtifact.java59
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Constant.java26
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/DashedWire.java14
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/NormalWire.java6
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/PropertyArtifact.java62
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ReferenceArtifact.java70
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ServiceArtifact.java79
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/WireArtifact.java64
9 files changed, 431 insertions, 10 deletions
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ComponentArtifact.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ComponentArtifact.java
new file mode 100755
index 0000000000..ae81ad8cda
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ComponentArtifact.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.impl.artifacts;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class ComponentArtifact extends Artifact{
+
+
+ /**
+ * Create an element with specified height and width
+ */
+ 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;
+ }
+
+ /**
+ * 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, Constant.COMPONENT_DEFAULT_HEIGHT, Constant.COMPONENT_DEFAULT_WIDTH);
+
+ }
+
+}
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/CompositeArtifact.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/CompositeArtifact.java
new file mode 100755
index 0000000000..34f3dd7fa9
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/CompositeArtifact.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+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
+ *
+ */
+public class CompositeArtifact extends Artifact{
+
+
+ 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;
+ }
+
+// //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/Constant.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Constant.java
new file mode 100755
index 0000000000..24f755616f
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Constant.java
@@ -0,0 +1,26 @@
+package org.apache.tuscany.sca.impl.artifacts;
+
+public final class Constant {
+
+ public static final int COMPONENT_DEFAULT_WIDTH = 200 ;
+ public static final int COMPONENT_DEFAULT_HEIGHT = 130 ;
+ public static final int COMPONENT_TEXT_SPACING = 20 ;
+
+ public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPONENT_OF_PROPERTY = 20 ;
+ public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPOSITE_OF_PROPERTY = 60 ;
+ public static final int SPACING_FOR_COMPONENT_OF_PROPERTY = 20 ;
+ public static final int SPACING_FOR_COMPOSITE_OF_PROPERTY = 60 ;
+
+ public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPONENT_OF_REFERENCE = 30 ;
+ public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPOSITE_OF_REFERENCE = 90 ;
+ public static final int SPACING_FOR_COMPONENT_OF_REFERENCE = 10 ;
+ public static final int SPACING_FOR_COMPOSITE_OF_REFERENCE = 30 ;
+
+ public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPONENT_OF_SERVICE = 30 ;
+ public static final int DEFAULT_MAXIMUM_HEIGHT_FOR_COMPOSITE_OF_SERVICE = 90 ;
+ public static final int SPACING_FOR_COMPONENT_OF_SERVICE = 10 ;
+ public static final int SPACING_FOR_COMPOSITE_OF_SERVICE = 30 ;
+
+
+
+}
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/DashedWire.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/DashedWire.java
index 9fc9144f5f..70c8882c2b 100755
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/DashedWire.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/DashedWire.java
@@ -22,7 +22,7 @@ package org.apache.tuscany.sca.impl.artifacts;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-public class DashedWire extends Wire{
+public class DashedWire extends WireArtifact{
@Override
public Element addElement(Document document, String svgNs, Object a,
@@ -31,10 +31,10 @@ public class DashedWire extends Wire{
Element polyline = document.createElementNS(svgNs, "polyline");
int x1=0,x2=0,y1=0,y2=0;
- if(a instanceof Service && b instanceof Service){
+ if(a instanceof ServiceArtifact && b instanceof ServiceArtifact){
- Service aService1 = (Service)a;
- Service aService2 = (Service)b;
+ ServiceArtifact aService1 = (ServiceArtifact)a;
+ ServiceArtifact aService2 = (ServiceArtifact)b;
x1=aService1.getxCoordinate()+aService1.getHeight()*3/2;
y1=aService1.getyCoordinate()+aService1.getHeight()/2;
@@ -44,10 +44,10 @@ public class DashedWire extends Wire{
}
- else if(a instanceof Reference && b instanceof Reference){
+ else if(a instanceof ReferenceArtifact && b instanceof ReferenceArtifact){
- Reference aReference1 = (Reference)a;
- Reference aReference2 = (Reference)b;
+ ReferenceArtifact aReference1 = (ReferenceArtifact)a;
+ ReferenceArtifact aReference2 = (ReferenceArtifact)b;
x1=aReference1.getxCoordinate()+aReference1.getHeight()*3/2;
y1=aReference1.getyCoordinate()+aReference1.getHeight()/2;
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/NormalWire.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/NormalWire.java
index 54fe2f5d04..517bea1980 100755
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/NormalWire.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/NormalWire.java
@@ -22,14 +22,14 @@ package org.apache.tuscany.sca.impl.artifacts;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-public class NormalWire extends Wire{
+public class NormalWire extends WireArtifact{
@Override
public Element addElement(Document document, String svgNs, Object a,
Object b, int changingFactor, String color) {
- Reference aReference = (Reference)a;
- Service aService = (Service)b;
+ ReferenceArtifact aReference = (ReferenceArtifact)a;
+ ServiceArtifact aService = (ServiceArtifact)b;
Element polyline = document.createElementNS(svgNs, "polyline");
int x1=aReference.getxCoordinate()+aReference.getHeight()*3/2;
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/PropertyArtifact.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/PropertyArtifact.java
new file mode 100755
index 0000000000..f1151f8b57
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/PropertyArtifact.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.impl.artifacts;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class PropertyArtifact extends Artifact{
+
+ /**
+ * Property is a square.
+ * ___
+ * | |
+ * |___|
+ *
+ */
+ 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, "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;
+ }
+
+
+ public Element addElement(Document document, String svgNs, int x, int y,
+ int height) {
+
+ return addElement(document, svgNs, x, y, height, height);
+ }
+
+
+}
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ReferenceArtifact.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ReferenceArtifact.java
new file mode 100755
index 0000000000..5001f4908e
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ReferenceArtifact.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.impl.artifacts;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class ReferenceArtifact extends Artifact {
+
+
+ /**
+ * 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 width) {
+
+
+ this.setHeight(height);
+ this.setWidth(width);
+ this.setxCoordinate(x);
+ this.setyCoordinate(y);
+
+ int halfOfHeight = height/2;
+
+ Element polygon = document.createElementNS(svgNs, "polygon");
+ 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)+" "
+ );
+
+ polygon.setAttributeNS(null, "fill", "#BF3EFF");
+ polygon.setAttributeNS(null, "stroke", "#68228B");
+
+ 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);
+ }
+
+}
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ServiceArtifact.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ServiceArtifact.java
new file mode 100755
index 0000000000..98ad6ee740
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/ServiceArtifact.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.impl.artifacts;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class ServiceArtifact extends Artifact{
+
+
+
+ /**
+ * In a Service 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 width) {
+
+ this.setHeight(height);
+ this.setWidth(width);
+ this.setxCoordinate(x);
+ this.setyCoordinate(y);
+
+ int halfOfHeight = height/2;
+
+ Element polygon = document.createElementNS(svgNs, "polygon");
+ 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)+" "
+ );
+
+ polygon.setAttributeNS(null, "fill", "#00CD66");
+ polygon.setAttributeNS(null, "stroke", "#008B45");
+
+ 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);
+ }
+
+
+}
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/WireArtifact.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/WireArtifact.java
new file mode 100755
index 0000000000..ef179b9a70
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/WireArtifact.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.impl.artifacts;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public abstract class WireArtifact {
+
+ public abstract Element addElement(Document document, String svgNs,
+ Object a, Object b, int changingFactor, String color);
+
+ public Element setWireAttributes(int x1, int y1, int x2, int y2,
+ Element polyline, int changingFactor, String color){
+
+ if(y1 == y2 && x2>x1){
+ polyline.setAttributeNS(null, "points", x1+","+
+ y1+" "+x2+","+y2
+ );
+ }
+ else if(y1 == y2 && x1>x2){
+ polyline.setAttributeNS(null, "points", x1+","+
+ y1+" "+(x1+changingFactor)+","+y1
+ +" "+(x1+changingFactor)+","+(y1-(changingFactor*2))
+ +" "+(x2-changingFactor)+","+(y1-(changingFactor*2))
+ +" "+(x2-changingFactor)+","+(y1)
+ +" "+(x2)+","+(y1)
+ );
+
+ }
+ else{
+ polyline.setAttributeNS(null, "points", x1+","+
+ y1+" "+(x1+changingFactor)+","+y1
+ +" "+(x1+changingFactor)+","+y2
+ +" "+x2+","+y2
+ );
+ }
+
+ polyline.setAttributeNS(null, "stroke", color);
+ polyline.setAttributeNS(null, "stroke-width", "2");
+ polyline.setAttributeNS(null, "fill", "none");
+
+ return polyline;
+ }
+
+
+}