tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r1171841 - in /tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main: java/org/apache/tuscany/sca/diagram/artifacts/ java/org/apache/tuscany/sca/diagram/generator/ resources/ resources/org/ resources/org/apache/ resources/org/apache...
Date Fri, 16 Sep 2011 22:45:19 GMT
Author: rfeng
Date: Fri Sep 16 22:45:18 2011
New Revision: 1171841

URL: http://svn.apache.org/viewvc?rev=1171841&view=rev
Log:
Externalize the artifact styles into CSS

Added:
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Style.java
  (with props)
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/resources/
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/resources/org/
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/resources/org/apache/
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/resources/org/apache/tuscany/
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/resources/org/apache/tuscany/sca/
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/resources/org/apache/tuscany/sca/diagram/
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/resources/org/apache/tuscany/sca/diagram/artifacts/
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/resources/org/apache/tuscany/sca/diagram/artifacts/composite-diagram.css
Modified:
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ComponentArtifact.java
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/CompositeArtifact.java
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/DashedWire.java
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ImplementationArtifact.java
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Layer.java
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/NormalWire.java
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/PropertyArtifact.java
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ReferenceArtifact.java
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ServiceArtifact.java
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Text.java
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/WireArtifact.java
    tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/generator/DiagramGenerator.java

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ComponentArtifact.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ComponentArtifact.java?rev=1171841&r1=1171840&r2=1171841&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ComponentArtifact.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ComponentArtifact.java
Fri Sep 16 22:45:18 2011
@@ -41,9 +41,10 @@ public class ComponentArtifact extends A
         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");
+//        rectangle.setAttributeNS(null, "fill", "#3D59AB");
+//        rectangle.setAttributeNS(null, "stroke", "#104E8B");
+//        rectangle.setAttributeNS(null, "fill-opacity", "0.75");
+        rectangle.setAttributeNS(null, "class", "component");
         return rectangle;
     }
 

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/CompositeArtifact.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/CompositeArtifact.java?rev=1171841&r1=1171840&r2=1171841&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/CompositeArtifact.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/CompositeArtifact.java
Fri Sep 16 22:45:18 2011
@@ -42,9 +42,10 @@ public class CompositeArtifact extends A
         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", "middle");
+//        rectangle.setAttributeNS(null, "fill", "#E5E5E5");
+//        rectangle.setAttributeNS(null, "stroke", "#919191");
+//        rectangle.setAttributeNS(null, "alignment-baseline", "middle");
+        rectangle.setAttributeNS(null, "class", "composite");
 
         return rectangle;
     }

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/DashedWire.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/DashedWire.java?rev=1171841&r1=1171840&r2=1171841&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/DashedWire.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/DashedWire.java
Fri Sep 16 22:45:18 2011
@@ -58,7 +58,9 @@ public class DashedWire extends WireArti
 
         polyline = setWireAttributes(x1, y1, x2, y2, polyline, changingFactor, color);
 
-        polyline.setAttributeNS(null, "stroke-dasharray", "3 3");
+//        polyline.setAttributeNS(null, "stroke-dasharray", "3 3");
+        polyline.setAttributeNS(null, "class", "wire dashedWire");
+
 
         return polyline;
     }

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ImplementationArtifact.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ImplementationArtifact.java?rev=1171841&r1=1171840&r2=1171841&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ImplementationArtifact.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ImplementationArtifact.java
Fri Sep 16 22:45:18 2011
@@ -45,6 +45,8 @@ public class ImplementationArtifact exte
         rectangle.setAttributeNS(null, "stroke", "black");
         rectangle.setAttributeNS(null, "stroke-width", "1");
         rectangle.setAttributeNS(null, "fill-opacity", "0.1");
