commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r984130 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: demo/hierarchical-layout-drag-and-drop/ demo/hierarchical_layout/ src/javascript/scxml/cgf/ src/javascript/scxml/cgf/layout/
Date Tue, 10 Aug 2010 17:13:17 GMT
Author: jbeard
Date: Tue Aug 10 17:13:16 2010
New Revision: 984130

URL: http://svn.apache.org/viewvc?rev=984130&view=rev
Log:
Updated merged visualization code to use new dependency injection APIs.

Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical-layout-drag-and-drop/test.html
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical_layout/test.html
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical_layout/testBatik.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical_layout/test_with_dom.html
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/layout.js
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/layout/PrepLayout.js

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical-layout-drag-and-drop/test.html
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical-layout-drag-and-drop/test.html?rev=984130&r1=984129&r2=984130&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical-layout-drag-and-drop/test.html
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical-layout-drag-and-drop/test.html
Tue Aug 10 17:13:16 2010
@@ -21,56 +21,61 @@
 
 		function(compiler,scxmlDoc,layout,dragAndDropBehaviourSCXMLDoc,xpath,LinkOptimizer){
 
-			var layoutInfo = layout.applyHierarchicalLayout(scxmlDoc);
-			var svgDoc = layoutInfo.svgDoc, 
-				linkNodeList = layoutInfo.linkNodeList, 
-				entityNodeList = layoutInfo.entityNodeList;
-
-			//enough graphical stuff, let's do some compilation
-			compiler.compile({
-				inFiles:[dragAndDropBehaviourSCXMLDoc],
-				backend:"state",
-				beautify:true,
-				verbose:false,
-				log:false,
-				ie:false,
-				genListenerHooks:true
-			}, function(scArr){
-				var dragAndDropBehaviourTransformedJs = scArr[0];
-
-				console.log(dragAndDropBehaviourTransformedJs);
-
-				//hook up graphical node drag and drop behaviour
-				eval(dragAndDropBehaviourTransformedJs);
-
-				DragAndDropStatechartExecutionContext = StatechartExecutionContext;
-
-				var graphEntityNodes = xpath.query("//svg:g[@c:graphEntity = 'true']",svgDoc.documentElement)
-				graphEntityNodes.forEach(function(groupNode){
-					var compiledStatechartInstance = new DragAndDropStatechartExecutionContext();
-					
-					//initialize
-					compiledStatechartInstance.initialize();
-
-					console.log(groupNode);
-					
-					//pass in reference to rect
-					compiledStatechartInstance.init({rawNode:groupNode,linkNodeList:linkNodeList,LinkOptimizer:LinkOptimizer});

-
-					//hook up DOM events
-					["mousedown","mouseup","mousemove"].forEach(function(eventName){
-						groupNode.addEventListener(eventName,
-						function(e){
-							e.preventDefault();
-							compiledStatechartInstance[eventName](e);
-							e.stopPropagation();
-						},
-						false);
-					});
+			require( [window.DOMParser ?
+					"src/javascript/scxml/cgf/util/xsl/browser" :
+					"src/javascript/scxml/cgf/util/xsl/ie"],
+				function(transform){
+
+					var layoutInfo = layout.applyHierarchicalLayout(transform,scxmlDoc);
+					var svgDoc = layoutInfo.svgDoc, 
+						linkNodeList = layoutInfo.linkNodeList, 
+						entityNodeList = layoutInfo.entityNodeList;
+
+					//enough graphical stuff, let's do some compilation
+					compiler.compile({
+						inFiles:[dragAndDropBehaviourSCXMLDoc],
+						backend:"state",
+						beautify:true,
+						verbose:false,
+						log:false,
+						ie:false,
+						genListenerHooks:true
+					}, function(scArr){
+						var dragAndDropBehaviourTransformedJs = scArr[0];
+
+						console.log(dragAndDropBehaviourTransformedJs);
+
+						//hook up graphical node drag and drop behaviour
+						eval(dragAndDropBehaviourTransformedJs);
+
+						DragAndDropStatechartExecutionContext = StatechartExecutionContext;
+
+						var graphEntityNodes = xpath.query("//svg:g[@c:graphEntity = 'true']",svgDoc.documentElement)
+						graphEntityNodes.forEach(function(groupNode){
+							var compiledStatechartInstance = new DragAndDropStatechartExecutionContext();
+							
+							//initialize
+							compiledStatechartInstance.initialize();
+
+							console.log(groupNode);
+							
+							//pass in reference to rect
+							compiledStatechartInstance.init({rawNode:groupNode,linkNodeList:linkNodeList,LinkOptimizer:LinkOptimizer});

+
+							//hook up DOM events
+							["mousedown","mouseup","mousemove"].forEach(function(eventName){
+								groupNode.addEventListener(eventName,
+								function(e){
+									e.preventDefault();
+									compiledStatechartInstance[eventName](e);
+									e.stopPropagation();
+								},
+								false);
+							});
+						});
+					},transform);
 				});
 			});
-		}
-	);
 </script>
   </head>
   <body/>

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical_layout/test.html
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical_layout/test.html?rev=984130&r1=984129&r2=984130&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical_layout/test.html (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical_layout/test.html Tue Aug 10
17:13:16 2010
@@ -16,7 +16,13 @@
 					"src/javascript/scxml/cgf/layout"],
 
 				function(scxmlDoc,layout){
-					layout.applyHierarchicalLayout(scxmlDoc);
+					require( [window.DOMParser ?
+							"src/javascript/scxml/cgf/util/xsl/browser" :
+							"src/javascript/scxml/cgf/util/xsl/ie"],
+						function(transform){
+
+						layout.applyHierarchicalLayout(transform,scxmlDoc);
+					});
 				}
 			);
 		</script>

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical_layout/testBatik.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical_layout/testBatik.js?rev=984130&r1=984129&r2=984130&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical_layout/testBatik.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical_layout/testBatik.js Tue Aug
10 17:13:16 2010
@@ -21,14 +21,15 @@ require({
 			[
 				"xml!test/kitchen_sink/KitchenSink.xml",
 				"src/javascript/scxml/cgf/layout",
-				"src/javascript/scxml/cgf/util/xml",
-				"src/javascript/scxml/cgf/util/file"
+				"src/javascript/scxml/cgf/util/xml/rhino",
+				"src/javascript/scxml/cgf/util/file",
+				"src/javascript/scxml/cgf/util/xsl/rhino"
 				],
 
 
-			function(scxmlDoc,layout,xml,file){
+			function(scxmlDoc,layout,xml,file,transformer){
 
-				var layoutInfo = layout.applyHierarchicalLayout(scxmlDoc);
+				var layoutInfo = layout.applyHierarchicalLayout(transformer,scxmlDoc);
 				var svgDoc = layoutInfo.svgDoc;
 
 				//serialize to SVG, PDF, etc.

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical_layout/test_with_dom.html
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical_layout/test_with_dom.html?rev=984130&r1=984129&r2=984130&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical_layout/test_with_dom.html (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/demo/hierarchical_layout/test_with_dom.html Tue
Aug 10 17:13:16 2010
@@ -46,51 +46,58 @@
 				[
 					"xml!test/kitchen_sink/KitchenSink.xml",
 					"src/javascript/scxml/cgf/layout",
-					"src/javascript/scxml/cgf/layout/hierarchical/HierarchicalLayout",
-					"src/javascript/scxml/cgf/util/xml"],
+					"src/javascript/scxml/cgf/layout/hierarchical/HierarchicalLayout"],
 
-				function(scxmlDoc,layout,HierarchicalLayout,xmlUtils){
+				function(scxmlDoc,layout,HierarchicalLayout){
 
-					//set the initial XML content in the textarea
-					var xmlString = xmlUtils.serializeToString(scxmlDoc);
-					scxml_input.textContent = xmlString;
-
-					//main callback on buttons
-					function applyHierLayout(heuristic,domAttachPoint,scxmlInputDoc){
-						layout.applyHierarchicalLayout(scxmlInputDoc,{heuristic : heuristic},domAttachPoint)
-					}
-
-					function parseTextareaPopupWindowAndApplyLayout(heuristic){
-						//parse from textarea dom
-						var scxmlInputDoc = xmlUtils.parseFromString(scxml_input.textContent);
-
-						//open new window and get DOM attach point
-						var w = window.open("display.html");
-						//debugger;
-						w.addEventListener("DOMContentLoaded",function(e){
-							var domAttachPoint = w.document.body;
-
-							//debugger;
-							//apply layout
-							console.log("dom attach point",domAttachPoint)
-							applyHierLayout(heuristic,domAttachPoint,scxmlInputDoc);
-						},true);
-
-					}
-
-					//hook up event listeners
-					LONGEST_PATH_LAYERING_BOTTOM_UP_button.addEventListener("mousedown",function(e){
-						parseTextareaPopupWindowAndApplyLayout(HierarchicalLayout.HEURISTICS_ENUM.LONGEST_PATH_LAYERING_BOTTOM_UP)
-					},true); 
-					LONGEST_PATH_LAYERING_TOP_DOWN_button.addEventListener("mousedown",function(e){
-						parseTextareaPopupWindowAndApplyLayout(HierarchicalLayout.HEURISTICS_ENUM.LONGEST_PATH_LAYERING_TOP_DOWN)
-					},true);
-					MINIMUM_WIDTH_LAYERING_button.addEventListener("mousedown",function(e){
-						parseTextareaPopupWindowAndApplyLayout(HierarchicalLayout.HEURISTICS_ENUM.MINIMUM_WIDTH_LAYERING)
-					},true);
+					require( [window.DOMParser ?
+							"src/javascript/scxml/cgf/util/xsl/browser" :
+							"src/javascript/scxml/cgf/util/xsl/ie",
+							window.DOMParser ?
+								"src/javascript/scxml/cgf/util/xml/browser" :
+								"src/javascript/scxml/cgf/util/xml/ie" ],
+						function(transform,xmlUtils){
+
+							//set the initial XML content in the textarea
+							var xmlString = xmlUtils.serializeToString(scxmlDoc);
+							scxml_input.textContent = xmlString;
+
+							//main callback on buttons
+							function applyHierLayout(heuristic,domAttachPoint,scxmlInputDoc){
+								layout.applyHierarchicalLayout(transform,scxmlInputDoc,{heuristic : heuristic},domAttachPoint)
+							}
+
+							function parseTextareaPopupWindowAndApplyLayout(heuristic){
+								//parse from textarea dom
+								var scxmlInputDoc = xmlUtils.parseFromString(scxml_input.textContent);
+
+								//open new window and get DOM attach point
+								var w = window.open("display.html");
+								//debugger;
+								w.addEventListener("DOMContentLoaded",function(e){
+									var domAttachPoint = w.document.body;
+
+									//debugger;
+									//apply layout
+									console.log("dom attach point",domAttachPoint)
+									applyHierLayout(heuristic,domAttachPoint,scxmlInputDoc);
+								},true);
+
+							}
+
+							//hook up event listeners
+							LONGEST_PATH_LAYERING_BOTTOM_UP_button.addEventListener("mousedown",function(e){
+								parseTextareaPopupWindowAndApplyLayout(HierarchicalLayout.HEURISTICS_ENUM.LONGEST_PATH_LAYERING_BOTTOM_UP)
+							},true); 
+							LONGEST_PATH_LAYERING_TOP_DOWN_button.addEventListener("mousedown",function(e){
+								parseTextareaPopupWindowAndApplyLayout(HierarchicalLayout.HEURISTICS_ENUM.LONGEST_PATH_LAYERING_TOP_DOWN)
+							},true);
+							MINIMUM_WIDTH_LAYERING_button.addEventListener("mousedown",function(e){
+								parseTextareaPopupWindowAndApplyLayout(HierarchicalLayout.HEURISTICS_ENUM.MINIMUM_WIDTH_LAYERING)
+							},true);
+						});
 
-				}
-			);
+				});
 		</script>
 
 

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/layout.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/layout.js?rev=984130&r1=984129&r2=984130&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/layout.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/layout.js Tue Aug 10
17:13:16 2010
@@ -12,7 +12,6 @@ require.def("src/javascript/scxml/cgf/la
 	"xml!src/xslt/layout/computeAncestorOrSelfAndChildOfLCA.xsl",
 	"xml!src/xslt/layout/addTransitionTargetIds.xsl",
 	"xml!src/xslt/layout/scxmlToSVG.xsl",
-	"src/javascript/scxml/cgf/Transformer",
 	"src/javascript/scxml/cgf/layout/PrepLayout",
 	"src/javascript/scxml/cgf/layout/hierarchical/NodeWrapper",
 	"src/javascript/scxml/cgf/layout/hierarchical/HierarchicalLayout",
@@ -23,20 +22,19 @@ function(
 		nameTransitions,generateUniqueStateIds,generateUniqueInitialStateIds,normalizeInitialStates,
 			splitTransitionTargets,computeLCA,computeAncestorOrSelfAndChildOfLCA,addTransitionTargetIds,
 		scxmlToSvgXsl,
-		Transformer,
 		PrepLayout,NodeWrapper,HierarchicalLayout,shrinkwrapLayout,
 		LinkOptimizer){
 
 	return {
-		applyHierarchicalLayout : function(scxmlDoc,options,domAttachPoint){
-			var ir = Transformer(scxmlDoc,
+		applyHierarchicalLayout : function(transformer,scxmlDoc,options,domAttachPoint){
+			var ir = transformer(scxmlDoc,
 				[generateUniqueStateIds,normalizeInitialStates,generateUniqueInitialStateIds,
 					nameTransitions,splitTransitionTargets,computeLCA,
 					computeAncestorOrSelfAndChildOfLCA,addTransitionTargetIds
 				],
 				null,"xml");  //transform to IR
 
-			var svgDoc = Transformer(ir,[scxmlToSvgXsl],null,"xml");	//transform scxml to non-laid
out, svg graphical representation
+			var svgDoc = transformer(ir,[scxmlToSvgXsl],null,"xml");	//transform scxml to non-laid
out, svg graphical representation
 
 			//console.dirxml(ir);
 			svgDoc = PrepLayout.bootSVGDOM(svgDoc,domAttachPoint);
@@ -57,7 +55,7 @@ function(
 			//TODO: move this into hier layout
 			NodeWrapper.initilizeNodeWrapper()
 			HierarchicalLayout.recursivelyApplyHierarchicalLayout(rootEntity,
-				{heuristic : HierarchicalLayout.HEURISTICS_ENUM.LONGEST_PATH_LAYERING_BOTTOM_UP })
+				{heuristic : (options && options.heuristic) || HierarchicalLayout.HEURISTICS_ENUM.LONGEST_PATH_LAYERING_BOTTOM_UP
})
 
 			//shrinkwrap layout
 			console.log("Recursively applying shrinkwrap layout")

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/layout/PrepLayout.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/layout/PrepLayout.js?rev=984130&r1=984129&r2=984130&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/layout/PrepLayout.js
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/layout/PrepLayout.js
Tue Aug 10 17:13:16 2010
@@ -18,11 +18,10 @@
 require.def("src/javascript/scxml/cgf/layout/PrepLayout",
 [
 	"src/javascript/scxml/cgf/util/svg",
-	"src/javascript/scxml/cgf/Transformer",
 	"src/javascript/scxml/cgf/layout/graphics",
 	"src/javascript/scxml/cgf/util/xpath" ],
 
-function(commonSVG,Transformer,graphics,xpath){
+function(commonSVG,graphics,xpath){
 
 
 	//FIXME: this method is something that will need to be moved out as well, as we may use
batik when running under Rhino



Mime
View raw message