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 | |
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 '')
3 files changed, 35 insertions, 9 deletions
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 index 79d7a2981a..a08fedfd49 100755 --- 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 @@ -14,12 +14,12 @@ public final class Constant { 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 SPACING_FOR_COMPOSITE_OF_REFERENCE = 50 ; 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 ; + public static final int SPACING_FOR_COMPOSITE_OF_SERVICE = 50 ; public static final int SPACING_FOR_TEXT = 1 ; 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); diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/LayoutBuilder.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/LayoutBuilder.java index b7c594f406..b4ea2bdaa4 100755 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/LayoutBuilder.java +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/layout/LayoutBuilder.java @@ -82,6 +82,7 @@ public class LayoutBuilder { assignPositions(startEnt); } + assignPositionsOfOtherConncetedEntities();//such as a different cluster of components assignPositionsOfIdleEntities(); assignCoordinates(); @@ -93,7 +94,17 @@ public class LayoutBuilder { for(Entity ent: elts){ if(!ent.isPossitionSet()){ - this.setPosition(ent, ++currentMaxLevel, 0); + + setPosition(ent, currentMaxLevel++, 0); + } + } + } + + private void assignPositionsOfOtherConncetedEntities() { + + for(Entity ent: elts){ + if(!ent.isPossitionSet() && isConnected(ent.getId())){ + assignPositions(ent); } } } |