commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r984020 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: demo/drawing-tool/ demo/drawing-tool/behaviour/ demo/drawing-tool/behaviour/canvas.xml demo/drawing-tool/drawing-tool.html src/xslt/backends/js/AbstractStatechartGenerator.xsl
Date Tue, 10 Aug 2010 14:17:21 GMT
Author: jbeard
Date: Tue Aug 10 14:17:21 2010
New Revision: 984020

URL: http://svn.apache.org/viewvc?rev=984020&view=rev
Log:
Started working on drawing tool demo.

Added:
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/behaviour/
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/behaviour/canvas.xml   (with
props)
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool.html   (with props)
Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/behaviour/canvas.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/behaviour/canvas.xml?rev=984020&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/behaviour/canvas.xml (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/behaviour/canvas.xml Tue Aug
10 14:17:21 2010
@@ -0,0 +1,86 @@
+<scxml 
+	xmlns="http://www.w3.org/2005/07/scxml"
+	version="1.0"
+	profile="ecmascript"
+	id="scxmlRoot"
+	initial="initial_default">
+
+	<script>
+		function computeTDelta(oldEvent,newEvent){
+			//summary:computes the offset between two events; to be later used with this.translate
+			var dx = newEvent.clientX - oldEvent.clientX;
+			var dy = newEvent.clientY - oldEvent.clientY;
+
+			return {'dx':dx,'dy':dy};
+		}
+
+		function updateRect(rawNode,tDelta){
+			rawNode.width.baseVal.value = tDelta.dx;
+			rawNode.height.baseVal.value = tDelta.dy;
+		}
+	</script>
+
+
+	<datamodel>
+		<data id="rawNode"/>
+		<data id="tDelta"/>
+		<data id="firstEvent"/>
+		<data id="eventStamp"/>
+		<data id="rectNode"/>
+		<data id="svgNs" expr="'http://www.w3.org/2000/svg'"/>
+	</datamodel>
+
+	<state id="initial_default">
+		<transition event="init" target="idle">
+			<assign location="rawNode" expr="_event.data.rawNode"/>
+		</transition>
+	</state>
+
+	<state id="idle">
+		<transition event="mousedown" target="before_drawing_mode">
+			<assign location="firstEvent" expr="_event.data"/>
+			<assign location="eventStamp" expr="_event.data"/>
+		</transition>
+	</state>
+
+	<state id="before_drawing_mode">
+		<transition event="mouseup" target="idle">
+			<script>
+				//TODO
+				//obj.canvasDeselect();
+			</script>
+		</transition>
+		<transition event="mousemove" target="drawing">
+			<assign location="tDelta" expr="computeTDelta(eventStamp,_event.data)"/>
+			<script>
+				rectNode = document.createElementNS(svgNs,"rect");
+				rectNode.setAttributeNS(null,"x",_event.data.clientX);
+				rectNode.setAttributeNS(null,"y",_event.data.clientY);
+				rectNode.setAttributeNS(null,"fill","red");
+				rectNode.setAttributeNS(null,"stroke","black");
+				rawNode.appendChild(rectNode);
+			</script>
+		</transition>
+	</state>
+
+	<state id="drawing">
+		<transition event="mouseup" target="idle">
+			<!-- TODO: finalize by turning rect into semantic object -->
+		</transition>
+
+		<!-- if escape keypress, kill the node -->
+		<!--
+		<transition event="keydown">
+		</transition>
+		-->
+
+		<transition event="mousemove" target="drawing">
+			<assign location="tDelta" expr="computeTDelta(eventStamp,_event.data)"/>
+			<script>
+				updateRect(rectNode,tDelta);
+			</script>
+		</transition>
+	</state>
+
+</scxml>
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/behaviour/canvas.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool.html
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool.html?rev=984020&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool.html (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool.html Tue Aug 10
14:17:21 2010
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg">
+	<head>
+		<style type="text/css">
+			html, body {
+				height:100%;
+				margin: 0;
+				padding: 0;
+			}
+		</style>
+		<script src="../../lib/js/requirejs/require.js" type="text/javascript"></script>
+		<script src="../../lib/js/requirejs/require/text.js" type="text/javascript"></script>
+		<script src="../../lib/js/requirejs/require/xml.js" type="text/javascript"></script>
+	</head>
+	<body>
+		<script>
+			var resultText;
+
+			//hook up minimal console api
+			if(typeof console == "undefined"){
+				console = {};
+				["log","info","error","dirxml"].forEach(function(m){console[m] = console[m] || function(){}
});
+			} 
+
+
+			//prep scxml document to transform by pulling the scxml node into its own document
+			var scxmlns = "http://www.w3.org/2005/07/scxml";
+			var svgns = "http://www.w3.org/2000/svg";
+
+			var svg = document.createElementNS(svgns,"svg");
+			svg.setAttributeNS(null,"width","100%");
+			svg.setAttributeNS(null,"height","100%");
+
+			document.body.appendChild(svg);
+
+
+			require(
+				{
+					"baseUrl":"/"
+				},
+				["src/javascript/scxml/cgf/SCXMLCompiler",
+					"xml!demo/drawing-tool/behaviour/canvas.xml"],
+
+				function(compiler,canvasBehaviourSCXML){
+
+					require( [window.DOMParser ?
+							"src/javascript/scxml/cgf/util/xsl/browser" :
+							"src/javascript/scxml/cgf/util/xsl/ie"],
+						function(transform){
+
+		
+						var compiledStatechartConstructor, compiledStatechartInstance; 
+
+						compiler.compile({
+							inFiles:[canvasBehaviourSCXML],
+							//debug:true,
+							backend:"state",
+							beautify:true,
+							verbose:false,
+							log:true,
+							ie:false
+						}, function(scArr){
+							var transformedJs = scArr[0];
+
+							//eval
+							console.log(transformedJs);
+							eval(transformedJs);
+							compiledStatechartConstructor = StatechartExecutionContext;
+							compiledStatechartInstance = new compiledStatechartConstructor(); 
+
+							//initialize
+							compiledStatechartInstance.initialize();
+							
+							//pass in reference to rect
+							compiledStatechartInstance.init({rawNode:svg}); 
+
+							//hook up DOM events
+							["mousedown","mouseup","mousemove"].forEach(function(eventName){
+								svg.addEventListener(eventName,function(e){e.preventDefault();compiledStatechartInstance[eventName](e)},false);
+							});
+						},transform);
+					})
+				}
+			);
+		</script>
+	</body>
+</html>
+
+
+

Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool.html
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl?rev=984020&r1=984019&r2=984020&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
Tue Aug 10 14:17:21 2010
@@ -21,7 +21,7 @@
 	version="1.0">
 	<output method="text"/>
 
-	<param name="log" select="true()"/>
+	<param name="log"/>
 	<param name="noIndexOf" select="false()"/>
 	<param name="noMap" select="false()"/>
 	<param name="noForEach" select="false()"/>



Mime
View raw message