Rename ol.interaction.DrawMode to ol.interaction.Draw.Mode

This commit is contained in:
Frederic Junod
2016-09-07 16:38:16 +02:00
parent 9a9b22ec5e
commit 3e4ed489a4
2 changed files with 32 additions and 32 deletions

View File

@@ -17,6 +17,7 @@ A number of internal types have been renamed. This will not affect those who us
* rename `ol.OverlayProperty` to `ol.Overlay.Property`
* rename `ol.control.MousePositionProperty` to `ol.control.MousePosition.Property`
* rename `ol.format.IGCZ` to `ol.format.IGC.Z`
* rename `ol.interaction.DrawMode` to `ol.interaction.Draw.Mode`
* rename `ol.interaction.ExtentEvent` to `ol.interaction.Extent.Event`
* rename `ol.interaction.ExtentEventType` to `ol.interaction.Extent.EventType`
* rename `ol.interaction.DragAndDropEvent` to `ol.interaction.DragAndDrop.Event`

View File

@@ -1,7 +1,6 @@
goog.provide('ol.interaction.Draw');
goog.provide('ol.interaction.DrawEvent');
goog.provide('ol.interaction.DrawEventType');
goog.provide('ol.interaction.DrawMode');
goog.require('ol');
goog.require('ol.events');
@@ -132,7 +131,7 @@ ol.interaction.Draw = function(options) {
/**
* Drawing mode (derived from geometry type.
* @type {ol.interaction.DrawMode}
* @type {ol.interaction.Draw.Mode}
* @private
*/
this.mode_ = ol.interaction.Draw.getMode_(this.type_);
@@ -146,7 +145,7 @@ ol.interaction.Draw = function(options) {
*/
this.minPoints_ = options.minPoints ?
options.minPoints :
(this.mode_ === ol.interaction.DrawMode.POLYGON ? 3 : 2);
(this.mode_ === ol.interaction.Draw.Mode.POLYGON ? 3 : 2);
/**
* The number of points that can be drawn before a polygon ring or line string
@@ -183,11 +182,11 @@ ol.interaction.Draw = function(options) {
} else {
var Constructor;
var mode = this.mode_;
if (mode === ol.interaction.DrawMode.POINT) {
if (mode === ol.interaction.Draw.Mode.POINT) {
Constructor = ol.geom.Point;
} else if (mode === ol.interaction.DrawMode.LINE_STRING) {
} else if (mode === ol.interaction.Draw.Mode.LINE_STRING) {
Constructor = ol.geom.LineString;
} else if (mode === ol.interaction.DrawMode.POLYGON) {
} else if (mode === ol.interaction.Draw.Mode.POLYGON) {
Constructor = ol.geom.Polygon;
}
/**
@@ -339,8 +338,8 @@ ol.interaction.Draw.prototype.setMap = function(map) {
* @api
*/
ol.interaction.Draw.handleEvent = function(mapBrowserEvent) {
if ((this.mode_ === ol.interaction.DrawMode.LINE_STRING ||
this.mode_ === ol.interaction.DrawMode.POLYGON) &&
if ((this.mode_ === ol.interaction.Draw.Mode.LINE_STRING ||
this.mode_ === ol.interaction.Draw.Mode.POLYGON) &&
this.freehandCondition_(mapBrowserEvent)) {
this.freehand_ = true;
}
@@ -399,10 +398,10 @@ ol.interaction.Draw.handleUpEvent_ = function(event) {
this.handlePointerMove_(event);
if (!this.finishCoordinate_) {
this.startDrawing_(event);
if (this.mode_ === ol.interaction.DrawMode.POINT) {
if (this.mode_ === ol.interaction.Draw.Mode.POINT) {
this.finishDrawing();
}
} else if (this.mode_ === ol.interaction.DrawMode.CIRCLE) {
} else if (this.mode_ === ol.interaction.Draw.Mode.CIRCLE) {
this.finishDrawing();
} else if (this.atFinish_(event)) {
if (this.finishCondition_(event)) {
@@ -444,9 +443,9 @@ ol.interaction.Draw.prototype.atFinish_ = function(event) {
if (this.sketchFeature_) {
var potentiallyDone = false;
var potentiallyFinishCoordinates = [this.finishCoordinate_];
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
if (this.mode_ === ol.interaction.Draw.Mode.LINE_STRING) {
potentiallyDone = this.sketchCoords_.length > this.minPoints_;
} else if (this.mode_ === ol.interaction.DrawMode.POLYGON) {
} else if (this.mode_ === ol.interaction.Draw.Mode.POLYGON) {
potentiallyDone = this.sketchCoords_[0].length >
this.minPoints_;
potentiallyFinishCoordinates = [this.sketchCoords_[0][0],
@@ -498,14 +497,14 @@ ol.interaction.Draw.prototype.createOrUpdateSketchPoint_ = function(event) {
ol.interaction.Draw.prototype.startDrawing_ = function(event) {
var start = event.coordinate;
this.finishCoordinate_ = start;
if (this.mode_ === ol.interaction.DrawMode.POINT) {
if (this.mode_ === ol.interaction.Draw.Mode.POINT) {
this.sketchCoords_ = start.slice();
} else if (this.mode_ === ol.interaction.DrawMode.POLYGON) {
} else if (this.mode_ === ol.interaction.Draw.Mode.POLYGON) {
this.sketchCoords_ = [[start.slice(), start.slice()]];
this.sketchLineCoords_ = this.sketchCoords_[0];
} else {
this.sketchCoords_ = [start.slice(), start.slice()];
if (this.mode_ === ol.interaction.DrawMode.CIRCLE) {
if (this.mode_ === ol.interaction.Draw.Mode.CIRCLE) {
this.sketchLineCoords_ = this.sketchCoords_;
}
}
@@ -535,9 +534,9 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
var coordinate = event.coordinate;
var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry());
var coordinates, last;
if (this.mode_ === ol.interaction.DrawMode.POINT) {
if (this.mode_ === ol.interaction.Draw.Mode.POINT) {
last = this.sketchCoords_;
} else if (this.mode_ === ol.interaction.DrawMode.POLYGON) {
} else if (this.mode_ === ol.interaction.Draw.Mode.POLYGON) {
coordinates = this.sketchCoords_[0];
last = coordinates[coordinates.length - 1];
if (this.atFinish_(event)) {
@@ -560,7 +559,7 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
}
var sketchLineGeom;
if (geometry instanceof ol.geom.Polygon &&
this.mode_ !== ol.interaction.DrawMode.POLYGON) {
this.mode_ !== ol.interaction.Draw.Mode.POLYGON) {
if (!this.sketchLine_) {
this.sketchLine_ = new ol.Feature(new ol.geom.LineString(null));
}
@@ -586,13 +585,13 @@ ol.interaction.Draw.prototype.addToDrawing_ = function(event) {
var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry());
var done;
var coordinates;
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
if (this.mode_ === ol.interaction.Draw.Mode.LINE_STRING) {
this.finishCoordinate_ = coordinate.slice();
coordinates = this.sketchCoords_;
coordinates.push(coordinate.slice());
done = coordinates.length > this.maxPoints_;
this.geometryFunction_(coordinates, geometry);
} else if (this.mode_ === ol.interaction.DrawMode.POLYGON) {
} else if (this.mode_ === ol.interaction.Draw.Mode.POLYGON) {
coordinates = this.sketchCoords_[0];
coordinates.push(coordinate.slice());
done = coordinates.length > this.maxPoints_;
@@ -615,11 +614,11 @@ ol.interaction.Draw.prototype.addToDrawing_ = function(event) {
ol.interaction.Draw.prototype.removeLastPoint = function() {
var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry());
var coordinates, sketchLineGeom;
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
if (this.mode_ === ol.interaction.Draw.Mode.LINE_STRING) {
coordinates = this.sketchCoords_;
coordinates.splice(-2, 1);
this.geometryFunction_(coordinates, geometry);
} else if (this.mode_ === ol.interaction.DrawMode.POLYGON) {
} else if (this.mode_ === ol.interaction.Draw.Mode.POLYGON) {
coordinates = this.sketchCoords_[0];
coordinates.splice(-2, 1);
sketchLineGeom = /** @type {ol.geom.LineString} */ (this.sketchLine_.getGeometry());
@@ -645,11 +644,11 @@ ol.interaction.Draw.prototype.finishDrawing = function() {
var sketchFeature = this.abortDrawing_();
var coordinates = this.sketchCoords_;
var geometry = /** @type {ol.geom.SimpleGeometry} */ (sketchFeature.getGeometry());
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
if (this.mode_ === ol.interaction.Draw.Mode.LINE_STRING) {
// remove the redundant last point
coordinates.pop();
this.geometryFunction_(coordinates, geometry);
} else if (this.mode_ === ol.interaction.DrawMode.POLYGON) {
} else if (this.mode_ === ol.interaction.Draw.Mode.POLYGON) {
// When we finish drawing a polygon on the last point,
// the last coordinate is duplicated as for LineString
// we force the replacement by the first point
@@ -708,7 +707,7 @@ ol.interaction.Draw.prototype.abortDrawing_ = function() {
*/
ol.interaction.Draw.prototype.extend = function(feature) {
var geometry = feature.getGeometry();
ol.DEBUG && console.assert(this.mode_ == ol.interaction.DrawMode.LINE_STRING,
ol.DEBUG && console.assert(this.mode_ == ol.interaction.Draw.Mode.LINE_STRING,
'interaction mode must be "line"');
ol.DEBUG && console.assert(geometry.getType() == ol.geom.GeometryType.LINE_STRING,
'feature geometry must be a line string');
@@ -804,24 +803,24 @@ ol.interaction.Draw.createRegularPolygon = function(opt_sides, opt_angle) {
* Get the drawing mode. The mode for mult-part geometries is the same as for
* their single-part cousins.
* @param {ol.geom.GeometryType} type Geometry type.
* @return {ol.interaction.DrawMode} Drawing mode.
* @return {ol.interaction.Draw.Mode} Drawing mode.
* @private
*/
ol.interaction.Draw.getMode_ = function(type) {
var mode;
if (type === ol.geom.GeometryType.POINT ||
type === ol.geom.GeometryType.MULTI_POINT) {
mode = ol.interaction.DrawMode.POINT;
mode = ol.interaction.Draw.Mode.POINT;
} else if (type === ol.geom.GeometryType.LINE_STRING ||
type === ol.geom.GeometryType.MULTI_LINE_STRING) {
mode = ol.interaction.DrawMode.LINE_STRING;
mode = ol.interaction.Draw.Mode.LINE_STRING;
} else if (type === ol.geom.GeometryType.POLYGON ||
type === ol.geom.GeometryType.MULTI_POLYGON) {
mode = ol.interaction.DrawMode.POLYGON;
mode = ol.interaction.Draw.Mode.POLYGON;
} else if (type === ol.geom.GeometryType.CIRCLE) {
mode = ol.interaction.DrawMode.CIRCLE;
mode = ol.interaction.Draw.Mode.CIRCLE;
}
return /** @type {!ol.interaction.DrawMode} */ (mode);
return /** @type {!ol.interaction.Draw.Mode} */ (mode);
};
@@ -830,7 +829,7 @@ ol.interaction.Draw.getMode_ = function(type) {
* cousins.
* @enum {string}
*/
ol.interaction.DrawMode = {
ol.interaction.Draw.Mode = {
POINT: 'Point',
LINE_STRING: 'LineString',
POLYGON: 'Polygon',