summaryrefslogtreecommitdiffstats
path: root/collaboration
diff options
context:
space:
mode:
authornirmal070125 <nirmal070125@13f79535-47bb-0310-9956-ffa450edef68>2011-08-15 14:55:26 +0000
committernirmal070125 <nirmal070125@13f79535-47bb-0310-9956-ffa450edef68>2011-08-15 14:55:26 +0000
commit6bbfb01ef30081f9c7ec6b9d4b41facef5090578 (patch)
tree7abd6af5e1070801736c13417697896c622d18e8 /collaboration
parent4f933606e0fa045116e70764dbf9d99c05484ccb (diff)
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
Diffstat (limited to 'collaboration')
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/MyValueComposite2_diagram.html14
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/output/store_diagram.html14
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/impl/html/HTMLWrapper.java59
-rwxr-xr-xcollaboration/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/src/main/java/org/apache/tuscany/sca/main/Main.java21
4 files changed, 66 insertions, 42 deletions
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 @@
<h1 align='center'>Apache Tuscany - Composite Diagram Generator</h1>
<h2 align='center'>MyValueComposite2</h2>
</br>
-<script type="text/javascript" src="/media/798D-18B1/GSoC-2011/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/resources/rgbcolor.js"></script>
-<script type="text/javascript" src="/media/798D-18B1/GSoC-2011/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/resources/canvg-1.0.js"></script>
-<script type="text/javascript">
-window.onload = function() {
-//load '../path/to/your.svg' in the canvas with id = 'canvas'
-canvg('canvas', 'MyValueComposite2_diagram.svg')
-//load a svg snippet in the canvas with id = 'drawingArea'
-canvg(document.getElementById('drawingArea'), '<svg>...</svg>')
-canvg('canvas', 'MyValueComposite2_diagram.svg', {})
-}
-</script>
</head>
<body>
-<canvas id="canvas" width="1400px" height="1080px">
-</canvas>
+<?xml version="1.0" encoding="UTF-8"?><svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" contentScriptType="text/ecmascript" zoomAndPan="magnify" contentStyleType="text/css" viewBox="0 0 1400 1080" preserveAspectRatio="xMidYMid meet" version="1.0"><rect x="0" y="0" alignment-baseline="middle" fill="#E5E5D0" width="1400" rx="20" ry="20" height="1080" stroke="#919191"/><rect x="200" y="100" alignment-baseline="middle" fill="#E5E5E5" width="1000" rx="20" ry="20" height="880" stroke="#919191"/><text x="220" font-size="15" y="120" dominant-baseline="mathematical">MyValueComposite2</text><rect x="400" y="200" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="400" font-size="15" y="350" dominant-baseline="mathematical">MyValueServiceComponent</text><rect fill="#EEEE00" x="420" width="20" height="20" y="190" stroke="#EEC900"/><text x="420" font-size="15" y="189" dominant-baseline="mathematical">currency</text><polygon fill="#00CD66" points="380,210 410,210 425,225 410,240 380,240 395,225 " stroke="#008B45"/><text x="380" font-size="15" y="209" dominant-baseline="mathematical">myValueService</text><polygon fill="#BF3EFF" points="580,210 610,210 625,225 610,240 580,240 595,225 " stroke="#68228B"/><text x="580" font-size="15" y="209" dominant-baseline="mathematical">stockQuoteService</text><polygon fill="#BF3EFF" points="580,250 610,250 625,265 610,280 580,280 595,265 " stroke="#68228B"/><text x="580" font-size="15" y="249" dominant-baseline="mathematical">customerService</text><rect x="800" y="200" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="800" font-size="15" y="350" dominant-baseline="mathematical">StockQuoteMediatorComponent</text><rect fill="#EEEE00" x="820" width="20" height="20" y="190" stroke="#EEC900"/><text x="820" font-size="15" y="189" dominant-baseline="mathematical">currency</text><polygon fill="#00CD66" points="780,210 810,210 825,225 810,240 780,240 795,225 " stroke="#008B45"/><text x="780" font-size="15" y="209" dominant-baseline="mathematical">SQMediator</text><polygon fill="#BF3EFF" points="980,210 1010,210 1025,225 1010,240 980,240 995,225 " stroke="#68228B"/><text x="980" font-size="15" y="209" dominant-baseline="mathematical">stockQuoteService</text><rect x="400" y="460" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="400" font-size="15" y="610" dominant-baseline="mathematical">SubtractServiceComponent</text><polygon fill="#00CD66" points="380,470 410,470 425,485 410,500 380,500 395,485 " stroke="#008B45"/><text x="380" font-size="15" y="469" dominant-baseline="mathematical">SubtractService</text><rect x="400" y="720" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="400" font-size="15" y="870" dominant-baseline="mathematical">MultiplyServiceComponent</text><polygon fill="#00CD66" points="380,730 410,730 425,745 410,760 380,760 395,745 " stroke="#008B45"/><text x="380" font-size="15" y="729" dominant-baseline="mathematical">MultiplyService</text><rect fill="#EEEE00" x="670" width="60" height="60" y="70" stroke="#EEC900"/><text x="670" font-size="15" y="69" dominant-baseline="mathematical">currency</text><polygon fill="#00CD66" points="140,495 230,495 275,540 230,585 140,585 185,540 " stroke="#008B45"/><text x="140" font-size="15" y="494" dominant-baseline="mathematical">MyValueService</text><polygon fill="#BF3EFF" points="1140,425 1230,425 1275,470 1230,515 1140,515 1185,470 " stroke="#68228B"/><text x="1140" font-size="15" y="424" dominant-baseline="mathematical">CustomerService</text><polygon fill="#BF3EFF" points="1140,565 1230,565 1275,610 1230,655 1140,655 1185,610 " stroke="#68228B"/><text x="1140" font-size="15" y="564" dominant-baseline="mathematical">StockQuoteService</text><polyline fill="none" stroke-width="2" points="625,225 795,225" stroke="black"/><polyline fill="none" stroke-dasharray="3 3" stroke-width="2" points="1025,225 1050,225 1050,610 1185,610" stroke="black"/><polyline fill="none" stroke-dasharray="3 3" stroke-width="2" points="625,265 655,265 655,470 1185,470" stroke="black"/><polyline fill="none" stroke-dasharray="3 3" stroke-width="2" points="1025,225 1060,225 1060,470 1185,470" stroke="black"/><polyline fill="none" stroke-dasharray="3 3" stroke-width="2" points="275,540 315,540 315,225 395,225" stroke="black"/><rect x="205" y="910" alignment-baseline="middle" fill="#E5E5C0" width="990" rx="20" ry="20" height="65" stroke="#919191"/><text x="210" font-size="15" y="920" dominant-baseline="mathematical">Included Composites</text><text x="210" font-size="15" y="945" dominant-baseline="mathematical"><a xlink:href="store_diagram.svg" xlink:actuate="onRequest" xlink:type="simple" xlink:show="new" xmlns:xlink="http://www.w3.org/1999/xlink"> store ,</a><a xlink:href="Calculator_diagram.svg" xlink:actuate="onRequest" xlink:type="simple" xlink:show="new" xmlns:xlink="http://www.w3.org/1999/xlink"> Calculator ,</a><a xlink:href="supplychain_diagram.svg" xlink:actuate="onRequest" xlink:type="simple" xlink:show="new" xmlns:xlink="http://www.w3.org/1999/xlink"> supplychain ,</a></text></svg>
</body>
</html> \ 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 @@
<h1 align='center'>Apache Tuscany - Composite Diagram Generator</h1>
<h2 align='center'>store</h2>
</br>
-<script type="text/javascript" src="/media/798D-18B1/GSoC-2011/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/resources/rgbcolor.js"></script>
-<script type="text/javascript" src="/media/798D-18B1/GSoC-2011/GSoC-2011-Nirmal/CompositeDiagramGeneratorUsingBatik/resources/canvg-1.0.js"></script>
-<script type="text/javascript">
-window.onload = function() {
-//load '../path/to/your.svg' in the canvas with id = 'canvas'
-canvg('canvas', 'store_diagram.svg')
-//load a svg snippet in the canvas with id = 'drawingArea'
-canvg(document.getElementById('drawingArea'), '<svg>...</svg>')
-canvg('canvas', 'store_diagram.svg', {})
-}
-</script>
</head>
<body>
-<canvas id="canvas" width="1800px" height="820px">
-</canvas>
+<?xml version="1.0" encoding="UTF-8"?><svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" contentScriptType="text/ecmascript" zoomAndPan="magnify" contentStyleType="text/css" viewBox="0 0 1800 820" preserveAspectRatio="xMidYMid meet" version="1.0"><rect x="0" y="0" alignment-baseline="middle" fill="#E5E5D0" width="1800" rx="20" ry="20" height="820" stroke="#919191"/><rect x="200" y="100" alignment-baseline="middle" fill="#E5E5E5" width="1400" rx="20" ry="20" height="620" stroke="#919191"/><text x="220" font-size="15" y="120" dominant-baseline="mathematical">store</text><rect x="400" y="200" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="400" font-size="15" y="350" dominant-baseline="mathematical">Store</text><polygon fill="#00CD66" points="380,210 410,210 425,225 410,240 380,240 395,225 " stroke="#008B45"/><text x="380" font-size="15" y="209" dominant-baseline="mathematical">Widget</text><polygon fill="#BF3EFF" points="580,210 610,210 625,225 610,240 580,240 595,225 " stroke="#68228B"/><text x="580" font-size="15" y="209" dominant-baseline="mathematical">catalog</text><polygon fill="#BF3EFF" points="580,250 610,250 625,265 610,280 580,280 595,265 " stroke="#68228B"/><text x="580" font-size="15" y="249" dominant-baseline="mathematical">shoppingCart</text><polygon fill="#BF3EFF" points="580,290 610,290 625,305 610,320 580,320 595,305 " stroke="#68228B"/><text x="580" font-size="15" y="289" dominant-baseline="mathematical">shoppingTotal</text><rect x="800" y="200" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="800" font-size="15" y="350" dominant-baseline="mathematical">Catalog</text><rect fill="#EEEE00" x="820" width="20" height="20" y="190" stroke="#EEC900"/><text x="820" font-size="15" y="189" dominant-baseline="mathematical">currencyCode</text><polygon fill="#00CD66" points="780,210 810,210 825,225 810,240 780,240 795,225 " stroke="#008B45"/><text x="780" font-size="15" y="209" dominant-baseline="mathematical">Catalog</text><polygon fill="#BF3EFF" points="980,210 1010,210 1025,225 1010,240 980,240 995,225 " stroke="#68228B"/><text x="980" font-size="15" y="209" dominant-baseline="mathematical">currencyConverter</text><rect x="800" y="460" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="800" font-size="15" y="610" dominant-baseline="mathematical">ShoppingCart</text><polygon fill="#00CD66" points="780,470 810,470 825,485 810,500 780,500 795,485 " stroke="#008B45"/><text x="780" font-size="15" y="469" dominant-baseline="mathematical">Cart</text><polygon fill="#00CD66" points="780,510 810,510 825,525 810,540 780,540 795,525 " stroke="#008B45"/><text x="780" font-size="15" y="509" dominant-baseline="mathematical">Total</text><rect x="1200" y="200" fill-opacity="0.75" fill="#3D59AB" width="200" rx="20" ry="20" height="130" stroke="#104E8B"/><text x="1200" font-size="15" y="350" dominant-baseline="mathematical">CurrencyConverter</text><polygon fill="#00CD66" points="1180,210 1210,210 1225,225 1210,240 1180,240 1195,225 " stroke="#008B45"/><text x="1180" font-size="15" y="209" dominant-baseline="mathematical">CurrencyConverter</text><polyline fill="none" stroke-width="2" points="625,305 645,305 645,525 795,525" stroke="black"/><polyline fill="none" stroke-width="2" points="625,265 650,265 650,485 795,485" stroke="black"/><polyline fill="none" stroke-width="2" points="625,225 795,225" stroke="black"/><polyline fill="none" stroke-width="2" points="1025,225 1195,225" stroke="black"/></svg>
</body>
</html> \ 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 {
"<h1 align='center'>Apache Tuscany - Composite Diagram Generator</h1>\n" +
"<h2 align='center'>"+compositeName+"</h2>\n" +
"</br>\n" +
- "<script type=\"text/javascript\" src=\""+CANVG_LIB_DIR+RGB_FILE+"\"></script>\n" +
- "<script type=\"text/javascript\" src=\""+CANVG_LIB_DIR+CANVG_FILE+"\"></script>\n" +
- "<script type=\"text/javascript\">\n" +
- "window.onload = function() {\n" +
- "//load '../path/to/your.svg' in the canvas with id = 'canvas'\n" +
- "canvg('canvas', '"+svgFileName+"')\n" +
- "//load a svg snippet in the canvas with id = 'drawingArea'\n" +
- "canvg(document.getElementById('drawingArea'), '<svg>...</svg>')\n" +
- "canvg('canvas', '"+svgFileName+"', {})\n" +
- "}\n" +
- "</script>\n" +
+// "<script type=\"text/javascript\" src=\""+CANVG_LIB_DIR+RGB_FILE+"\"></script>\n" +
+// "<script type=\"text/javascript\" src=\""+CANVG_LIB_DIR+CANVG_FILE+"\"></script>\n" +
+// "<script type=\"text/javascript\">\n" +
+// "window.onload = function() {\n" +
+// "//load '../path/to/your.svg' in the canvas with id = 'canvas'\n" +
+// "canvg('canvas', '"+svgFileName+"')\n" +
+// "//load a svg snippet in the canvas with id = 'drawingArea'\n" +
+// "canvg(document.getElementById('drawingArea'), '<svg>...</svg>')\n" +
+// "canvg('canvas', '"+svgFileName+"', {})\n" +
+// "}\n" +
+// "</script>\n" +
"</head>\n" +
"<body>\n" +
- "<canvas id=\"canvas\" width=\""+compositeWidth+"px\" height=\""+compositeHeight+"px\">\n" +
- "</canvas>\n" +
+ extractSvg()+"\n"+
+// "<canvas id=\"canvas\" width=\""+compositeWidth+"px\" height=\""+compositeHeight+"px\">\n" +
+// "</canvas>\n" +
"</body>\n" +
"</html>";
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();
}