+        
+        rectangle.setAttributeNS(null, "class", "implementation");
         return rectangle;
     }
 

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Layer.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Layer.java?rev=1171841&r1=1171840&r2=1171841&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Layer.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Layer.java
Fri Sep 16 22:45:18 2011
@@ -45,6 +45,7 @@ public class Layer extends Artifact {
         rectangle.setAttributeNS(null, "fill", "#E5E5D0");
         rectangle.setAttributeNS(null, "stroke", "#919191");
         rectangle.setAttributeNS(null, "alignment-baseline", "middle");
+        rectangle.setAttributeNS(null, "class", "layer");
 
         return rectangle;
     }

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/NormalWire.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/NormalWire.java?rev=1171841&r1=1171840&r2=1171841&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/NormalWire.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/NormalWire.java
Fri Sep 16 22:45:18 2011
@@ -38,6 +38,7 @@ public class NormalWire extends WireArti
         int y2 = aService.getyCoordinate() + aService.getHeight() / 2;
 
         polyline = setWireAttributes(x1, y1, x2, y2, polyline, changingFactor, color);
+        polyline.setAttributeNS(null, "class", "wire normalWire");
 
         return polyline;
     }

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/PropertyArtifact.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/PropertyArtifact.java?rev=1171841&r1=1171840&r2=1171841&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/PropertyArtifact.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/PropertyArtifact.java
Fri Sep 16 22:45:18 2011
@@ -46,6 +46,8 @@ public class PropertyArtifact extends Ar
         rectangle.setAttributeNS(null, "fill", "#EEEE00");
         rectangle.setAttributeNS(null, "stroke", "#EEC900");
         //rectangle.setAttributeNS(null, "fill-opacity", "0.75");
+        
+        rectangle.setAttributeNS(null, "class", "property");
 
         return rectangle;
     }

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ReferenceArtifact.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ReferenceArtifact.java?rev=1171841&r1=1171840&r2=1171841&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ReferenceArtifact.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ReferenceArtifact.java
Fri Sep 16 22:45:18 2011
@@ -74,6 +74,8 @@ public class ReferenceArtifact extends A
 
         polygon.setAttributeNS(null, "fill", "#BF3EFF");
         polygon.setAttributeNS(null, "stroke", "#68228B");
+        polygon.setAttributeNS(null, "class", "reference");
+
 
         return polygon;
     }

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ServiceArtifact.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ServiceArtifact.java?rev=1171841&r1=1171840&r2=1171841&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ServiceArtifact.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/ServiceArtifact.java
Fri Sep 16 22:45:18 2011
@@ -74,7 +74,7 @@ public class ServiceArtifact extends Art
 
         polygon.setAttributeNS(null, "fill", "#00CD66");
         polygon.setAttributeNS(null, "stroke", "#008B45");
-
+        polygon.setAttributeNS(null, "class", "service");
         return polygon;
     }
 

Added: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Style.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Style.java?rev=1171841&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Style.java
(added)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Style.java
Fri Sep 16 22:45:18 2011
@@ -0,0 +1,108 @@
+/*
+ * 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.diagram.artifacts;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * CSS style element
+ */
+public class Style {
+    private String css = "rect.composite {" + "          fill: #E5E5E5;"
+        + "          stroke: #919191;"
+        + "          alignment-baseline: middle;"
+        + "      }\n"
+        + "      rect.component {"
+        + "          fill: #3D59AB;"
+        + "          stroke: #104E8B;"
+        + "          fill-opacity: 0.75;"
+        + "      }\n"
+        + "      rect.property {"
+        + "          fill: #EEEE00;"
+        + "          stroke: #EEC900;"
+        + "      }\n"
+        + "      polygon.reference {"
+        + "          fill: #BF3EFF;"
+        + "          stroke: #68228B;"
+        + "      }\n"
+        + "      polygon.service {"
+        + "          fill: #00CD66;"
+        + "          stroke: #008B45;"
+        + "      }\n"
+        + "      polyline.wire {"
+        + "          stroke-width: 2;"
+        + "          fill: none;"
+        + "      }\n"
+        + "      polyline.normalWire {"
+        + "      }\n"
+        + "      polyline.dashedWire {"
+        + "          stroke-dasharray: \"3 3\";"
+        + "      }\n"
+        + "      rect.layer {"
+        + "        fill: #E5E5D0;"
+        + "        stroke: #919191;"
+        + "        alignment-baseline: middle;"
+        + "      }\n";
+
+    public Element addElement(Document document, String svgNs, String css) {
+
+        Element style = document.createElementNS(svgNs, "style");
+        style.setAttributeNS(null, "type", "text/css");
+
+        if (css != null) {
+            this.css = css;
+        }
+        try {
+            this.css = readCSS();
+        } catch (IOException e) {
+            // Ignore
+        }
+        CDATASection cdata = document.createCDATASection(this.css);
+        style.appendChild(cdata);
+
+        return style;
+    }
+
+    private String readCSS() throws IOException {
+        InputStream is = getClass().getResourceAsStream("composite-diagram.css");
+        InputStreamReader reader = new InputStreamReader(is, "UTF-8");
+
+        StringWriter sw = new StringWriter();
+        char[] buf = new char[4096];
+        while (true) {
+            int size = reader.read(buf);
+            if (size < 0) {
+                break;
+            } else {
+                sw.write(buf, 0, size);
+            }
+        }
+        reader.close();
+        return sw.toString();
+
+    }
+}

