From 27a316faa2427a503d71f8f5d990b02ceed7212e Mon Sep 17 00:00:00 2001 From: nirmal070125 Date: Fri, 12 Aug 2011 02:55:15 +0000 Subject: 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 --- .../input/composite.xml | 10 ++++++++ .../input/composite_with_compositeService.xml | 11 ++++++++- .../output/Calculator_diagram.svg | 2 +- .../output/MyValueComposite2_diagram.svg | 2 +- .../tuscany/sca/impl/artifacts/Constant.java | 4 ++-- .../tuscany/sca/impl/diagram/DiagramGenerator.java | 27 +++++++++++++++++----- .../tuscany/sca/impl/layout/LayoutBuilder.java | 13 ++++++++++- .../java/org/apache/tuscany/sca/main/Main.java | 2 +- 8 files changed, 58 insertions(+), 13 deletions(-) (limited to 'collaboration') diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite.xml b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite.xml index 345b9065a9..49c33cf2d8 100755 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite.xml +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite.xml @@ -45,5 +45,15 @@ + + + + + + EURO + + + + \ No newline at end of file diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite_with_compositeService.xml b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite_with_compositeService.xml index 33809ea6c3..e619d39c1c 100755 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite_with_compositeService.xml +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite_with_compositeService.xml @@ -57,6 +57,15 @@ + + + + + + + + + @@ -70,7 +79,7 @@ - + EURO CalculatorCalculatorServiceComponentCalculatorServiceaddServicesubtractServicemultiplyServicedivideServiceAddServiceComponentAddServiceSubtractServiceComponentSubtractServiceMultiplyServiceComponentMultiplyServiceDivideServiceComponentDivideService \ No newline at end of file +CalculatorCalculatorServiceComponentCalculatorServiceaddServicesubtractServicemultiplyServicedivideServiceAddServiceComponentAddServiceSubtractServiceComponentSubtractServiceMultiplyServiceComponentMultiplyServiceDivideServiceComponentDivideServiceStockQuoteMediatorComponentcurrencySQMediatorstockQuoteService \ No newline at end of file diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/MyValueComposite2_diagram.svg b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/MyValueComposite2_diagram.svg index 294a7e03df..8f2772470b 100755 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/MyValueComposite2_diagram.svg +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/MyValueComposite2_diagram.svg @@ -1 +1 @@ -MyValueComposite2MyValueServiceComponentmyValueServicestockQuoteServicecustomerServicecurrencyStockQuoteMediatorComponentSQMediatorstockQuoteServicecurrencyMyValueServiceCustomerServiceStockQuoteServiceIncluded Composites store , Calculator , supplychain , \ No newline at end of file +MyValueComposite2MyValueServiceComponentcurrencymyValueServicestockQuoteServicecustomerServiceStockQuoteMediatorComponentcurrencySQMediatorstockQuoteServiceSubtractServiceComponentSubtractServiceMultiplyServiceComponentMultiplyServicecurrencyMyValueServiceCustomerServiceStockQuoteServiceIncluded Composites store , Calculator , supplychain , \ No newline at end of file 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); } } } diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/Main.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/Main.java index 67e9a5019e..f56c88aed4 100755 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/Main.java +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/Main.java @@ -38,7 +38,7 @@ public class Main { public static void main(String[] args) throws Exception { XMLReader reader = new XMLReader(); - Document doc =reader.parseXMLFile(System.getProperty("user.dir")+"/input/composite.xml");//composite1.xml composite_with_compositeService.xml"); + Document doc =reader.parseXMLFile(System.getProperty("user.dir")+"/input/composite_with_compositeService.xml");//composite1.xml composite_with_compositeService.xml"); EntityBuilder eb = new EntityBuilder(doc); CompositeEntity comp =eb.buildCompositeEntity(); -- cgit v1.2.3