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/Composite.java8
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/DashedWire.java83
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Layer.java16
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Link.java41
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/NormalWire.java17
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Text.java4
-rw-r--r--collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Wire.java52
7 files changed, 144 insertions, 77 deletions
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 66f99a739b..e42baa68ee 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
@@ -51,9 +51,9 @@ public class Composite extends Artifact{
return rectangle;
}
- //OBSOLETE
- public Element addElement(Document document, String svgNs, int x, int y) {
- return null;
- }
+// //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/DashedWire.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/DashedWire.java
index c9381c9d50..9fc9144f5f 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
@@ -24,54 +24,61 @@ import org.w3c.dom.Element;
public class DashedWire extends Wire{
-
- public Element addElement(Document document, String svgNs,
- Reference aReference1, Reference aReference2){
+ @Override
+ public Element addElement(Document document, String svgNs, Object a,
+ Object b, int changingFactor, String color) {
Element polyline = document.createElementNS(svgNs, "polyline");
- int x1=aReference1.getxCoordinate()+aReference1.getHeight()*3/2;
- int y1=aReference1.getyCoordinate()+aReference1.getHeight()/2;
+ int x1=0,x2=0,y1=0,y2=0;
- int x2=aReference2.getxCoordinate()+aReference2.getHeight()/2;
- int y2=aReference2.getyCoordinate()+aReference2.getHeight()/2;
- //polyline.setAttributeNS(null,"class", "Connect");
- polyline.setAttributeNS(null, "points", x1+","+
- y1+" "+x2+","+y2
- );
- polyline.setAttributeNS(null, "stroke", "black");
- polyline.setAttributeNS(null, "stroke-dasharray", "3 3");
- polyline.setAttributeNS(null, "stroke-width", "2");
+ if(a instanceof Service && b instanceof Service){
+
+ Service aService1 = (Service)a;
+ Service aService2 = (Service)b;
+
+ x1=aService1.getxCoordinate()+aService1.getHeight()*3/2;
+ y1=aService1.getyCoordinate()+aService1.getHeight()/2;
+
+ x2=aService2.getxCoordinate()+aService2.getHeight()/2;
+ y2=aService2.getyCoordinate()+aService2.getHeight()/2;
+
+ }
- return polyline;
- }
+ else if(a instanceof Reference && b instanceof Reference){
+
+ Reference aReference1 = (Reference)a;
+ Reference aReference2 = (Reference)b;
+
+ x1=aReference1.getxCoordinate()+aReference1.getHeight()*3/2;
+ y1=aReference1.getyCoordinate()+aReference1.getHeight()/2;
+
+ x2=aReference2.getxCoordinate()+aReference2.getHeight()/2;
+ y2=aReference2.getyCoordinate()+aReference2.getHeight()/2;
+
+ }
+
+ polyline = setWireAttributes(x1, y1, x2, y2, polyline, changingFactor, color);
- public Element addElement(Document document, String svgNs,
- Service aService1, Service aService2){
-
- Element polyline = document.createElementNS(svgNs, "polyline");
- int x1=aService1.getxCoordinate()+aService1.getHeight()*3/2;
- int y1=aService1.getyCoordinate()+aService1.getHeight()/2;
-
- int x2=aService2.getxCoordinate()+aService2.getHeight()/2;
- int y2=aService2.getyCoordinate()+aService2.getHeight()/2;
- //polyline.setAttributeNS(null,"class", "Connect");
- polyline.setAttributeNS(null, "points", x1+","+
- y1+" "+x2+","+y2
- );
- polyline.setAttributeNS(null, "stroke", "black");
polyline.setAttributeNS(null, "stroke-dasharray", "3 3");
- polyline.setAttributeNS(null, "stroke-width", "2");
return polyline;
}
-
- @Override
- public Element addElement(Document document, String svgNs,
- Reference aReference, Service aService) {
- // TODO Auto-generated method stub
- return null;
- }
+
+ /**
+ * <script type="text/ecmascript"><![CDATA[
+ <SCRIPT LANGUAGE="JavaScript">
+
+var test = document.open("store_diagram.svg");
+
+</SCRIPT>
+ ]]></script>
+
+<!--rect x="0" y="0" alignment-baseline="central" fill="#E5E5D0" width="1400" rx="20" ry="20" height="560" stroke="#919191"/><rect x="200" y="100" alignment-baseline="central" fill="#E5E5E5" width="1000" rx="20" ry="20" height="360" stroke="#919191"/><text x="700" font-size="20" dominant-baseline="mathematical" y="120" text-anchor="middle">
+
+<a xlink:href="store_diagram.svg" xlink:show="new">MyValueComposite2</a></text-->
+
+ */
}
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Layer.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Layer.java
index 36d3d29f20..22ec76ff09 100755
--- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Layer.java
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Layer.java
@@ -23,7 +23,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
- * Structure of a "Composite" element in SCA, as a SVG element
+ * Structure of a "Outermost layer" : not a SCA artifact
*
*/
public class Layer extends Artifact{
@@ -50,10 +50,14 @@ public class Layer extends Artifact{
return rectangle;
}
-
- //OBSOLETE
- public Element addElement(Document document, String svgNs, int x, int y) {
- return null;
- }
+ public Element addElement(Document document, String svgNs, int x, int y,
+ int height, int width, String fillColor) {
+
+ Element rect = addElement(document, svgNs, x, y, height, width);
+ rect.setAttributeNS(null, "fill", fillColor);
+
+ return rect;
+ }
+
}
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Link.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Link.java
new file mode 100755
index 0000000000..e03edfd0e2
--- /dev/null
+++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Link.java
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+/**
+ * An "a" element to link two SVG diagrams: not a SCA artifact
+ *
+ */
+public class Link {
+
+ public Element addElement(Document document, String svgNs, String fileName, String compName) {
+
+ Element link = document.createElementNS(svgNs, "a");
+ link.setAttributeNS(null, "xlink:href", fileName);
+ link.setAttributeNS(null, "xlink:show", "new");
+ link.setTextContent(" "+compName + " ,");
+
+ return link;
+ }
+
+}
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 5ceece65bc..54fe2f5d04 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
@@ -24,9 +24,12 @@ import org.w3c.dom.Element;
public class NormalWire extends Wire{
-
- public Element addElement(Document document, String svgNs,
- Reference aReference, Service aService){
+ @Override
+ public Element addElement(Document document, String svgNs, Object a,
+ Object b, int changingFactor, String color) {
+
+ Reference aReference = (Reference)a;
+ Service aService = (Service)b;
Element polyline = document.createElementNS(svgNs, "polyline");
int x1=aReference.getxCoordinate()+aReference.getHeight()*3/2;
@@ -34,12 +37,8 @@ public class NormalWire extends Wire{
int x2=aService.getxCoordinate()+aService.getHeight()/2;
int y2=aService.getyCoordinate()+aService.getHeight()/2;
- //polyline.setAttributeNS(null,"class", "Connect");
- polyline.setAttributeNS(null, "points", x1+","+
- y1+" "+x2+","+y2
- );
- polyline.setAttributeNS(null, "stroke", "black");
- polyline.setAttributeNS(null, "stroke-width", "2");
+
+ polyline = setWireAttributes(x1, y1, x2, y2, polyline, changingFactor, color);
return polyline;
}
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
index 7457084eb6..40edf226c0 100644
--- 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
@@ -29,9 +29,9 @@ public class Text {
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, "text-anchor", "middle");
text.setAttributeNS(null, "dominant-baseline", "mathematical");
- text.setAttributeNS(null, "font-size", "20");
+ text.setAttributeNS(null, "font-size", "15");
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
index 9c91ccc361..e173365f4a 100644
--- 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
@@ -23,26 +23,42 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
public abstract class Wire {
-
-
+
public abstract Element addElement(Document document, String svgNs,
- Reference aReference, Service aService); //{
+ 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");
-// Element polyline = document.createElementNS(svgNs, "polyline");
-// int x1=aReference.getxCoordinate()+aReference.getHeight()*3/2;
-// int y1=aReference.getyCoordinate()+aReference.getHeight()/2;
-//
-// int x2=aService.getxCoordinate()+aService.getHeight()/2;
-// int y2=aService.getyCoordinate()+aService.getHeight()/2;
-// //polyline.setAttributeNS(null,"class", "Connect");
-// polyline.setAttributeNS(null, "points", x1+","+
-// y1+" "+x2+","+y2
-// );
-// polyline.setAttributeNS(null, "stroke", "black");
-// polyline.setAttributeNS(null, "stroke-width", "2");
-//
-// return polyline;
-// }
+ return polyline;
+ }
}