Merge all changes from the naturaldocs sandbox. This brings all the work that
has been done in the NaturalDocs branch back to trunk. Thanks to everyone who helped out in making this happen. (I could list people, but the list would be long, and I'm already mentally on vacation.) git-svn-id: http://svn.openlayers.org/trunk/openlayers@3545 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -4,66 +4,69 @@
|
||||
|
||||
|
||||
/**
|
||||
* Handler to draw a path on the map. Path is displayed on mouse down,
|
||||
* moves on mouse move, and is finished on mouse up.
|
||||
*
|
||||
* @class
|
||||
* @requires OpenLayers/Handler/Point.js
|
||||
* @requires OpenLayers/Geometry/Point.js
|
||||
* @requires OpenLayers/Geometry/LineString.js
|
||||
*
|
||||
* Class: OpenLayers.Handler.Path
|
||||
* Handler to draw a path on the map. Path is displayed on mouse down,
|
||||
* moves on mouse move, and is finished on mouse up.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Handler.Point>
|
||||
*/
|
||||
OpenLayers.Handler.Path = OpenLayers.Class.create();
|
||||
OpenLayers.Handler.Path.prototype =
|
||||
OpenLayers.Class.inherit(OpenLayers.Handler.Point, {
|
||||
|
||||
/**
|
||||
* @type OpenLayers.Feature.Vector
|
||||
* @private
|
||||
* Property: line
|
||||
* *Private*. {<OpenLayers.Feature.Vector>}
|
||||
*/
|
||||
line: null,
|
||||
|
||||
/**
|
||||
* In freehand mode, the handler starts the path on mouse down, adds a point
|
||||
* for every mouse move, and finishes the path on mouse up. Outside of
|
||||
* freehand mode, a point is added to the path on every mouse click and
|
||||
* double-click finishes the path.
|
||||
*
|
||||
* @type Boolean
|
||||
* Property: freehand
|
||||
* {Boolean} In freehand mode, the handler starts the path on mouse down,
|
||||
* adds a point for every mouse move, and finishes the path on mouse up.
|
||||
* Outside of freehand mode, a point is added to the path on every mouse
|
||||
* click and double-click finishes the path.
|
||||
*/
|
||||
freehand: false,
|
||||
|
||||
/**
|
||||
* If set, freehandToggle is checked on mouse events and will set the
|
||||
* freehand mode to the opposite of this.freehand. To disallow toggling
|
||||
* between freehand and non-freehand mode, set freehandToggle to null.
|
||||
* Acceptable toggle values are 'shiftKey', 'ctrlKey', and 'altKey'.
|
||||
*
|
||||
* @type String
|
||||
* Property: freehandToggle
|
||||
* {String} If set, freehandToggle is checked on mouse events and will set
|
||||
* the freehand mode to the opposite of this.freehand. To disallow
|
||||
* toggling between freehand and non-freehand mode, set freehandToggle to
|
||||
* null. Acceptable toggle values are 'shiftKey', 'ctrlKey', and 'altKey'.
|
||||
*/
|
||||
freehandToggle: 'shiftKey',
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* Constructor: OpenLayers.Handler.Path
|
||||
* Create a new path hander
|
||||
*
|
||||
* @param {OpenLayers.Control} control
|
||||
* @param {Array} callbacks An object with a 'done' property whos value is
|
||||
* a function to be called when the path drawing is
|
||||
* finished. The callback should expect to recieve a
|
||||
* single argument, the line string geometry.
|
||||
* If the callbacks object contains a 'point'
|
||||
* property, this function will be sent each point
|
||||
* as they are added. If the callbacks object contains
|
||||
* a 'cancel' property, this function will be called when
|
||||
* the handler is deactivated while drawing. The cancel
|
||||
* should expect to receive a geometry.
|
||||
* @param {Object} options
|
||||
* Parameters:
|
||||
* control - {<OpenLayers.Control>}
|
||||
* callbacks - {Array} An object with a 'done' property whos value is a
|
||||
* function to be called when the path drawing is finished. The callback
|
||||
* should expect to recieve a single argument, the line string geometry.
|
||||
* If the callbacks object contains a 'point' property, this function will
|
||||
* be sent each point as they are added. If the callbacks object contains
|
||||
* a 'cancel' property, this function will be called when the handler is
|
||||
* deactivated while drawing. The cancel should expect to receive a
|
||||
* geometry.
|
||||
* options - {Object} An optional object with properties to be set on the
|
||||
* handler
|
||||
*/
|
||||
initialize: function(control, callbacks, options) {
|
||||
OpenLayers.Handler.Point.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Add temporary geometries
|
||||
* Method: createFeature
|
||||
* *Private*. Add temporary geometries
|
||||
*/
|
||||
createFeature: function() {
|
||||
this.line = new OpenLayers.Feature.Vector(
|
||||
@@ -73,7 +76,8 @@ OpenLayers.Handler.Path.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroy temporary geometries
|
||||
* Method: destroyFeature
|
||||
* *Private*. Destroy temporary geometries
|
||||
*/
|
||||
destroyFeature: function() {
|
||||
this.line.destroy();
|
||||
@@ -81,7 +85,8 @@ OpenLayers.Handler.Path.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* Add point to geometry. Send the point index to override
|
||||
* Method: addPoint
|
||||
* *Private*. Add point to geometry. Send the point index to override
|
||||
* the behavior of LinearRing that disregards adding duplicate points.
|
||||
*/
|
||||
addPoint: function() {
|
||||
@@ -91,9 +96,10 @@ OpenLayers.Handler.Path.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine whether to behanve in freehand mode or not.
|
||||
* Method: freehandMode
|
||||
* *Private*. Determine whether to behave in freehand mode or not.
|
||||
*
|
||||
* @type Boolean
|
||||
* Return: {Boolean}
|
||||
*/
|
||||
freehandMode: function(evt) {
|
||||
return (this.freehandToggle && evt[this.freehandToggle]) ?
|
||||
@@ -101,8 +107,8 @@ OpenLayers.Handler.Path.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* Modify the existing geometry given the new point
|
||||
*
|
||||
* Method: modifyFeature
|
||||
* *Private*. Modify the existing geometry given the new point
|
||||
*/
|
||||
modifyFeature: function() {
|
||||
var index = this.line.geometry.components.length - 1;
|
||||
@@ -111,7 +117,8 @@ OpenLayers.Handler.Path.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* Render geometries on the temporary layer.
|
||||
* Method: drawFeature
|
||||
* *Private*. Render geometries on the temporary layer.
|
||||
*/
|
||||
drawFeature: function() {
|
||||
this.layer.drawFeature(this.line, this.style);
|
||||
@@ -119,20 +126,25 @@ OpenLayers.Handler.Path.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a clone of the relevant geometry.
|
||||
* Method: geometryClone
|
||||
* *Private*. Return a clone of the relevant geometry.
|
||||
*
|
||||
* @type OpenLayers.Geometry.LineString
|
||||
* Return: {<OpenLayers.Geometry.LineString>}
|
||||
*/
|
||||
geometryClone: function() {
|
||||
return this.line.geometry.clone();
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle mouse down. Add a new point to the geometry and render it.
|
||||
* Return determines whether to propagate the event on the map.
|
||||
* Method: mousedown
|
||||
* *Private*. Handle mouse down. Add a new point to the geometry and
|
||||
* render it. Return determines whether to propagate the event on the map.
|
||||
*
|
||||
* @param {Event} evt
|
||||
* @type Boolean
|
||||
* Parameters:
|
||||
* evt - {Event} The browser event
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} Allow event propagation
|
||||
*/
|
||||
mousedown: function(evt) {
|
||||
// ignore double-clicks
|
||||
@@ -156,11 +168,15 @@ OpenLayers.Handler.Path.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle mouse move. Adjust the geometry and redraw.
|
||||
* Method: mousemove
|
||||
* *Private*. Handle mouse move. Adjust the geometry and redraw.
|
||||
* Return determines whether to propagate the event on the map.
|
||||
*
|
||||
* @param {Event} evt
|
||||
* @type Boolean
|
||||
* Parameters:
|
||||
* evt - {Event} The browser event
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} Allow event propagation
|
||||
*/
|
||||
mousemove: function (evt) {
|
||||
if(this.drawing) {
|
||||
@@ -178,11 +194,15 @@ OpenLayers.Handler.Path.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle mouse up. Send the latest point in the geometry to the control.
|
||||
* Return determines whether to propagate the event on the map.
|
||||
* Method: mouseup
|
||||
* *Private*. Handle mouse up. Send the latest point in the geometry to
|
||||
* the control. Return determines whether to propagate the event on the map.
|
||||
*
|
||||
* @param {Event} evt
|
||||
* @type Boolean
|
||||
* Parameters:
|
||||
* evt - {Event} The browser event
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} Allow event propagation
|
||||
*/
|
||||
mouseup: function (evt) {
|
||||
this.mouseDown = false;
|
||||
@@ -201,10 +221,15 @@ OpenLayers.Handler.Path.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle double-clicks. Finish the geometry and send it back
|
||||
* Method: dblclick
|
||||
* *Private*. Handle double-clicks. Finish the geometry and send it back
|
||||
* to the control.
|
||||
*
|
||||
* @param {Event} evt
|
||||
* Parameters:
|
||||
* evt - {Event} The browser event
|
||||
*
|
||||
* Return:
|
||||
* {Boolean} Allow event propagation
|
||||
*/
|
||||
dblclick: function(evt) {
|
||||
if(!this.freehandMode(evt)) {
|
||||
@@ -215,6 +240,9 @@ OpenLayers.Handler.Path.prototype =
|
||||
return false;
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
/**
|
||||
* Constant: CLASS_NAME
|
||||
* {String} Name of class.
|
||||
*/
|
||||
CLASS_NAME: "OpenLayers.Handler.Path"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user