diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2011-09-16 22:45:18 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2011-09-16 22:45:18 +0000 |
commit | 6e4fab25b13f7af6b1b1fa766b111fd529a59490 (patch) | |
tree | 4497c3ada7926b91aa9245de02de60b821f07f8b /sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/generator/DiagramGenerator.java | |
parent | d877f13cb2e737db412311d9ef83d4eeeefde3c7 (diff) |
Externalize the artifact styles into CSS
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1171841 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rwxr-xr-x | sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/generator/DiagramGenerator.java | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/generator/DiagramGenerator.java b/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/generator/DiagramGenerator.java index 4c6b5d4640..b7ff1b47e7 100755 --- a/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/generator/DiagramGenerator.java +++ b/sca-java-2.x/trunk/modules/composite-diagram/src/main/java/org/apache/tuscany/sca/diagram/generator/DiagramGenerator.java @@ -35,6 +35,7 @@ import org.apache.tuscany.sca.diagram.artifacts.NormalWire; 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() { |