Propchange: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Style.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Style.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Text.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Text.java?rev=1171841&r1=1171840&r2=1171841&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Text.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/Text.java
Fri Sep 16 22:45:18 2011
@@ -32,7 +32,7 @@ public class Text {
         text.setAttributeNS(null, "dominant-baseline", "mathematical");
         text.setAttributeNS(null, "font-size", "15");
         text.setTextContent(content);
-
+        text.setAttributeNS(null, "class", "name");
         return text;
     }
 }

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/WireArtifact.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/WireArtifact.java?rev=1171841&r1=1171840&r2=1171841&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/WireArtifact.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/artifacts/WireArtifact.java
Fri Sep 16 22:45:18 2011
@@ -79,6 +79,8 @@ public abstract class WireArtifact {
         polyline.setAttributeNS(null, "stroke", color);
         polyline.setAttributeNS(null, "stroke-width", "2");
         polyline.setAttributeNS(null, "fill", "none");
+        
+        polyline.setAttributeNS(null, "class", "wire");
 
         return polyline;
     }

Modified: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/generator/DiagramGenerator.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/generator/DiagramGenerator.java?rev=1171841&r1=1171840&r2=1171841&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/generator/DiagramGenerator.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/generator/DiagramGenerator.java
Fri Sep 16 22:45:18 2011
@@ -35,6 +35,7 @@ import org.apache.tuscany.sca.diagram.ar
 import org.apache.tuscany.sca.diagram.artifacts.PropertyArtifact;
 import org.apache.tuscany.sca.diagram.artifacts.ReferenceArtifact;
 import org.apache.tuscany.sca.diagram.artifacts.ServiceArtifact;
+import org.apache.tuscany.sca.diagram.artifacts.Style;
 import org.apache.tuscany.sca.diagram.artifacts.Text;
 import org.apache.tuscany.sca.diagram.artifacts.WireArtifact;
 import org.apache.tuscany.sca.diagram.layout.ComponentEntity;
