Pullup r2999:3087 for RC2.

svn merge trunk/openlayers/@2999 trunk/openlayers/@HEAD branches/openlayers/2.4/



git-svn-id: http://svn.openlayers.org/branches/openlayers/2.4@3088 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-04-20 01:10:43 +00:00
parent b6fb16153c
commit b5103eb8ce
58 changed files with 1399 additions and 503 deletions

View File

@@ -99,7 +99,7 @@ OpenLayers.Handler.Box.prototype = OpenLayers.Class.inherit( OpenLayers.Handler,
this.removeBox();
// TBD: use CSS classes instead
this.map.div.style.cursor = "default";
this.map.div.style.cursor = "";
this.callback("done", [result]);
},

View File

@@ -76,11 +76,9 @@ OpenLayers.Handler.Drag.prototype = OpenLayers.Class.inherit( OpenLayers.Handler
if (this.started) {
this.dragging = true;
this.callback("move", [evt.xy]);
if(document.onselectstart) {
if(!this.oldOnselectstart) {
this.oldOnselectstart = document.onselectstart;
document.onselectstart = function() {return false;}
}
if(!this.oldOnselectstart) {
this.oldOnselectstart = document.onselectstart;
document.onselectstart = function() {return false;}
}
}
return true;
@@ -95,13 +93,10 @@ OpenLayers.Handler.Drag.prototype = OpenLayers.Class.inherit( OpenLayers.Handler
mouseup: function (evt) {
if (this.started) {
this.started = false;
this.dragging = false;
// TBD replace with CSS classes
this.map.div.style.cursor = "default";
this.map.div.style.cursor = "";
this.callback("up", [evt.xy]);
if(document.onselectstart) {
document.onselectstart = this.oldOnselectstart;
}
document.onselectstart = this.oldOnselectstart;
}
return true;
},
@@ -117,7 +112,7 @@ OpenLayers.Handler.Drag.prototype = OpenLayers.Class.inherit( OpenLayers.Handler
this.started = false;
this.dragging = false;
// TBD replace with CSS classes
this.map.div.style.cursor = "default";
this.map.div.style.cursor = "";
this.callback("out", []);
if(document.onselectstart) {
document.onselectstart = this.oldOnselectstart;
@@ -136,8 +131,8 @@ OpenLayers.Handler.Drag.prototype = OpenLayers.Class.inherit( OpenLayers.Handler
*/
click: function (evt) {
// throw away the first left click event that happens after a mouse up
if (OpenLayers.Event.isLeftClick(evt) && this.dragging) {
this.dragging = true;
if (this.dragging) {
this.dragging = false;
return false;
}
this.started = false;

View File

@@ -21,9 +21,9 @@ OpenLayers.Handler.Feature.prototype =
layerIndex: null,
/**
* @type {OpenLayers.Geometry}
* @type {OpenLayers.Feature.Vector}
*/
geometry: null,
feature: null,
/**
* @constructor
@@ -33,7 +33,7 @@ OpenLayers.Handler.Feature.prototype =
* @param {Array} callbacks An object with a 'over' property whos value is
* a function to be called when the mouse is over
* a feature. The callback should expect to recieve
* a single argument, the geometry.
* a single argument, the feature.
* @param {Object} options
*/
initialize: function(control, layer, callbacks, options) {
@@ -75,7 +75,7 @@ OpenLayers.Handler.Feature.prototype =
/**
* Capture double-clicks. Let the event continue propagating if the
* double-click doesn't hit a geometry. Otherwise call the dblclick
* double-click doesn't hit a feature. Otherwise call the dblclick
* callback.
*
* @param {Event} evt
@@ -92,26 +92,26 @@ OpenLayers.Handler.Feature.prototype =
* @type {Boolean} A feature was selected
*/
select: function(type, evt) {
var geometry = this.layer.renderer.getGeometryFromEvent(evt);
if(geometry) {
var feature = this.layer.getFeatureFromEvent(evt);
if(feature) {
// three cases:
// over a new, out of the last and over a new, or still on the last
if(!this.geometry) {
// over a new geometry
this.callback('over', [geometry]);
} else if(this.geometry != geometry) {
if(!this.feature) {
// over a new feature
this.callback('over', [feature]);
} else if(this.feature != feature) {
// out of the last and over a new
this.callback('out', [this.geometry]);
this.callback('over', [geometry]);
this.callback('out', [this.feature]);
this.callback('over', [feature]);
}
this.geometry = geometry;
this.callback(type, [geometry]);
this.feature = feature;
this.callback(type, [feature]);
return true;
} else {
if(this.geometry) {
if(this.feature) {
// out of the last
this.callback('out', [this.geometry]);
this.geometry = null;
this.callback('out', [this.feature]);
this.feature = null;
}
return false;
}

View File

@@ -17,7 +17,7 @@ OpenLayers.Handler.Path.prototype =
OpenLayers.Class.inherit(OpenLayers.Handler.Point, {
/**
* @type OpenLayers.Geometry.LineString
* @type OpenLayers.Feature.Vector
* @private
*/
line: null,
@@ -65,15 +65,17 @@ OpenLayers.Handler.Path.prototype =
/**
* Add temporary geometries
*/
createGeometry: function() {
this.line = new OpenLayers.Geometry.LineString();
this.point = new OpenLayers.Geometry.Point();
createFeature: function() {
this.line = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.LineString());
this.point = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point());
},
/**
* Destroy temporary geometries
*/
destroyGeometry: function() {
destroyFeature: function() {
this.line.destroy();
this.point.destroy();
},
@@ -83,7 +85,9 @@ OpenLayers.Handler.Path.prototype =
* the behavior of LinearRing that disregards adding duplicate points.
*/
addPoint: function() {
this.line.addComponent(this.point.clone(), this.line.components.length);
this.line.geometry.addComponent(this.point.geometry.clone(),
this.line.geometry.components.length);
this.callback("point", [this.point.geometry]);
},
/**
@@ -100,18 +104,18 @@ OpenLayers.Handler.Path.prototype =
* Modify the existing geometry given the new point
*
*/
modifyGeometry: function() {
var index = this.line.components.length - 1;
this.line.components[index].x = this.point.x;
this.line.components[index].y = this.point.y;
modifyFeature: function() {
var index = this.line.geometry.components.length - 1;
this.line.geometry.components[index].x = this.point.geometry.x;
this.line.geometry.components[index].y = this.point.geometry.y;
},
/**
* Render geometries on the temporary layer.
*/
drawGeometry: function() {
this.layer.renderer.drawGeometry(this.line, this.style);
this.layer.renderer.drawGeometry(this.point, this.style);
drawFeature: function() {
this.layer.drawFeature(this.line, this.style);
this.layer.drawFeature(this.point, this.style);
},
/**
@@ -120,7 +124,7 @@ OpenLayers.Handler.Path.prototype =
* @type OpenLayers.Geometry.LineString
*/
geometryClone: function() {
return this.line.clone();
return this.line.geometry.clone();
},
/**
@@ -136,17 +140,17 @@ OpenLayers.Handler.Path.prototype =
return false;
}
if(this.lastDown == null) {
this.createGeometry();
this.createFeature();
}
this.mouseDown = true;
this.lastDown = evt.xy;
var lonlat = this.control.map.getLonLatFromPixel(evt.xy);
this.point.x = lonlat.lon;
this.point.y = lonlat.lat;
this.point.geometry.x = lonlat.lon;
this.point.geometry.y = lonlat.lat;
if((this.lastUp == null) || !this.lastUp.equals(evt.xy)) {
this.addPoint();
}
this.drawGeometry();
this.drawFeature();
this.drawing = true;
return false;
},
@@ -161,14 +165,14 @@ OpenLayers.Handler.Path.prototype =
mousemove: function (evt) {
if(this.drawing) {
var lonlat = this.map.getLonLatFromPixel(evt.xy);
this.point.x = lonlat.lon;
this.point.y = lonlat.lat;
this.point.geometry.x = lonlat.lon;
this.point.geometry.y = lonlat.lat;
if(this.mouseDown && this.freehandMode(evt)) {
this.addPoint();
} else {
this.modifyGeometry();
this.modifyFeature();
}
this.drawGeometry();
this.drawFeature();
}
return true;
},
@@ -190,7 +194,6 @@ OpenLayers.Handler.Path.prototype =
this.addPoint();
}
this.lastUp = evt.xy;
this.callback("point", [this.point]);
}
return false;
}
@@ -205,9 +208,9 @@ OpenLayers.Handler.Path.prototype =
*/
dblclick: function(evt) {
if(!this.freehandMode(evt)) {
var index = this.line.components.length - 1;
this.line.removeComponent(this.line.components[index]);
this.finalize(this.line);
var index = this.line.geometry.components.length - 1;
this.line.geometry.removeComponent(this.line.geometry.components[index]);
this.finalize();
}
return false;
},

View File

@@ -16,7 +16,7 @@ OpenLayers.Handler.Point.prototype =
OpenLayers.Class.inherit(OpenLayers.Handler, {
/**
* @type OpenLayers.Geometry.Point
* @type OpenLayers.Feature.Vector
* @private
*/
point: null,
@@ -87,10 +87,11 @@ OpenLayers.Handler.Point.prototype =
},
/**
* Add temporary geometries
* Add temporary features
*/
createGeometry: function() {
this.point = new OpenLayers.Geometry.Point();
createFeature: function() {
this.point = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point());
},
/**
@@ -112,7 +113,7 @@ OpenLayers.Handler.Point.prototype =
/**
* Destroy the temporary geometries
*/
destroyGeometry: function() {
destroyFeature: function() {
this.point.destroy();
},
@@ -122,7 +123,7 @@ OpenLayers.Handler.Point.prototype =
finalize: function() {
this.layer.renderer.clear();
this.callback("done", [this.geometryClone()]);
this.destroyGeometry();
this.destroyFeature();
this.drawing = false;
this.mouseDown = false;
this.lastDown = null;
@@ -135,7 +136,7 @@ OpenLayers.Handler.Point.prototype =
cancel: function() {
this.layer.renderer.clear();
this.callback("cancel", [this.geometryClone()]);
this.destroyGeometry();
this.destroyFeature();
this.drawing = false;
this.mouseDown = false;
this.lastDown = null;
@@ -151,10 +152,10 @@ OpenLayers.Handler.Point.prototype =
},
/**
* Render geometries on the temporary layer.
* Render features on the temporary layer.
*/
drawGeometry: function() {
this.layer.renderer.drawGeometry(this.point, this.style);
drawFeature: function() {
this.layer.drawFeature(this.point, this.style);
},
/**
@@ -163,7 +164,7 @@ OpenLayers.Handler.Point.prototype =
* @type OpenLayers.Geometry.Point
*/
geometryClone: function() {
return this.point.clone();
return this.point.geometry.clone();
},
/**
@@ -183,14 +184,14 @@ OpenLayers.Handler.Point.prototype =
return true;
}
if(this.lastDown == null) {
this.createGeometry();
this.createFeature();
}
this.lastDown = evt.xy;
this.drawing = true;
var lonlat = this.map.getLonLatFromPixel(evt.xy);
this.point.x = lonlat.lon;
this.point.y = lonlat.lat;
this.drawGeometry();
this.point.geometry.x = lonlat.lon;
this.point.geometry.y = lonlat.lat;
this.drawFeature();
return false;
},
@@ -204,9 +205,9 @@ OpenLayers.Handler.Point.prototype =
mousemove: function (evt) {
if(this.drawing) {
var lonlat = this.map.getLonLatFromPixel(evt.xy);
this.point.x = lonlat.lon;
this.point.y = lonlat.lat;
this.drawGeometry();
this.point.geometry.x = lonlat.lon;
this.point.geometry.y = lonlat.lat;
this.drawFeature();
}
return true;
},
@@ -220,7 +221,7 @@ OpenLayers.Handler.Point.prototype =
*/
mouseup: function (evt) {
if(this.drawing) {
this.finalize(this.point);
this.finalize();
return false;
} else {
return true;

View File

@@ -16,7 +16,7 @@ OpenLayers.Handler.Polygon.prototype =
OpenLayers.Class.inherit(OpenLayers.Handler.Path, {
/**
* @type OpenLayers.Geometry.Polygon
* @type OpenLayers.Feature.Vector
* @private
*/
polygon: null,
@@ -44,17 +44,20 @@ OpenLayers.Handler.Polygon.prototype =
/**
* Add temporary geometries
*/
createGeometry: function() {
this.polygon = new OpenLayers.Geometry.Polygon();
this.line = new OpenLayers.Geometry.LinearRing();
this.polygon.addComponent(this.line);
this.point = new OpenLayers.Geometry.Point();
createFeature: function() {
this.polygon = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Polygon());
this.line = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.LinearRing());
this.polygon.geometry.addComponent(this.line.geometry);
this.point = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point());
},
/**
* Destroy temporary geometries
*/
destroyGeometry: function() {
destroyFeature: function() {
this.polygon.destroy();
this.point.destroy();
},
@@ -63,18 +66,18 @@ OpenLayers.Handler.Polygon.prototype =
* Modify the existing geometry given the new point
*
*/
modifyGeometry: function() {
var index = this.line.components.length - 2;
this.line.components[index].x = this.point.x;
this.line.components[index].y = this.point.y;
modifyFeature: function() {
var index = this.line.geometry.components.length - 2;
this.line.geometry.components[index].x = this.point.geometry.x;
this.line.geometry.components[index].y = this.point.geometry.y;
},
/**
* Render geometries on the temporary layer.
*/
drawGeometry: function() {
this.layer.renderer.drawGeometry(this.polygon, this.style);
this.layer.renderer.drawGeometry(this.point, this.style);
drawFeature: function() {
this.layer.drawFeature(this.polygon, this.style);
this.layer.drawFeature(this.point, this.style);
},
/**
@@ -83,7 +86,7 @@ OpenLayers.Handler.Polygon.prototype =
* @type OpenLayers.Geometry.Polygon
*/
geometryClone: function() {
return this.polygon.clone();
return this.polygon.geometry.clone();
},
/**
@@ -95,9 +98,9 @@ OpenLayers.Handler.Polygon.prototype =
dblclick: function(evt) {
if(!this.freehandMode(evt)) {
// remove the penultimate point
var index = this.line.components.length - 2;
this.line.removeComponent(this.line.components[index]);
this.finalize(this.line);
var index = this.line.geometry.components.length - 2;
this.line.geometry.removeComponent(this.line.geometry.components[index]);
this.finalize();
}
return false;
},