From aac2d8e493accfd2d6573ec60d76770edc32010e Mon Sep 17 00:00:00 2001 From: nirmal070125 Date: Sat, 25 Jun 2011 11:27:17 +0000 Subject: git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1139524 13f79535-47bb-0310-9956-ffa450edef68 --- .../input/composite3.xml | 50 +++++++++++++++ .../output/Calculator_diagram.svg | 2 +- .../output/store_diagram.svg | 2 +- .../output/supplychain_diagram.svg | 2 +- .../CompositeDiagramGeneratorUsingBatik/pom.xml | 6 ++ .../apache/tuscany/sca/impl/artifacts/Text.java | 2 +- .../tuscany/sca/impl/diagram/DiagramGenerator.java | 73 +++++++++++++++++++++- .../tuscany/sca/impl/layout/EntityBuilder.java | 47 +++++++++++++- .../java/org/apache/tuscany/sca/main/Main.java | 2 +- 9 files changed, 178 insertions(+), 8 deletions(-) create mode 100755 collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite3.xml (limited to 'collaboration') diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite3.xml b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite3.xml new file mode 100755 index 0000000000..7d00becf2d --- /dev/null +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/input/composite3.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/Calculator_diagram.svg b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/Calculator_diagram.svg index 66318f9eb9..6ba9f5c579 100755 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/Calculator_diagram.svg +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/Calculator_diagram.svg @@ -1 +1 @@ -CalculatorCalculatorServiceComponentaddServicesubtractServicemultiplyServicedivideServiceAddServiceComponentSubtractServiceComponentMultiplyServiceComponentDivideServiceComponent \ No newline at end of file +CalculatorCalculatorServiceComponentsubtractServicedivideServicemultiplyServiceaddServiceAddServiceComponentSubtractServiceComponentMultiplyServiceComponentDivideServiceComponent \ No newline at end of file diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/store_diagram.svg b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/store_diagram.svg index eb7fece1ac..db517b9b29 100755 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/store_diagram.svg +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/store_diagram.svg @@ -1 +1 @@ -storeStoreWidgetcatalogshoppingCartshoppingTotalCatalogCatalogcurrencyConvertercurrencyCodeShoppingCartCartTotalCurrencyConverter \ No newline at end of file +storeStoreWidgetcatalogshoppingCartshoppingTotalCatalogCatalogcurrencyConvertercurrencyCodeShoppingCartCartTotalCurrencyConverter \ No newline at end of file diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/supplychain_diagram.svg b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/supplychain_diagram.svg index 6a465e70f2..cf0569359f 100755 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/supplychain_diagram.svg +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/supplychain_diagram.svg @@ -1 +1 @@ -supplychainCustomerComponentretailerRetailerComponentwarehouseWarehouseComponentshipperShipperComponentcustomer \ No newline at end of file +supplychainCustomerComponentretailerRetailerComponentwarehouseWarehouseComponentshipperShipperComponentcustomer \ No newline at end of file diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/pom.xml b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/pom.xml index 46489481ff..f7636d210f 100644 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/pom.xml +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/pom.xml @@ -98,6 +98,12 @@ test + + org.apache.tuscany.sca + tuscany-base-runtime + 2.0-SNAPSHOT + + diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Text.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Text.java index 7457084eb6..fabbf40873 100644 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Text.java +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/artifacts/Text.java @@ -31,7 +31,7 @@ public class Text { text.setAttributeNS(null, "y", y+""); text.setAttributeNS(null, "text-anchor", "middle"); text.setAttributeNS(null, "dominant-baseline", "mathematical"); - text.setAttributeNS(null, "font-size", "20"); + text.setAttributeNS(null, "font-size", "10"); text.setTextContent(content); return text; 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 af7437d494..8c86248663 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 @@ -107,6 +107,7 @@ public class DiagramGenerator { private Reference getRef(String ref) { for(Reference r: refs){ + if(r.getContainerName().equals(ref) || r.getName().equals(ref)){ return r; } @@ -139,7 +140,7 @@ public class DiagramGenerator { int x=(ent.getX()+ent.getWidth())-(refHeight*2/3); int y=ent.getY()+Reference.SPACING; - for(String ref: ent.getReferences()){ + for(String ref: setRefOrder(ent)){ Reference refer= new Reference(); Element polygon = refer.addElement(doc, svgNS, x, y, refHeight); Element text = Text.addTextElement(doc, svgNS, x, y+refHeight/2, ref); @@ -155,6 +156,69 @@ public class DiagramGenerator { } } + private String[] setRefOrder(Entity e){ + + ArrayList refs = e.getReferences(); + ArrayList sers = new ArrayList(); + String[] orderedRefs = new String[refs.size()]; + + for(int i=0;i levelCount = new ArrayList();//keeps track of levels used in lanes + //components connected to each other are tracked using following map private HashMap> connectedEntities = new HashMap>(); private int totalWidth=0; private int totalHeight=0; private Entity startEnt = null; private String compositeName; + /** + * Constructor which initiates the DOM document + * @param aDom DOM document + */ public EntityBuilder(Document aDom){ dom = aDom; } + /** + * Layout Building Algorithm + * ~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * An Entity object represents a component element of a composite XML. + * Here we position (i.e. assigning a level and a lane) all such components + * in a unique cell of a grid. + * + * lane0 lane1 lane2 lane3 .... + * _______________________________ + * level0 | | | | | + * |_______|_______|_______|_______| + * level1 | | | | | + * |_______|_______|_______|_______| + * level2 | | | | | + * + * 1) Determining the Entity at level0, lane0 (starting entity) + * -First Entity in the list of Entities which has one or more adjacent Entities + * -If there is only one Entity it will eventually chosen + * + * 2) Get adjacent Entities of starting Entity. + * * If there are adjacent entities; + * *For each adjacent Entity; + * + * + * @return + */ public Entity[] buildEntities(){ Entity[] elts = null; //get the root element @@ -146,6 +178,8 @@ public class EntityBuilder { } if(i 0 ) { + for(int i = 0 ; i < nl1.getLength();i++) { + Element elt = (Element)nl1.item(i); + System.out.println(elt.getAttribute("class")); + String serName = elt.getAttribute("class").split("\\.")[1]; + ent.addAService(serName); + } + } + } private void setProperties(Element nVal, Entity 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 6f8f047adc..3f62f38cb5 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/composite2.xml"); + Document doc =reader.parseXMLFile(System.getProperty("user.dir")+"/input/composite3.xml"); EntityBuilder eb = new EntityBuilder(doc); Entity[] ents =eb.buildEntities(); DiagramGenerator dg = new DiagramGenerator(ents, eb.getTotalHeight(), eb.getTotalWidth(), eb.getCompositeName()); -- cgit v1.2.3