From 6bbfb01ef30081f9c7ec6b9d4b41facef5090578 Mon Sep 17 00:00:00 2001 From: nirmal070125 Date: Mon, 15 Aug 2011 14:55:26 +0000 Subject: HTMLWrapper is modified, and avoided the use of Canvg. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1157868 13f79535-47bb-0310-9956-ffa450edef68 --- .../output/MyValueComposite2_diagram.html | 14 +---- .../output/store_diagram.html | 14 +---- .../apache/tuscany/sca/impl/html/HTMLWrapper.java | 59 +++++++++++++++++----- .../java/org/apache/tuscany/sca/main/Main.java | 21 +++++++- 4 files changed, 66 insertions(+), 42 deletions(-) (limited to 'collaboration') diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/MyValueComposite2_diagram.html b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/MyValueComposite2_diagram.html index ae6b2d49fa..0c91f6ae0a 100755 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/MyValueComposite2_diagram.html +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/MyValueComposite2_diagram.html @@ -3,20 +3,8 @@

Apache Tuscany - Composite Diagram Generator

MyValueComposite2


- - - - - +MyValueComposite2MyValueServiceComponentcurrencymyValueServicestockQuoteServicecustomerServiceStockQuoteMediatorComponentcurrencySQMediatorstockQuoteServiceSubtractServiceComponentSubtractServiceMultiplyServiceComponentMultiplyServicecurrencyMyValueServiceCustomerServiceStockQuoteServiceIncluded Composites store , Calculator , supplychain , \ No newline at end of file diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/store_diagram.html b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/store_diagram.html index 16b72202ac..9be38f99ad 100755 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/store_diagram.html +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/store_diagram.html @@ -3,20 +3,8 @@

Apache Tuscany - Composite Diagram Generator

store


- - - - - +storeStoreWidgetcatalogshoppingCartshoppingTotalCatalogcurrencyCodeCatalogcurrencyConverterShoppingCartCartTotalCurrencyConverterCurrencyConverter \ No newline at end of file diff --git a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/html/HTMLWrapper.java b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/html/HTMLWrapper.java index f286f050b8..076e28fd70 100755 --- a/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/html/HTMLWrapper.java +++ b/collaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/html/HTMLWrapper.java @@ -22,6 +22,15 @@ package org.apache.tuscany.sca.impl.html; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; +import java.io.StringWriter; + +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.w3c.dom.Document; public class HTMLWrapper { @@ -30,6 +39,7 @@ public class HTMLWrapper { private String compositeName; private String svgFileName; private int compositeHeight, compositeWidth; + private Document svg; private static final String CANVG_LIB_DIR = System.getProperty("user.dir")+"/resources/"; private static final String CANVG_FILE = "canvg-1.0.js"; private static final String RGB_FILE = "rgbcolor.js"; @@ -42,9 +52,10 @@ public class HTMLWrapper { * @param compositeWidth * @param htmlFilePath */ - public HTMLWrapper(String compositeName, String svgFileName, + public HTMLWrapper(Document svg, String compositeName, String svgFileName, int compositeHeight, int compositeWidth, File htmlFilePath) { + this.svg = svg; this.compositeName = compositeName; this.svgFileName = svgFileName; this.compositeHeight = compositeHeight; @@ -59,27 +70,47 @@ public class HTMLWrapper { "

Apache Tuscany - Composite Diagram Generator

\n" + "

"+compositeName+"

\n" + "
\n" + - "\n" + - "\n" + - "\n" + +// "\n" + +// "\n" + +// "\n" + "\n" + "\n" + - "\n" + - "\n" + + extractSvg()+"\n"+ +// "\n" + +// "\n" + "\n" + ""; fileWriter(content); } + + public String extractSvg() throws Exception{ + + // Set up the output transformer + TransformerFactory transfac = TransformerFactory.newInstance(); + Transformer trans = transfac.newTransformer(); + + // Print the DOM node + + StringWriter sw = new StringWriter(); + StreamResult result = new StreamResult(sw); + DOMSource source = new DOMSource(svg); + trans.transform(source, result); + String svgString = sw.toString(); + + System.out.println(svgString); + + return svgString; + } private void fileWriter(String content) throws Exception{ 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 ce1d6600b9..191d98b6b7 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 @@ -37,9 +37,26 @@ public class Main { * @throws Exception */ public static void main(String[] args) throws Exception { + +// if(args.length == 0){ +// +// String help = "" + +// "----------Apache Tuscany Composite Diagram Generator----------\n" + +// "\n" + +// "Error: You have not specified an input \"Composite XML\" file.\n" + +// "\n" + +// "-----------------------------Help-----------------------------\n" + +// "You have 3 options:\n" + +// "---1) Default: Specify \"Composite XML\" file paths separated \n" + +// "--- by a space, with no arguments.\n" + +// "--- Eg: java CompositeDiagramGenerator \\a\\aa\\a.composite \\b\\b\\b.composite \n" + +// "---" + +// "---2) SVG Only"; +// System.out.println(); +// } XMLReader reader = new XMLReader(); - Document doc =reader.parseXMLFile(System.getProperty("user.dir")+"/input/composite2.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(); @@ -52,7 +69,7 @@ public class Main { writer.fileWriter(svg, svgFile); File htmlFile = new File(outFileDir + comp.getName()+ comp.getFileNameSuffix()+".html"); - HTMLWrapper html = new HTMLWrapper(comp.getName(), svgFileName, dg.getDiagramHeight(), + HTMLWrapper html = new HTMLWrapper(svg, comp.getName(), svgFileName, dg.getDiagramHeight(), dg.getDiagramWidth(), htmlFile); html.buildHTML(); } -- cgit v1.2.3