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:
crschmidt
2007-06-29 15:59:20 +00:00
parent f1c61fd0d6
commit 3948913bfc
107 changed files with 8658 additions and 4011 deletions
+33 -12
View File
@@ -3,28 +3,34 @@
* for the full text of the license. */
/**
* @requires OpenLayers/Handler.js
* @requires OpenLayers/Handler/Drag.js
*
* Class: OpenLayers.Handler.Box
* Handler for dragging a rectangle across the map. Box is displayed
* on mouse down, moves on mouse move, and is finished on mouse up.
*
* @class
* @requires OpenLayers/Handler.js
*
* Inherits from:
* - <OpenLayers.Handler>
*/
OpenLayers.Handler.Box = OpenLayers.Class.create();
OpenLayers.Handler.Box.prototype = OpenLayers.Class.inherit( OpenLayers.Handler, {
/**
* @type OpenLayers.Handler.Drag
*/
dragHandler: null,
/**
* Property: dragHandler
* {<OpenLayers.Handler.Drag>}
*/
dragHandler: null,
/**
* @constructor
* Constructor: OpenLayers.Handler.Box
*
* @param {OpenLayers.Control} control
* @param {Object} callbacks An object containing a single function to be
* Parameters:
* control - {<OpenLayers.Control>}
* callbacks - {Object} An object containing a single function to be
* called when the drag operation is finished.
* The callback should expect to recieve a single
* argument, the point geometry.
* @param {Object} options
* options - {Object}
*/
initialize: function(control, callbacks, options) {
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
@@ -38,6 +44,9 @@ OpenLayers.Handler.Box.prototype = OpenLayers.Class.inherit( OpenLayers.Handler,
this, callbacks, {keyMask: this.keyMask});
},
/**
* Method: setMap
*/
setMap: function (map) {
OpenLayers.Handler.prototype.setMap.apply(this, arguments);
if (this.dragHandler) {
@@ -46,7 +55,10 @@ OpenLayers.Handler.Box.prototype = OpenLayers.Class.inherit( OpenLayers.Handler,
},
/**
* @param {Event} evt
* Method: startBox
*
* Parameters:
* evt - {Event}
*/
startBox: function (xy) {
this.zoomBox = OpenLayers.Util.createDiv('zoomBox',
@@ -67,6 +79,7 @@ OpenLayers.Handler.Box.prototype = OpenLayers.Class.inherit( OpenLayers.Handler,
},
/**
* Method: moveBox
*/
moveBox: function (xy) {
var deltaX = Math.abs(this.dragHandler.start.x - xy.x);
@@ -82,6 +95,7 @@ OpenLayers.Handler.Box.prototype = OpenLayers.Class.inherit( OpenLayers.Handler,
},
/**
* Method: endBox
*/
endBox: function(end) {
var result;
@@ -105,6 +119,7 @@ OpenLayers.Handler.Box.prototype = OpenLayers.Class.inherit( OpenLayers.Handler,
},
/**
* Method: removeBox
* Remove the zoombox from the screen and nullify our reference to it.
*/
removeBox: function() {
@@ -112,6 +127,9 @@ OpenLayers.Handler.Box.prototype = OpenLayers.Class.inherit( OpenLayers.Handler,
this.zoomBox = null;
},
/**
* Method: activate
*/
activate: function () {
if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {
this.dragHandler.activate();
@@ -121,6 +139,9 @@ OpenLayers.Handler.Box.prototype = OpenLayers.Class.inherit( OpenLayers.Handler,
}
},
/**
* Method: deactivate
*/
deactivate: function () {
if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
this.dragHandler.deactivate();
+62 -38
View File
@@ -3,54 +3,62 @@
* for the full text of the license. */
/**
* Handler for dragging a rectangle across the map. Drag is displayed
* on mouse down, moves on mouse move, and is finished on mouse up.
*
* @class
* @requires OpenLayers/Handler.js
* @requires OpenLayers/Events.js
*
* Class: OpenLayers.Handler.Drag
*/
OpenLayers.Handler.Drag = OpenLayers.Class.create();
OpenLayers.Handler.Drag.prototype = OpenLayers.Class.inherit( OpenLayers.Handler, {
/**
* When a mousedown event is received, we want to record it, but not set
* 'dragging' until the mouse moves after starting.
*
* @type Boolean
* Property: started
* {Boolean} When a mousedown event is received, we want to record it, but
* not set 'dragging' until the mouse moves after starting.
**/
started: false,
/** @type Boolean **/
dragging: false,
/**
* Property: dragging
* {Boolean}
*/
dragging: false,
/** @type OpenLayers.Pixel **/
start: null,
/**
* Property: start
* {<OpenLayers.Pixel>}
*/
start: null,
/**
* @type Function
* @private
* Property: oldOnselectstart
* *Private*. {Function}
*/
oldOnselectstart: null,
/**
* @constructor
*
* @param {OpenLayers.Control} control
* @param {Object} callbacks An object containing a single function to be
* Constructor: OpenLayers.Handler.Drag
* Returns OpenLayers.Handler.Drag
*
* Parameters:
* control - {<OpenLayers.Control>}
* callbacks - {Object} An object containing a single function to be
* called when the drag operation is finished.
* The callback should expect to recieve a single
* argument, the point geometry.
* @param {Object} options
* options - {Object}
*/
initialize: function(control, callbacks, options) {
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
},
/**
* Method: mousedown
* Handle mousedown events
* @param {Event} evt
* @type Boolean
* @return Should the event propagate
*
* Parameters:
* evt - {Event}
*
* Return: {Boolean} Should the event propagate
*/
mousedown: function (evt) {
if (this.checkModifiers(evt) && OpenLayers.Event.isLeftClick(evt)) {
@@ -67,10 +75,13 @@ OpenLayers.Handler.Drag.prototype = OpenLayers.Class.inherit( OpenLayers.Handler
},
/**
* Method: mousemove
* Handle mousemove events
* @param {Event} evt
* @type Boolean
* @return Should the event propagate
*
* Parameters:
* evt - {Event}
*
* Return: {Boolean} Should the event propagate
*/
mousemove: function (evt) {
if (this.started) {
@@ -85,10 +96,13 @@ OpenLayers.Handler.Drag.prototype = OpenLayers.Class.inherit( OpenLayers.Handler
},
/**
* Method: mouseup
* Handle mouseup events
* @param {Event} evt
* @type Boolean
* @return Should the event propagate
*
* Parameters:
* evt - {Event}
*
* Return: {Boolean} Should the event propagate
*/
mouseup: function (evt) {
if (this.started) {
@@ -102,10 +116,13 @@ OpenLayers.Handler.Drag.prototype = OpenLayers.Class.inherit( OpenLayers.Handler
},
/**
* Method: mouseout
* Handle mouseout events
* @param {Event} evt
* @type Boolean
* @return Should the event propagate
*
* Parameters:
* evt - {Event}
*
* Return: {Boolean} Should the event propagate
*/
mouseout: function (evt) {
if (this.started && OpenLayers.Util.mouseLeft(evt, this.map.div)) {
@@ -122,12 +139,15 @@ OpenLayers.Handler.Drag.prototype = OpenLayers.Class.inherit( OpenLayers.Handler
},
/**
* Method: click
* The drag handler captures the click event. If something else registers
* for clicks on the same element, its listener will not be called after a
* drag.
* @param {Event} evt
* @type Boolean
* @return Should the event propagate
*
* Parameters:
* evt - {Event}
*
* Return: {Boolean} Should the event propagate
*/
click: function (evt) {
// throw away the first left click event that happens after a mouse up
@@ -140,9 +160,11 @@ OpenLayers.Handler.Drag.prototype = OpenLayers.Class.inherit( OpenLayers.Handler
},
/**
* Method: activate
* Activate the handler.
* @type Boolean
* @return Was activation successful. Returns false if already active.
*
* Return: {Boolean} Was activation successful. Returns false if already
* active.
*/
activate: function() {
if(OpenLayers.Handler.prototype.activate.apply(this, arguments)) {
@@ -154,9 +176,11 @@ OpenLayers.Handler.Drag.prototype = OpenLayers.Class.inherit( OpenLayers.Handler
},
/**
* Method: deactivate
* Deactivate the handler.
* @type Boolean
* @return Was deactivation successful. Returns false if not already active.
*
* Return: {Boolean} Was deactivation successful. Returns false if already
* active.
*/
deactivate: function() {
if(OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
+37 -20
View File
@@ -4,37 +4,40 @@
/**
* @requires OpenLayers/Handler.js
*
* Class: OpenLayers.Handler.Feature
* Handler to respond to mouse events related to a drawn feature.
* Callbacks will be called for over, move, out, up, and down (corresponding
* to the equivalent mouse events).
*
* @class
* @requires OpenLayers/Handler.js
*/
OpenLayers.Handler.Feature = OpenLayers.Class.create();
OpenLayers.Handler.Feature.prototype =
OpenLayers.Class.inherit(OpenLayers.Handler, {
/**
* @type {Int}
* Property: layerIndex
* {Int}
*/
layerIndex: null,
/**
* @type {OpenLayers.Feature.Vector}
* Property: feature
* {<OpenLayers.Feature.Vector>}
*/
feature: null,
/**
* @constructor
* Constructor: OpenLayers.Handler.Feature
*
* @param {OpenLayers.Control} control
* @param {Array} layers List of OpenLayers.Layer.Vector
* @param {Array} callbacks An object with a 'over' property whos value is
* Parameters:
* control - {<OpenLayers.Control>}
* layers - {Array} List of OpenLayers.Layer.Vector
* callbacks - {Array} 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 feature.
* @param {Object} options
* options - {Object}
*/
initialize: function(control, layer, callbacks, options) {
OpenLayers.Handler.prototype.initialize.apply(this, [control, callbacks, options]);
@@ -42,9 +45,11 @@ OpenLayers.Handler.Feature.prototype =
},
/**
* Method: mousedown
* Handle mouse down. Call the "down" callback if down on a feature.
*
* @param {Event} evt
* Parameters:
* evt - {Event}
*/
mousedown: function(evt) {
var selected = this.select('down', evt);
@@ -52,11 +57,13 @@ OpenLayers.Handler.Feature.prototype =
},
/**
* Method: mousemove
* Handle mouse moves. Call the "move" callback if moving over a feature.
* Call the "over" callback if moving over a feature for the first time.
* Call the "out" callback if moving off of a feature.
*
* @param {Event} evt
* Parameters:
* evt - {Event}
*/
mousemove: function(evt) {
this.select('move', evt);
@@ -64,9 +71,11 @@ OpenLayers.Handler.Feature.prototype =
},
/**
* Handle mouse moves. Call the "up" callback if up on a feature.
* Method: mouseup
* Handle mouse up. Call the "up" callback if up on a feature.
*
* @param {Event} evt
* Parameters:
* evt - {Event}
*/
mouseup: function(evt) {
var selected = this.select('up', evt);
@@ -74,11 +83,13 @@ OpenLayers.Handler.Feature.prototype =
},
/**
* Method: dblclick
* Capture double-clicks. Let the event continue propagating if the
* double-click doesn't hit a feature. Otherwise call the dblclick
* callback.
*
* @param {Event} evt
* Parameters:
* evt - {Event}
*/
dblclick: function(evt) {
var selected = this.select('dblclick', evt);
@@ -86,10 +97,14 @@ OpenLayers.Handler.Feature.prototype =
},
/**
* Method: select
* Trigger the appropriate callback if a feature is under the mouse.
*
* @param {String} type Callback key
* @type {Boolean} A feature was selected
* Parameters:
* type - {String} Callback key
*
* Return:
* {Boolean} A feature was selected
*/
select: function(type, evt) {
var feature = this.layer.getFeatureFromEvent(evt);
@@ -118,9 +133,10 @@ OpenLayers.Handler.Feature.prototype =
},
/**
* Method: activate
* Turn on the handler. Returns false if the handler was already active.
*
* @type {Boolean}
* Return: {Boolean}
*/
activate: function() {
if(OpenLayers.Handler.prototype.activate.apply(this, arguments)) {
@@ -133,9 +149,10 @@ OpenLayers.Handler.Feature.prototype =
},
/**
* Turn onf the handler. Returns false if the handler was already active.
* Method: activate
* Turn of the handler. Returns false if the handler was already active.
*
* @type {Boolean}
* Returns: {Boolean}
*/
deactivate: function() {
if(OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
+25 -8
View File
@@ -3,12 +3,13 @@
* for the full text of the license. */
/**
* Handler for dragging a rectangle across the map. Keyboard is displayed
* on mouse down, moves on mouse move, and is finished on mouse up.
*
* @class
* @requires OpenLayers/Handler.js
* @requires OpenLayers/Events.js
*
* Class: OpenLayers.handler.Keyboard
*
* Inherits from:
* - <OpenLayers.Handler>
*/
OpenLayers.Handler.Keyboard = OpenLayers.Class.create();
OpenLayers.Handler.Keyboard.prototype = OpenLayers.Class.inherit( OpenLayers.Handler, {
@@ -18,14 +19,21 @@ OpenLayers.Handler.Keyboard.prototype = OpenLayers.Class.inherit( OpenLayers.Han
/* supported named callbacks are: keyup, keydown, keypress */
/** constant */
/**
* Constant: KEY_EVENTS
* keydown, keypress, keyup
*/
KEY_EVENTS: ["keydown", "keypress", "keyup"],
/** @type Function
* @private
/**
* Property: eventListener
* *Private*. {Function}
*/
eventListener: null,
/**
* Constructor: OpenLayers.Handler.Keyboard
*/
initialize: function () {
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
// cache the bound event listener method so it can be unobserved later
@@ -33,7 +41,7 @@ OpenLayers.Handler.Keyboard.prototype = OpenLayers.Class.inherit( OpenLayers.Han
},
/**
*
* Method: destroy
*/
destroy: function() {
this.deactivate();
@@ -41,6 +49,9 @@ OpenLayers.Handler.Keyboard.prototype = OpenLayers.Class.inherit( OpenLayers.Han
OpenLayers.Control.prototype.destroy.apply(this, arguments);
},
/**
* Method: activate
*/
activate: function() {
if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {
for (var i = 0; i < this.KEY_EVENTS.length; i++) {
@@ -53,6 +64,9 @@ OpenLayers.Handler.Keyboard.prototype = OpenLayers.Class.inherit( OpenLayers.Han
}
},
/**
* Method: deactivate
*/
deactivate: function() {
if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
for (var i = 0; i < this.KEY_EVENTS.length; i++) {
@@ -65,6 +79,9 @@ OpenLayers.Handler.Keyboard.prototype = OpenLayers.Class.inherit( OpenLayers.Han
}
},
/**
* Method: handleKeyEvent
*/
handleKeyEvent: function (evt) {
if (this.checkModifiers(evt)) {
this.callback(evt.type, [evt.charCode || evt.keyCode]);
+42 -16
View File
@@ -3,33 +3,40 @@
* for the full text of the license. */
/**
* @requires OpenLayers/Handler.js
*
* Class: OpenLayers.Handler.MouseWheel
* Handler for wheel up/down events.
*
* @class
* @requires OpenLayers/Handler.js
* Inherits from:
* - <OpenLayers.Handler>
*/
OpenLayers.Handler.MouseWheel = OpenLayers.Class.create();
OpenLayers.Handler.MouseWheel.prototype = OpenLayers.Class.inherit( OpenLayers.Handler, {
/** @type function **/
/**
* Property: wheelListener
* {function}
*/
wheelListener: null,
/** @type OpenLayers.Pixel
* @private
*
* mousePosition is necessary because evt.clientX/Y is buggy in Moz on
* wheel events, so we cache and use the value from the last mousemove.
**/
/**
* Property: mousePosition
* *Private*. {<OpenLayers.Pixel>} mousePosition is necessary because
* evt.clientX/Y is buggy in Moz on wheel events, so we cache and use the
* value from the last mousemove.
*/
mousePosition: null,
/**
* @constructor
* Constructor: OpenLayers.Handler.MouseWheel
*
* @param {OpenLayers.Control} control
* @param {Object} callbacks An object containing a single function to be
* Parameters:
* control - {<OpenLayers.Control>}
* callbacks - {Object} An object containing a single function to be
* called when the drag operation is finished.
* The callback should expect to recieve a single
* argument, the point geometry.
* @param {Object} options
* options - {Object}
*/
initialize: function(control, callbacks, options) {
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
@@ -37,7 +44,7 @@ OpenLayers.Handler.MouseWheel.prototype = OpenLayers.Class.inherit( OpenLayers.H
},
/**
*
* Method: destroy
*/
destroy: function() {
this.deactivate();
@@ -49,9 +56,12 @@ OpenLayers.Handler.MouseWheel.prototype = OpenLayers.Class.inherit( OpenLayers.H
* Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/
*/
/** Catch the wheel event and handle it xbrowserly
/**
* Method: onWheelEvent
* Catch the wheel event and handle it xbrowserly
*
* @param {Event} e
* Parameters:
* e - {Event}
*/
onWheelEvent: function(e){
// first check keyboard modifiers
@@ -98,10 +108,23 @@ OpenLayers.Handler.MouseWheel.prototype = OpenLayers.Class.inherit( OpenLayers.H
}
},
/**
* Method: mousemove
* Update the stored mousePosition on every move.
*
* Parameters:
* evt - {Event} The browser event
*
* Return:
* {Boolean} Allow event propagation
*/
mousemove: function (evt) {
this.mousePosition = evt.xy;
},
/**
* Method: activate
*/
activate: function (evt) {
if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {
//register mousewheel events specifically on the window and document
@@ -115,6 +138,9 @@ OpenLayers.Handler.MouseWheel.prototype = OpenLayers.Class.inherit( OpenLayers.H
}
},
/**
* Method: deactivate
*/
deactivate: function (evt) {
if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
// unregister mousewheel events specifically on the window and document
+83 -55
View File
@@ -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"
});
+76 -38
View File
@@ -4,65 +4,73 @@
/**
* Handler to draw a point on the map. Point is displayed on mouse down,
* moves on mouse move, and is finished on mouse up.
*
* @class
* @requires OpenLayers/Handler.js
* @requires OpenLayers/Geometry/Point.js
*
* Class: OpenLayers.Handler.Point
* Handler to draw a point on the map. Point is displayed on mouse down,
* moves on mouse move, and is finished on mouse up. The handler triggers
* callbacks for 'done' and 'cancel'. Create a new instance with the
* <OpenLayers.Handler.Point> constructor.
*
* Inherits from:
* - <OpenLayers.Handler>
*/
OpenLayers.Handler.Point = OpenLayers.Class.create();
OpenLayers.Handler.Point.prototype =
OpenLayers.Class.inherit(OpenLayers.Handler, {
/**
* @type OpenLayers.Feature.Vector
* @private
* Property: point
* {<OpenLayers.Feature.Vector>} The currently drawn point
*/
point: null,
/**
* @type OpenLayers.Layer.Vector
* @private
* Property: layer
* {<OpenLayers.Layer.Vector>} The temporary drawing layer
*/
layer: null,
/**
* @type Boolean
* @private
* Property: drawing
* {Boolean} A point is being drawn
*/
drawing: false,
/**
* @type Boolean
* @private
* Property: mouseDown
* {Boolean} The mouse is down
*/
mouseDown: false,
/**
* @type OpenLayers.Pixel
* @private
* Property: lastDown
* {<OpenLayers.Pixel>} Location of the last mouse down
*/
lastDown: null,
/**
* @type OpenLayers.Pixel
* @private
* Property: lastUp
* {<OpenLayers.Pixel>}
*/
lastUp: null,
/**
* @constructor
* Constructor: OpenLayers.Handler.Point
* Create a new point handler.
*
* @param {OpenLayers.Control} control
* @param {Array} callbacks An object with a 'done' property whos value is
* a function to be called when the point drawing
* is finished. The callback should expect to
* recieve a single argument, the point geometry.
* 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>} The control that owns this handler
* callbacks - {Array} An object with a 'done' property whos value is a
* function to be called when the point drawing is finished.
* The callback should expect to recieve a single argument,
* the point geometry. 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) {
// TBD: deal with style
@@ -72,6 +80,7 @@ OpenLayers.Handler.Point.prototype =
},
/**
* APIMethod: activate
* turn on the handler
*/
activate: function() {
@@ -87,6 +96,7 @@ OpenLayers.Handler.Point.prototype =
},
/**
* Method: createFeature
* Add temporary features
*/
createFeature: function() {
@@ -95,6 +105,7 @@ OpenLayers.Handler.Point.prototype =
},
/**
* APIMethod: deactivate
* turn off the handler
*/
deactivate: function() {
@@ -111,6 +122,7 @@ OpenLayers.Handler.Point.prototype =
},
/**
* Method: destroyFeature
* Destroy the temporary geometries
*/
destroyFeature: function() {
@@ -118,6 +130,7 @@ OpenLayers.Handler.Point.prototype =
},
/**
* Method: finalize
* Finish the geometry and call the "done" callback.
*/
finalize: function() {
@@ -131,6 +144,7 @@ OpenLayers.Handler.Point.prototype =
},
/**
* APIMethod: cancel
* Finish the geometry and call the "cancel" callback.
*/
cancel: function() {
@@ -144,7 +158,14 @@ OpenLayers.Handler.Point.prototype =
},
/**
* Method: dblclick
* Handle double clicks.
*
* Parameters:
* evt - {Event} The browser event
*
* Return:
* {Boolean} Allow event propagation
*/
dblclick: function(evt) {
OpenLayers.Event.stop(evt);
@@ -152,6 +173,7 @@ OpenLayers.Handler.Point.prototype =
},
/**
* Method: drawFeature
* Render features on the temporary layer.
*/
drawFeature: function() {
@@ -159,20 +181,25 @@ OpenLayers.Handler.Point.prototype =
},
/**
* Method: geometryClone
* Return a clone of the relevant geometry.
*
* @type OpenLayers.Geometry.Point
* Return: {<OpenLayers.Geometry.Point>}
*/
geometryClone: function() {
return this.point.geometry.clone();
},
/**
* Handle mouse down. Add a new point to the geometry and render it.
* Method: mousedown
* Handle mouse down. 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
*/
mousedown: function(evt) {
// check keyboard modifiers
@@ -196,13 +223,17 @@ OpenLayers.Handler.Point.prototype =
},
/**
* Method: mousemove
* 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) {
mousemove: function (evt) {
if(this.drawing) {
var lonlat = this.map.getLonLatFromPixel(evt.xy);
this.point.geometry.x = lonlat.lon;
@@ -213,13 +244,17 @@ OpenLayers.Handler.Point.prototype =
},
/**
* Method: mouseup
* 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) {
mouseup: function (evt) {
if(this.drawing) {
this.finalize();
return false;
@@ -228,6 +263,9 @@ OpenLayers.Handler.Point.prototype =
}
},
/** @final @type String */
/**
* Constant: CLASS_NAME
* {String} Name of class.
*/
CLASS_NAME: "OpenLayers.Handler.Point"
});
+26 -12
View File
@@ -4,28 +4,34 @@
/**
* Handler to draw a path on the map. Polygon is displayed on mouse down,
* moves on mouse move, and is finished on mouse up.
*
* @class
* @requires OpenLayers/Handler/Path.js
* @requires OpenLayers/Geometry/Polygon.js
*
* Class: OpenLayers.Handler.Polygon
* Handler to draw a polygon on the map. Polygon is displayed on mouse down,
* moves on mouse move, and is finished on mouse up.
*
* Inherits from:
* - <OpenLayers.Handler.Path>
* - <OpenLayers.Handler>
*/
OpenLayers.Handler.Polygon = OpenLayers.Class.create();
OpenLayers.Handler.Polygon.prototype =
OpenLayers.Class.inherit(OpenLayers.Handler.Path, {
/**
* @type OpenLayers.Feature.Vector
* @private
* Parameter: polygon
* *Private*. {<OpenLayers.Feature.Vector>}
*/
polygon: null,
/**
* @constructor
* Constructor: OpenLayers.Handler.Polygon
* Create a Polygon Handler.
*
* @param {OpenLayers.Control} control
* @param {Array} callbacks An object with a 'done' property whos value is
* 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 polygon geometry.
@@ -35,13 +41,14 @@ OpenLayers.Handler.Polygon.prototype =
* 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
* options - {Object}
*/
initialize: function(control, callbacks, options) {
OpenLayers.Handler.Path.prototype.initialize.apply(this, arguments);
},
/**
* Method: createFeature
* Add temporary geometries
*/
createFeature: function() {
@@ -55,6 +62,7 @@ OpenLayers.Handler.Polygon.prototype =
},
/**
* Method: destroyFeature
* Destroy temporary geometries
*/
destroyFeature: function() {
@@ -63,6 +71,7 @@ OpenLayers.Handler.Polygon.prototype =
},
/**
* Method: modifyFeature
* Modify the existing geometry given the new point
*
*/
@@ -73,6 +82,7 @@ OpenLayers.Handler.Polygon.prototype =
},
/**
* Method: drawFeature
* Render geometries on the temporary layer.
*/
drawFeature: function() {
@@ -81,19 +91,23 @@ OpenLayers.Handler.Polygon.prototype =
},
/**
* Method: geometryClone
* Return a clone of the relevant geometry.
*
* @type OpenLayers.Geometry.Polygon
* Return:
* {<OpenLayers.Geometry.Polygon>}
*/
geometryClone: function() {
return this.polygon.geometry.clone();
},
/**
* Method: dblclick
* Handle double-clicks. Finish the geometry and send it back
* to the control.
*
* @param {Event} evt
* Parameters:
* evt - {Event}
*/
dblclick: function(evt) {
if(!this.freehandMode(evt)) {