diff options
author | nirmal070125 <nirmal070125@13f79535-47bb-0310-9956-ffa450edef68> | 2011-08-12 02:55:15 +0000 |
---|---|---|
committer | nirmal070125 <nirmal070125@13f79535-47bb-0310-9956-ffa450edef68> | 2011-08-12 02:55:15 +0000 |
commit | 27a316faa2427a503d71f8f5d990b02ceed7212e (patch) | |
tree | 5aa2f80b9750cf52ae07658f6d6172097c11bfe4 /collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram | |
parent | 0ad58ea612b11983efbb44064fb4a2b9fcda03c3 (diff) |
added an algorithm (1 line) to make compositeArtifacts lie in center, and fixed a possible bug in layout algo
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1156944 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram')
-rwxr-xr-x | collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java index 07c781f3e4..544ce37a2f 100755 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/diagram/DiagramGenerator.java @@ -449,10 +449,13 @@ public class DiagramGenerator { int serHeight = comp.getSerHeight(); int x= comp.getX()-(serHeight*2/3); - int y= comp.getY() + Constant.SPACING_FOR_COMPOSITE_OF_SERVICE; + int y= comp.getY() + getStartingPoint(comp.getHeight(), serHeight, Constant.SPACING_FOR_COMPOSITE_OF_SERVICE, + comp.getServices().size()); + + //int y= comp.getY() + Constant.SPACING_FOR_COMPOSITE_OF_SERVICE; - System.err.println(serHeight); - System.out.println("''''''"+((CompositeEntity)comp).getName() +" '''''' "+ comp.getServices().size()); + //System.err.println(serHeight); + //System.out.println("''''''"+((CompositeEntity)comp).getName() +" '''''' "+ comp.getServices().size()); for(String ser: comp.getServices()){ ServiceArtifact serve= new ServiceArtifact(); @@ -477,8 +480,10 @@ public class DiagramGenerator { private void addCompositeReference() { int refHeight = comp.getRefHeight(); + int x=(comp.getX()+comp.getWidth())-(refHeight*2/3); - int y=comp.getY() + Constant.SPACING_FOR_COMPOSITE_OF_REFERENCE; + int y= comp.getY() + getStartingPoint(comp.getHeight(), refHeight, Constant.SPACING_FOR_COMPOSITE_OF_REFERENCE, + comp.getReferences().size()); for(String ref: comp.getReferences()){ ReferenceArtifact refer= new ReferenceArtifact(); @@ -497,9 +502,19 @@ public class DiagramGenerator { } + //Algorithm to position in center + private int getStartingPoint(int compDim, int artifactDim, int gap, int artifactQty) { + + int x = (compDim - artifactQty * artifactDim - (artifactQty-1) * gap ) / 2; + return x; + } + private void addCompositeProperties() { int propLen = comp.getPropLength(); - int x= comp.getX() + Constant.SPACING_FOR_COMPOSITE_OF_PROPERTY; + + int x= comp.getX() + getStartingPoint(comp.getWidth(), propLen, Constant.SPACING_FOR_COMPOSITE_OF_PROPERTY, + comp.getProperties().size()); + //int x= comp.getX() + Constant.SPACING_FOR_COMPOSITE_OF_PROPERTY; int y= comp.getY()-propLen/2; for(String prop: comp.getProperties()){ @@ -537,7 +552,7 @@ public class DiagramGenerator { CompositeArtifact composite = new CompositeArtifact(); Element composi = composite.addElement(doc, svgNS, comp.getX(), comp.getY(), comp.getHeight(), comp.getWidth()); - Element text = Text.addTextElement(doc, svgNS, comp.getX() +comp.getWidth()/2, comp.getY() +20, comp.getName()); + Element text = Text.addTextElement(doc, svgNS, comp.getX()+20, comp.getY() +20, comp.getName()); svgRoot.appendChild(composi); svgRoot.appendChild(text); |