commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r984036 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: demo/drawing-tool/behaviour/canvas.xml demo/drawing-tool/drawing-tool-precompiled.html demo/drawing-tool/drawing-tool.html run.sh
Date Tue, 10 Aug 2010 14:20:20 GMT
Author: jbeard
Date: Tue Aug 10 14:20:20 2010
New Revision: 984036

URL: http://svn.apache.org/viewvc?rev=984036&view=rev
Log:
Various small changes.

Added:
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool-precompiled.html
      - copied, changed from r984035, commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool.html
Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/behaviour/canvas.xml
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool.html
    commons/sandbox/gsoc/2010/scxml-js/trunk/run.sh

Modified: 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=984036&r1=984035&r2=984036&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/behaviour/canvas.xml (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/behaviour/canvas.xml Tue Aug
10 14:20:20 2010
@@ -83,11 +83,17 @@ In both:
 			var sePtY = cachedBBox.height + cachedBBox.y;
 
 			var sScale = scaleHandle.transform.baseVal.getItem(0);
-			var newM = identity.translate(sePtX,sePtY);
+			var bbox = scaleHandle.getBBox();
+			var dx = sePtX - bbox.x;
+			var dy = sePtY - bbox.y;
+			var newM = scaleHandle.ownerSVGElement.createSVGMatrix().translate(dx,dy).multiply(sScale.matrix);
 			sScale.setMatrix(newM);
 
 			var rScale = rotationHandle.transform.baseVal.getItem(0);
-			var newM = identity.translate(sePtX,sePtY);
+			var bbox = rotationHandle.getBBox();
+			var dx = sePtX - bbox.x;
+			var dy = sePtY - bbox.y;
+			var newM = rotationHandle.ownerSVGElement.createSVGMatrix().translate(dx,dy).multiply(rScale.matrix);
 			rScale.setMatrix(newM);
 		}
 
@@ -96,8 +102,8 @@ In both:
 			//get the aggregate of the bounding boxes of his children, or if he has no hier children,
