[OpenLayers-Commits] r11950 - in sandbox/tschaub/editing/lib/OpenLayers: Control Handler

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed May 4 14:57:35 EDT 2011


Author: tschaub
Date: 2011-05-04 11:57:34 -0700 (Wed, 04 May 2011)
New Revision: 11950

Modified:
   sandbox/tschaub/editing/lib/OpenLayers/Control/DrawFeature.js
   sandbox/tschaub/editing/lib/OpenLayers/Handler/Path.js
Log:
Adding method to insert by x,y offsets.

Modified: sandbox/tschaub/editing/lib/OpenLayers/Control/DrawFeature.js
===================================================================
--- sandbox/tschaub/editing/lib/OpenLayers/Control/DrawFeature.js	2011-05-04 12:08:25 UTC (rev 11949)
+++ sandbox/tschaub/editing/lib/OpenLayers/Control/DrawFeature.js	2011-05-04 18:57:34 UTC (rev 11950)
@@ -137,6 +137,20 @@
     },
 
     /**
+     * APIMethod: insertDeltaXY
+     * Insert a point given offsets from the previously inserted point.
+     *
+     * Parameters:
+     * dx - {Number} The x-coordinate offset of the point.
+     * dy - {Number} The y-coordinate offset of the point.
+     */
+    insertDeltaXY: function(dx, dy) {
+        if (this.handler && this.handler.line) {
+            this.handler.insertDeltaXY(dx, dy);
+        }
+    },
+
+    /**
      * APIMethod: insertDirectionLength
      * Insert a point in the current sketch given a direction and a length.
      *
@@ -151,6 +165,20 @@
     },
 
     /**
+     * APIMethod: insertDirectionLength
+     * Insert a point in the current sketch given a direction and a length.
+     *
+     * Parameters:
+     * direction - {Number} Degrees clockwise from the positive x-axis.
+     * length - {Number} Distance from the previously drawn point.
+     */
+    insertDirectionLength: function(direction, length) {
+        if (this.handler && this.handler.line) {
+            this.handler.insertDirectionLength(direction, length);
+        }
+    },
+
+    /**
      * APIMethod: finishSketch
      * Finishes the sketch without including the currently drawn point.
      *     This method can be called to terminate drawing programmatically

Modified: sandbox/tschaub/editing/lib/OpenLayers/Handler/Path.js
===================================================================
--- sandbox/tschaub/editing/lib/OpenLayers/Handler/Path.js	2011-05-04 12:08:25 UTC (rev 11949)
+++ sandbox/tschaub/editing/lib/OpenLayers/Handler/Path.js	2011-05-04 18:57:34 UTC (rev 11950)
@@ -181,6 +181,20 @@
     },
 
     /**
+     * Method: insertDeltaXY
+     * Insert a point given offsets from the previously inserted point.
+     *
+     * Parameters:
+     * dx - {Number} The x-coordinate offset of the point.
+     * dy - {Number} The y-coordinate offset of the point.
+     */
+    insertDeltaXY: function(dx, dy) {
+        var previousIndex = this.getCurrentPointIndex() - 1;
+        var p0 = this.line.geometry.components[previousIndex];
+        this.insertXY(p0.x + dx, p0.y + dy);
+    },
+
+    /**
      * Method: insertDirectionLength
      * Insert a point in the current sketch given a direction and a length.
      *
@@ -192,9 +206,7 @@
         direction *= Math.PI / 180;
         var dx = length * Math.cos(direction);
         var dy = length * Math.sin(direction);
-        var previousIndex = this.getCurrentPointIndex() - 1;
-        var p0 = this.line.geometry.components[previousIndex];
-        this.insertXY(p0.x + dx, p0.y + dy);
+        this.insertDeltaXY(dx, dy);
     },
 
     /**



More information about the Commits mailing list