[OpenLayers-Commits] r11116 - in sandbox/elemoine/draw-feature:
lib/OpenLayers/Handler tests/Control tests/Handler
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Mon Feb 14 03:13:46 EST 2011
Author: erilem
Date: 2011-02-14 00:13:46 -0800 (Mon, 14 Feb 2011)
New Revision: 11116
Modified:
sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js
sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js
sandbox/elemoine/draw-feature/tests/Control/Measure.html
sandbox/elemoine/draw-feature/tests/Handler/Path.html
sandbox/elemoine/draw-feature/tests/Handler/Point.html
sandbox/elemoine/draw-feature/tests/Handler/Polygon.html
Log:
call modifyFeature on mousedown, and eliminate the bug when clicking thrice for finalizing
Modified: sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js
===================================================================
--- sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js 2011-02-13 22:09:08 UTC (rev 11115)
+++ sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js 2011-02-14 08:13:46 UTC (rev 11116)
@@ -239,6 +239,7 @@
}
this.mouseDown = true;
this.lastDown = evt.xy;
+ this.modifyFeature(evt.xy, !!this.lastUp);
if (this.freehandMode(evt)) {
this.freehandMouseDown = true;
return false;
Modified: sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js
===================================================================
--- sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js 2011-02-13 22:09:08 UTC (rev 11115)
+++ sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js 2011-02-14 08:13:46 UTC (rev 11116)
@@ -341,6 +341,7 @@
mousedown: function(evt) {
this.mouseDown = true;
this.lastDown = evt.xy;
+ this.modifyFeature(evt.xy);
return !this.stopDown;
},
Modified: sandbox/elemoine/draw-feature/tests/Control/Measure.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Control/Measure.html 2011-02-13 22:09:08 UTC (rev 11115)
+++ sandbox/elemoine/draw-feature/tests/Control/Measure.html 2011-02-14 08:13:46 UTC (rev 11116)
@@ -207,14 +207,14 @@
t.eq(log.length, 2, "h) event logged");
t.eq(log[1].type, "measurepartial", "h) correct type");
t.eq(log[1].measure, 20, "h) correct measure");
-
+
// i) mouse up to finish
trigger("mouseup", 20, 0);
t.eq(log.length, 3, "i) event logged");
t.eq(log[2].type, "measure", "i) correct type");
t.eq(log[2].measure, 20, "i) correct measure");
-
+
// j) clean up
log = [];
map.destroy();
@@ -228,7 +228,7 @@
}
function test_immediate(t) {
- t.plan(29);
+ t.plan(32);
var map = new OpenLayers.Map({
div: "map",
@@ -241,7 +241,7 @@
],
center: new OpenLayers.LonLat(0, 0)
});
-
+
var log = [];
var control = new OpenLayers.Control.Measure(
OpenLayers.Handler.Path, {
@@ -259,7 +259,7 @@
);
map.addControl(control);
control.activate();
-
+
// convenience function to trigger mouse events
function trigger(type, x, y) {
map.events.triggerEvent(type, {
@@ -279,7 +279,7 @@
trigger("mousemove", 0, 10);
t.eq(log.length, 0, "a) no event fired yet");
-
+
t.delay_call(
delay, function() {
// confirm measurepartial is fired
@@ -339,18 +339,21 @@
// i) double click to finish
trigger("mousedown", 0, 60);
+ t.eq(log.length, 7, "i) event logged");
+ t.eq(log[6].type, "measurepartial", "i) correct type");
+ t.eq(log[6].measure, 60, "i) correct measure");
trigger("mouseup", 0, 60);
- t.eq(log.length, 6, "i) no event fired yet");
+ t.eq(log.length, 7, "i) no event fired yet");
},
delay, function() {
- t.eq(log.length, 7, "i) event logged");
- t.eq(log[6].type, "measurepartial", "i) correct type");
- t.eq(log[6].measure, 60, "i) correct measure");
-
- trigger("dblclick", 0, 60);
t.eq(log.length, 8, "i) event logged");
- t.eq(log[7].type, "measure", "i) correct type");
+ t.eq(log[7].type, "measurepartial", "i) correct type");
t.eq(log[7].measure, 60, "i) correct measure");
+
+ trigger("dblclick", 0, 60);
+ t.eq(log.length, 9, "i) event logged");
+ t.eq(log[8].type, "measure", "i) correct type");
+ t.eq(log[8].measure, 60, "i) correct measure");
// clear log
log = [];
Modified: sandbox/elemoine/draw-feature/tests/Handler/Path.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Handler/Path.html 2011-02-13 22:09:08 UTC (rev 11115)
+++ sandbox/elemoine/draw-feature/tests/Handler/Path.html 2011-02-14 08:13:46 UTC (rev 11116)
@@ -116,7 +116,7 @@
}
function test_callbacks(t) {
- t.plan(39);
+ t.plan(45);
var map = new OpenLayers.Map("map", {
resolutions: [1]
});
@@ -159,7 +159,7 @@
"[activate] correct feature");
// mouse move
handler.mousemove(
- {type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
+ {type: "mousemove", xy: new OpenLayers.Pixel(0, 0)});
t.eq(logs.length, 1, "[mousemove] called back");
log = logs.shift();
t.eq(log.type, "modify", "[mousemove] modify called");
@@ -170,7 +170,13 @@
// mouse down
handler.mousedown(
{type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
- t.eq(logs.length, 0, "[mousedown] not called back");
+ t.eq(logs.length, 1, "[mousedown] called back");
+ log = logs.shift();
+ t.eq(log.type, "modify", "[mousedown] modify called");
+ t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-150, 75),
+ "[mousedown] correct point");
+ t.ok(log.args[1] === handler.line,
+ "[mousedown] correct feature");
// mouse up
handler.mouseup({type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
t.eq(logs.length, 2, "[mouseup] called back twice");
@@ -212,7 +218,13 @@
// mouse down
handler.mousedown({type: "mousedown",
xy: new OpenLayers.Pixel(10, 10)});
- t.eq(logs.length, 0, "[mousedown] not called back");
+ t.eq(logs.length, 1, "[mousedown] called back");
+ log = logs.shift();
+ t.eq(log.type, "modify", "[mousedown] modify called");
+ t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-140, 65),
+ "[mousedown] correct point");
+ t.ok(log.args[1] === handler.line,
+ "[mousedown] correct feature");
// mouse up ("point", "modify")
handler.mouseup({type: "mouseup",
xy: new OpenLayers.Pixel(10, 10)});
@@ -222,8 +234,8 @@
// mouse down
handler.mousedown({type: "mousedown",
xy: new OpenLayers.Pixel(10, 10)});
- t.eq(logs.length, 0, "[mousedown] not called back");
- // mouse up ("point", "modify")
+ t.eq(logs.length, 0, "[mousedown] called back");
+ // mouse up
handler.mouseup({type: "mouseup",
xy: new OpenLayers.Pixel(10, 10)});
t.eq(logs.length, 0, "[mouseup] not called back");
@@ -263,7 +275,7 @@
"[cancel] correct point");
map.destroy();
- }
+ }
function test_toggle_freehand(t) {
t.plan(2);
Modified: sandbox/elemoine/draw-feature/tests/Handler/Point.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Handler/Point.html 2011-02-13 22:09:08 UTC (rev 11115)
+++ sandbox/elemoine/draw-feature/tests/Handler/Point.html 2011-02-14 08:13:46 UTC (rev 11116)
@@ -142,7 +142,7 @@
}
function test_callbacks(t) {
- t.plan(22);
+ t.plan(28);
var map = new OpenLayers.Map("map", {
resolutions: [1]
});
@@ -181,7 +181,14 @@
// mouse down
handler.mousedown(
{type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
- t.eq(logs.length, 0, "[mousedown] not called back");
+ t.eq(logs.length, 1, "[mousedown] called back");
+ log = logs.shift();
+ t.eq(log.type, "modify", "[mousedown] modify called");
+ t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-150, 75),
+ "[mousedown] correct point");
+ t.geom_eq(log.args[1].geometry,
+ new OpenLayers.Geometry.Point(-150, 75),
+ "[mousedown] correct feature");
// mouse move
handler.mousemove(
{type: "mousemove", xy: new OpenLayers.Pixel(1, 0)});
@@ -203,7 +210,14 @@
// mouse down
handler.mousedown(
{type: "mousedown", xy: new OpenLayers.Pixel(2, 0)});
- t.eq(logs.length, 0, "[mousedown] not called back");
+ t.eq(logs.length, 1, "[mousedown] called back");
+ log = logs.shift();
+ t.eq(log.type, "modify", "[mousedown] modify called");
+ t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-148, 75),
+ "[mousedown] correct point");
+ t.geom_eq(log.args[1].geometry,
+ new OpenLayers.Geometry.Point(-148, 75),
+ "[mousedown] correct feature");
// mouse up
handler.mouseup({type: "mouseup", xy: new OpenLayers.Pixel(2, 0)});
t.eq(logs.length, 2, "[mouseup] called back twice");
Modified: sandbox/elemoine/draw-feature/tests/Handler/Polygon.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Handler/Polygon.html 2011-02-13 22:09:08 UTC (rev 11115)
+++ sandbox/elemoine/draw-feature/tests/Handler/Polygon.html 2011-02-14 08:13:46 UTC (rev 11116)
@@ -109,7 +109,7 @@
}
function test_callbacks(t) {
- t.plan(38);
+ t.plan(45);
var map = new OpenLayers.Map("map", {
resolutions: [1]
});
@@ -164,7 +164,13 @@
// mouse down
handler.mousedown(
{type: "mousedown", xy: new OpenLayers.Pixel(0, 0)});
- t.eq(logs.length, 0, "[mousedown] not called back");
+ t.eq(logs.length, 1, "[mousedown] called back");
+ log = logs.shift();
+ t.eq(log.type, "modify", "[mousedown] modify called");
+ t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-150, 75),
+ "[mousedown] correct point");
+ t.ok(log.args[1] === handler.polygon,
+ "[mousedown] correct feature");
// mouse up
handler.mouseup(
{type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
@@ -202,6 +208,13 @@
// mouse down
handler.mousedown(
{type: "mousedown", xy: new OpenLayers.Pixel(10, 10)});
+ t.eq(logs.length, 1, "[mousedown] called back");
+ log = logs.shift();
+ t.eq(log.type, "modify", "[mousedown] modify called");
+ t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-140, 65),
+ "[mousedown] correct point");
+ t.ok(log.args[1] === handler.polygon,
+ "[mousedown] correct feature");
// mouse up
handler.mouseup(
{type: "mouseup", xy: new OpenLayers.Pixel(10, 10)});
@@ -221,7 +234,8 @@
// mouse down
handler.mousedown(
{type: "mousedown", xy: new OpenLayers.Pixel(0, 10)});
- t.eq(logs.length, 0, "[mousedown] not called back");
+ t.eq(logs.length, 1, "[mousedown] not called back");
+ log = logs.shift();
// mouse up
handler.mouseup(
{type: "mouseup", xy: new OpenLayers.Pixel(0, 10)});
@@ -551,7 +565,7 @@
trigger("dblclick", event);
// make assertions
- t.eq(log.length, 10, "a) correct number of events");
+ t.eq(log.length, 14, "a) correct number of events");
t.eq(log[log.length-1].type, "featureadded", "a) featureadded event last");
t.eq(log[log.length-1].feature.geometry.getArea(), 64, "a) correct polygon area");
@@ -584,7 +598,7 @@
trigger("dblclick", event);
// make assertions
- t.eq(log.length, 9, "b) correct number of events");
+ t.eq(log.length, 13, "b) correct number of events");
t.eq(log[log.length-1].type, "sketchcomplete", "b) sketchcomplete event last");
t.eq(log[log.length-1].feature.geometry.getArea(), 55, "b) correct polygon area");
@@ -618,7 +632,7 @@
trigger("dblclick", event);
// make assertions
- t.eq(log.length, 10, "c) correct number of events");
+ t.eq(log.length, 14, "c) correct number of events");
t.eq(log[log.length-1].type, "featureadded", "c) featureadded event last");
t.eq(log[log.length-1].feature.geometry.getArea(), 16, "c) correct polygon area");
@@ -656,7 +670,7 @@
trigger("dblclick", event);
// make assertions
- t.eq(log.length, 12, "d) correct number of events");
+ t.eq(log.length, 18, "d) correct number of events");
t.eq(log[log.length-1].type, "sketchcomplete", "d) sketchcomplete event last");
t.eq(log[log.length-1].feature.geometry.getArea(), 12, "d) correct polygon area");
More information about the Commits
mailing list