get his own bbox
 			var newBBox;
 			if(nodes.length){
-				var bboxes = $(nodes).map(function(e){
-					return e.visualObject.getBBoxInEntitySpace(boundingBoxGraphEntity.visualObject);
+				var bboxes = nodes.map(function(n){
+					return n.getBBox();
 				});
 
 				var newBBoxX0 = Math.min.apply(this,bboxes.map(function(bbox){ return bbox.x }))
@@ -253,6 +259,14 @@ In both:
 
 				<state id="nodes_selected" initial="ready_to_scale">
 
+					<onentry>
+						<assign location="cachedCenterPoint" expr="getAggregateCenterPoint(selectedNodes)"/>
+						<assign location="cachedBBox" expr="getAggregateBBox(selectedNodes)"/>
+						<script>
+							updateTransformHandles();
+						</script>
+					</onentry>
+
 					<history type="shallow" id="nodes_selected_history">
 						<target id="ready_to_scale"/>
 					</history>
@@ -491,7 +505,7 @@ In both:
 				</transition>
 				<transition target="ready" event="mouseup">
 					<assign location="tDelta" expr="computeTDelta(firstEvent,eventStamp)"/>
-					<assign location="cachedCenterPoint" expr="getCenterPoint(selectedNodes)"/>
+					<assign location="cachedCenterPoint" expr="getAggregateCenterPoint(selectedNodes)"/>
 					<assign location="cachedBBox" expr="getAggregateBBox(selectedNodes)"/>
 					<!-- TODO -->
 					<script>
@@ -525,7 +539,7 @@ In both:
 
 			<state id="scaling">
 				<transition target="ready" event="mouseup">
-					<assign location="cachedCenterPoint" expr="getCenterPoint(selectedNodes)"/>
+					<assign location="cachedCenterPoint" expr="getAggregateCenterPoint(selectedNodes)"/>
 					<assign location="cachedBBox" expr="getAggregateBBox(selectedNodes)"/>
 					<script>
 						updateTransformHandles();
@@ -578,8 +592,13 @@ In both:
 				
 				<transition target="ready" event="mouseup">
 					<script>
+						$(selectedNodes).removeClass("selected");
+					</script>
+					<script>
+						selectedNodes = [nodeBeingDrawn];
+
 						allNodes.push(nodeBeingDrawn);
-						selectedNodes.push(nodeBeingDrawn);
+
 						$(nodeBeingDrawn).addClass("selected");
 					</script>
 				</transition>

Copied: commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool-precompiled.html
(from r984035, 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-precompiled.html?p2=commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool-precompiled.html&p1=commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool.html&r1=984035&r2=984036&rev=984036&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool.html (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool-precompiled.html
Tue Aug 10 14:20:20 2010
@@ -42,6 +42,10 @@
         stroke : none;
       }
 
+      ellipse.selected, rect.selected {
+        stroke-dasharray : 5,5;
+      }
+
       @import "lib/jquery.svg.css";
 
     </style>
@@ -52,6 +56,7 @@
     <script src="lib/jquery-1.4.2.js" type="text/javascript"></script>
     <script src="lib/jquery.svg.js" type="text/javascript"></script>
     <script src="lib/jquery.svgdom.js" type="text/javascript"></script>
+    <script src="build/canvas.js"></script>
 
     <script>
       $(document).ready(function(){
@@ -122,7 +127,10 @@
 		  transform:"rotate(-45)",
 		  visibility:"hidden"
 		})
-		var rotationHandle =  svg.path("M 12 0 L 17 5 L 15 5 Q 15 15 5 15 L 5 17 L 0 12 L 5 7 L
5 9 Q 9 9 9 5 L 7 5 L 12 0 z",{visibility:"hidden"})
+		var rotationHandle =  svg.path("M 12 0 L 17 5 L 15 5 Q 15 15 5 15 L 5 17 L 0 12 L 5 7 L
5 9 Q 9 9 9 5 L 7 5 L 12 0 z",{
+			visibility:"hidden",
+			transform:"translate(0,0)"
+		})
 
                 function hookUpDOMEvents(node,compiledStatechartInstance){
                   //hook up DOM events
@@ -136,68 +144,28 @@
                   });
                 }
 
-                require(
-                  {
-                    "baseUrl":"/"
-                  },
-                  ["src/javascript/scxml/cgf/SCXMLCompiler",
-                    "demo/drawing-tool/transform",
-                    "xml!demo/drawing-tool/behaviour/canvas.xml" ],
-
-                  function(compiler,svgTransformer,canvasBehaviourSCXML){
-
-                    require( [window.DOMParser ?
-                        "src/javascript/scxml/cgf/util/xsl/browser" :
-                        "src/javascript/scxml/cgf/util/xsl/ie"],
-                      function(xslTransformer){
-
-              
-                      var d = new Date();
-
-                      compiler.compile({
-                        inFiles:[canvasBehaviourSCXML],
-                        //debug:true,
-                        backend:"state",
-                        beautify:true,
-                        verbose:false,
-                        log:false,
-                        ie:false
-                      }, function(scArr){
-            
-                        console.log("Compiling statecharts took:",new Date() - d);
-                        //eval
-                        for(var i=0, l=scArr.length; i < l; i++){
-                          console.log(scArr[i]);
-                          eval(scArr[i]);
-                        }
-
-                        //hook up canvas behaviour
-                        var canvasSC = new CanvasStatechartExecutionContext(); 
-
-			svg.statechart = canvasSC;	//hook up dom node reference
-
-                        canvasSC.initialize();
-                        
-                        //pass in reference to rect
-                        canvasSC.init({  
-                          svg:svg,
-			  scaleHandle:scaleHandle,
-			  rotationHandle:rotationHandle,
-                          ellipseButton:ellipseButton,
-                          rectButton:rectButton,
-                          transformButton:transformButton,
-                          ellipseIcon:ellipseButtonIcon,
-                          rectIcon:rectButtonIcon,
-                          transformIcon:transformButtonIcon 
-                        });   
-
-                        hookUpDOMEvents(svg.root(),canvasSC);
-                        hookUpDOMEvents(toolbar.root(),canvasSC);
-
-                      },xslTransformer);
-                    })
-                  }
-                );
+		//hook up canvas behaviour
+		canvasSC = new CanvasStatechartExecutionContext(); 
+
+		svg.statechart = canvasSC;	//hook up dom node reference
+
+		canvasSC.initialize();
+
+		//pass in reference to rect
+		canvasSC.init({  
+		  svg:svg,
+		  scaleHandle:scaleHandle,
+		  rotationHandle:rotationHandle,
+		  ellipseButton:ellipseButton,
+		  rectButton:rectButton,
+		  transformButton:transformButton,
+		  ellipseIcon:ellipseButtonIcon,
+		  rectIcon:rectButtonIcon,
+		  transformIcon:transformButtonIcon 
+		});   
+
+		hookUpDOMEvents(svg.root(),canvasSC);
+		hookUpDOMEvents(toolbar.root(),canvasSC);
               }  
             })
           }
@@ -214,3 +182,4 @@
 
 
 
+

Modified: 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=984036&r1=984035&r2=984036&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool.html (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool.html Tue Aug 10
14:20:20 2010
@@ -42,6 +42,10 @@
         stroke : none;
       }
 
+      circle.selected, rect.selected {
+        stroke-dasharray : 4 4;
+      }
+
       @import "lib/jquery.svg.css";
 
     </style>

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/run.sh
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/run.sh?rev=984036&r1=984035&r2=984036&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/run.sh (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/run.sh Tue Aug 10 14:20:20 2010
@@ -6,4 +6,4 @@
 
 dn=`dirname $0`
 abspath=`cd $dn; pwd`
-java -cp ./lib/java/js.jar:./lib/java/commons-cli.jar:./lib/java/serializer.jar:./lib/java/xalan.jar:./lib/java/xercesImpl.jar:./lib/java/xml-apis.jar
org.mozilla.javascript.tools.shell.Main -debug runner.js $abspath src/javascript/scxml/cgf/main
$*
+java -cp $abspath/lib/java/js.jar:$abspath/lib/java/commons-cli.jar:$abspath/lib/java/serializer.jar:$abspath/lib/java/xalan.jar:$abspath/lib/java/xercesImpl.jar:$abspath/lib/java/xml-apis.jar
org.mozilla.javascript.tools.shell.Main -debug $abspath/runner.js $abspath src/javascript/scxml/cgf/main
$*



Mime
View raw message