@@ -112,6 +113,8 @@ public class DiagramGenerator {
 
         svgRoot.setAttributeNS(null, "viewBox", "0 0 " + getDiagramWidth() + " " + getDiagramHeight());
 
+        svgRoot.appendChild(new Style().addElement(doc, svgNS, null));
+
         addLayer();
         addComposite();
 
@@ -319,15 +322,10 @@ public class DiagramGenerator {
 
             Element child = property;
             if (baseURL != null) {
-                Element link = doc.createElementNS(svgNS, "a");
-                link.setAttributeNS(XLINK_NS, "xlink:href", baseURL + "/components/"
-                    + ent.getName()
-                    + "/properties/"
-                    + prop);
-                link.appendChild(property);
-                child = link;
+                String url = baseURL + "/components/" + ent.getName() + "/properties/" +
prop;
+                child = createLink(property, url);
             }
-            
+
             svgRoot.appendChild(child);
             svgRoot.appendChild(text);
 
@@ -350,13 +348,8 @@ public class DiagramGenerator {
 
             Element child = polygon;
             if (baseURL != null) {
-                Element link = doc.createElementNS(svgNS, "a");
-                link.setAttributeNS(XLINK_NS, "xlink:href", baseURL + "/components/"
-                    + ent.getName()
-                    + "/services/"
-                    + ref);
-                link.appendChild(polygon);
-                child = link;
+                String url = baseURL + "/components/" + ent.getName() + "/services/" + ref;
+                child = createLink(polygon, url);
             }
 
             Element text = Text.addTextElement(doc, svgNS, x, y - Constant.SPACING_FOR_TEXT,
ref);
@@ -481,13 +474,8 @@ public class DiagramGenerator {
 
             Element child = polygon;
             if (baseURL != null) {
-                Element link = doc.createElementNS(svgNS, "a");
-                link.setAttributeNS(XLINK_NS, "xlink:href", baseURL + "/components/"
-                    + ent.getName()
-                    + "/services/"
-                    + ser);
-                link.appendChild(polygon);
-                child = link;
+                String url = baseURL + "/components/" + ent.getName() + "/services/" + ser;
+                child = createLink(polygon, url);
             }
 
             svgRoot.appendChild(child);
@@ -601,10 +589,8 @@ public class DiagramGenerator {
 
         Element component = com;
         if (baseURL != null) {
-            Element link = doc.createElementNS(svgNS, "a");
-            link.setAttributeNS(XLINK_NS, "xlink:href", baseURL + "/components/" + ent.getName());
-            link.appendChild(com);
-            component = link;
+            String url = baseURL + "/components/" + ent.getName();
+            component = createLink(com, url);
         }
 
         Element text =
@@ -618,7 +604,7 @@ public class DiagramGenerator {
         svgRoot.appendChild(text);
 
         comp.setName(ent.getName());
-        
+
         if (ent.getImplementation() == null) {
             return;
         }
@@ -641,9 +627,20 @@ public class DiagramGenerator {
                                 ent.getY() + (ent.getHeight() / 4 + Constant.COMPONENT_TEXT_SPACING),
                                 ent.getImplementation());
         text2.setAttributeNS(null, "font-size", "10");
+        if (baseURL != null) {
+            String url = baseURL + "/components/" + ent.getName() + "/implementation";
+            implElement = createLink(implElement, url);
+        }
         svgRoot.appendChild(implElement);
         svgRoot.appendChild(text2);
-        
+
+    }
+
+    private Element createLink(Element com, String url) {
+        Element link = doc.createElementNS(svgNS, "a");
+        link.setAttributeNS(XLINK_NS, "xlink:href", url);
+        link.appendChild(com);
+        return link;
     }
 
     private void addComposite() {

Added: tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/resources/org/apache/tuscany/sca/diagram/artifacts/composite-diagram.css
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/resources/org/apache/tuscany/sca/diagram/artifacts/composite-diagram.css?rev=1171841&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/resources/org/apache/tuscany/sca/diagram/artifacts/composite-diagram.css
(added)
+++ tuscany/sca-java-2.x/trunk/modules/composite-diagram/src/main/resources/org/apache/tuscany/sca/diagram/artifacts/composite-diagram.css
Fri Sep 16 22:45:18 2011
@@ -0,0 +1,45 @@
+rect.layer {
+	fill: #E5E5D0;
+	stroke: #919191;
+	alignment-baseline: middle;
+}
+
+rect.composite {
+	fill: #E5E5E5;
+	stroke: #919191;
+	alignment-baseline: middle;
+}
+
+rect.component {
+	fill: #3D59AB;
+	stroke: #104E8B;
+	fill-opacity: 0.75;
+}
+
+rect.property {
+	fill: #EEEE00;
+	stroke: #EEC900;
+}
+
+polygon.reference {
+	fill: #BF3EFF;
+	stroke: #68228B;
+}
+
+polygon.service {
+	fill: #00CD66;
+	stroke: #008B45;
+}
+
+polyline.wire {
+	stroke-width: 2;
+	fill: none;
+}
+
+polyline.normalWire {
+	
+}
+
+polyline.dashedWire {
+	stroke-dasharray: "3 3";
+}
\ No newline at end of file



Mime
View raw message