commons-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=984040&view=rev
Log:
Switching between tools, dragging and dropping now works. Rotating, translating, and switching
between rotation and translation modes does not yet work.

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-precompiled.html
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/transform.js

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=984040&r1=984039&r2=984040&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:57 2010
@@ -79,8 +79,10 @@ In both:
 		}
 
 		function updateTransformHandles(){
-			var sePtX = cachedBBox.width + cachedBBox.x;
-			var sePtY = cachedBBox.height + cachedBBox.y;
+			//var sePtX = cachedBBox.width + cachedBBox.x;
+			//var sePtY = cachedBBox.height + cachedBBox.y;
+			var bbox = getAggregateBBox(selectedNodes);
+			var sePtX = bbox.x + bbox.width, sePtY = bbox.y + bbox.height;
 
 			//TODO: make this more general
 			var sScale = scaleHandle.transform.baseVal.getItem(0);
@@ -99,7 +101,7 @@ In both:
 			var newBBox;
 			if(nodes.length){
 				var bboxes = nodes.map(function(n){
-					return n.getBBox();
+					return transformModule.getBoundingBoxInCanvasCoordinates(n);	//FIXME: we do everything
in canvas coordinates
 				});
 
 				var newBBoxX0 = Math.min.apply(this,bboxes.map(function(bbox){ return bbox.x }))
@@ -360,6 +362,11 @@ In both:
 					<assign location="firstEvent" expr="_event.data"/>
 					<assign location="eventStamp" expr="_event.data"/>
 				</onexit>
+				<onentry>
+					<script>
+						updateTransformHandles();
+					</script>
+				</onentry>
 
 				<transition target="after_mousedown_on_selected_nodes" event="mousedown" 
 					cond="selectedNodes.indexOf(_event.data.target) !== -1 

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool-precompiled.html
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool-precompiled.html?rev=984040&r1=984039&r2=984040&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool-precompiled.html
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool-precompiled.html
Tue Aug 10 14:20:57 2010
@@ -144,28 +144,38 @@
                   });
                 }
 
-		//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);
+                require(
+                  {
+                    "baseUrl":"/"
+                  },
+                  [ "demo/drawing-tool/transform"],
+
+                  function(svgTransformModule){
+
+										//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,
+											transformModule:svgTransformModule,
+											scaleHandle:scaleHandle,
+											rotationHandle:rotationHandle,
+											ellipseButton:ellipseButton,
+											rectButton:rectButton,
+											transformButton:transformButton,
+											ellipseIcon:ellipseButtonIcon,
+											rectIcon:rectButtonIcon,
+											transformIcon:transformButtonIcon 
+										});   
+
+										hookUpDOMEvents(svg.root(),canvasSC);
+										hookUpDOMEvents(toolbar.root(),canvasSC);
+								});
               }  
             })
           }

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/transform.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/transform.js?rev=984040&r1=984039&r2=984040&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/transform.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/transform.js Tue Aug 10 14:20:57
2010
@@ -59,7 +59,7 @@ function(){
 	}	
 
 	function getBoundingBoxInCanvasCoordinates (rawNode){
-		return getBoundingBoxInArbitrarySpace(rawNode,rawNode.ownerSVGElement);
+		return getBoundingBoxInArbitrarySpace(rawNode,rawNode.getTransformToElement(rawNode.ownerSVGElement));
 	}
 
 	function radiansToDegrees(r){
@@ -112,7 +112,9 @@ function(){
 			t.setMatrix(newM);
 			tl.initialize(t);
 			return newM;
-		}
+		},
+
+		getBoundingBoxInCanvasCoordinates : getBoundingBoxInCanvasCoordinates
 	}
 }
 )



Mime
View raw message