Rename ol.Observable#dispatchChangeEvent() to #changed()

Since dispatchChangeEvent does not only dispatch a change event, but
also increases the revision counter, the method name should reflect
this.
This commit is contained in:
Andreas Hocevar
2014-09-04 19:30:48 -06:00
parent 5de537001f
commit ebe3b48e0a
32 changed files with 66 additions and 66 deletions

View File

@@ -132,7 +132,7 @@ ol.DeviceOrientation.prototype.orientationChange_ = function(browserEvent) {
this.set(ol.DeviceOrientationProperty.GAMMA,
goog.math.toRadians(event.gamma));
}
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -198,7 +198,7 @@ ol.Feature.prototype.getStyleFunction = function() {
* @private
*/
ol.Feature.prototype.handleGeometryChange_ = function() {
this.dispatchChangeEvent();
this.changed();
};
@@ -214,7 +214,7 @@ ol.Feature.prototype.handleGeometryChanged_ = function() {
if (goog.isDefAndNotNull(geometry)) {
this.geometryChangeKey_ = goog.events.listen(geometry,
goog.events.EventType.CHANGE, this.handleGeometryChange_, false, this);
this.dispatchChangeEvent();
this.changed();
}
};
@@ -244,7 +244,7 @@ goog.exportProperty(
ol.Feature.prototype.setStyle = function(style) {
this.style_ = style;
this.styleFunction_ = ol.feature.createFeatureStyleFunction(style);
this.dispatchChangeEvent();
this.changed();
};
@@ -256,7 +256,7 @@ ol.Feature.prototype.setStyle = function(style) {
*/
ol.Feature.prototype.setId = function(id) {
this.id_ = id;
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -173,7 +173,7 @@ ol.Geolocation.prototype.positionChange_ = function(position) {
ol.sphere.WGS84, this.position_, coords.accuracy);
geometry.applyTransform(this.transform_);
this.set(ol.GeolocationProperty.ACCURACY_GEOMETRY, geometry);
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -182,7 +182,7 @@ ol.geom.Circle.prototype.setCenterAndRadius =
flatCoordinates[offset++] = flatCoordinates[i];
}
flatCoordinates.length = offset;
this.dispatchChangeEvent();
this.changed();
}
};
@@ -194,7 +194,7 @@ ol.geom.Circle.prototype.setCenterAndRadius =
ol.geom.Circle.prototype.setFlatCoordinates =
function(layout, flatCoordinates) {
this.setFlatCoordinatesInternal(layout, flatCoordinates);
this.dispatchChangeEvent();
this.changed();
};
@@ -205,7 +205,7 @@ ol.geom.Circle.prototype.setFlatCoordinates =
ol.geom.Circle.prototype.setRadius = function(radius) {
goog.asserts.assert(!goog.isNull(this.flatCoordinates));
this.flatCoordinates[this.stride] = this.flatCoordinates[0] + radius;
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -61,7 +61,7 @@ ol.geom.GeometryCollection.prototype.unlistenGeometriesChange_ = function() {
for (i = 0, ii = this.geometries_.length; i < ii; ++i) {
goog.events.unlisten(
this.geometries_[i], goog.events.EventType.CHANGE,
this.dispatchChangeEvent, false, this);
this.changed, false, this);
}
};
@@ -77,7 +77,7 @@ ol.geom.GeometryCollection.prototype.listenGeometriesChange_ = function() {
for (i = 0, ii = this.geometries_.length; i < ii; ++i) {
goog.events.listen(
this.geometries_[i], goog.events.EventType.CHANGE,
this.dispatchChangeEvent, false, this);
this.changed, false, this);
}
};
@@ -243,7 +243,7 @@ ol.geom.GeometryCollection.prototype.setGeometriesArray = function(geometries) {
this.unlistenGeometriesChange_();
this.geometries_ = geometries;
this.listenGeometriesChange_();
this.dispatchChangeEvent();
this.changed();
};
@@ -256,7 +256,7 @@ ol.geom.GeometryCollection.prototype.applyTransform = function(transformFn) {
for (i = 0, ii = geometries.length; i < ii; ++i) {
geometries[i].applyTransform(transformFn);
}
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -138,7 +138,7 @@ ol.geom.LinearRing.prototype.setCoordinates =
}
this.flatCoordinates.length = ol.geom.flat.deflate.coordinates(
this.flatCoordinates, 0, coordinates, this.stride);
this.dispatchChangeEvent();
this.changed();
}
};
@@ -150,5 +150,5 @@ ol.geom.LinearRing.prototype.setCoordinates =
ol.geom.LinearRing.prototype.setFlatCoordinates =
function(layout, flatCoordinates) {
this.setFlatCoordinatesInternal(layout, flatCoordinates);
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -70,7 +70,7 @@ ol.geom.LineString.prototype.appendCoordinate = function(coordinate) {
} else {
ol.array.safeExtend(this.flatCoordinates, coordinate);
}
this.dispatchChangeEvent();
this.changed();
};
@@ -206,7 +206,7 @@ ol.geom.LineString.prototype.setCoordinates =
}
this.flatCoordinates.length = ol.geom.flat.deflate.coordinates(
this.flatCoordinates, 0, coordinates, this.stride);
this.dispatchChangeEvent();
this.changed();
}
};
@@ -218,5 +218,5 @@ ol.geom.LineString.prototype.setCoordinates =
ol.geom.LineString.prototype.setFlatCoordinates =
function(layout, flatCoordinates) {
this.setFlatCoordinatesInternal(layout, flatCoordinates);
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -66,7 +66,7 @@ ol.geom.MultiLineString.prototype.appendLineString = function(lineString) {
this.flatCoordinates, lineString.getFlatCoordinates().slice());
}
this.ends_.push(this.flatCoordinates.length);
this.dispatchChangeEvent();
this.changed();
};
@@ -261,7 +261,7 @@ ol.geom.MultiLineString.prototype.setCoordinates =
var ends = ol.geom.flat.deflate.coordinatess(
this.flatCoordinates, 0, coordinates, this.stride, this.ends_);
this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];
this.dispatchChangeEvent();
this.changed();
}
};
@@ -282,7 +282,7 @@ ol.geom.MultiLineString.prototype.setFlatCoordinates =
}
this.setFlatCoordinatesInternal(layout, flatCoordinates);
this.ends_ = ends;
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -41,7 +41,7 @@ ol.geom.MultiPoint.prototype.appendPoint = function(point) {
} else {
ol.array.safeExtend(this.flatCoordinates, point.getFlatCoordinates());
}
this.dispatchChangeEvent();
this.changed();
};
@@ -158,7 +158,7 @@ ol.geom.MultiPoint.prototype.setCoordinates =
}
this.flatCoordinates.length = ol.geom.flat.deflate.coordinates(
this.flatCoordinates, 0, coordinates, this.stride);
this.dispatchChangeEvent();
this.changed();
}
};
@@ -170,5 +170,5 @@ ol.geom.MultiPoint.prototype.setCoordinates =
ol.geom.MultiPoint.prototype.setFlatCoordinates =
function(layout, flatCoordinates) {
this.setFlatCoordinatesInternal(layout, flatCoordinates);
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -104,7 +104,7 @@ ol.geom.MultiPolygon.prototype.appendPolygon = function(polygon) {
}
}
this.endss_.push(ends);
this.dispatchChangeEvent();
this.changed();
};
@@ -338,7 +338,7 @@ ol.geom.MultiPolygon.prototype.setCoordinates =
this.flatCoordinates.length = lastEnds.length === 0 ?
0 : lastEnds[lastEnds.length - 1];
}
this.dispatchChangeEvent();
this.changed();
}
};
@@ -360,7 +360,7 @@ ol.geom.MultiPolygon.prototype.setFlatCoordinates =
}
this.setFlatCoordinatesInternal(layout, flatCoordinates);
this.endss_ = endss;
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -108,7 +108,7 @@ ol.geom.Point.prototype.setCoordinates = function(coordinates, opt_layout) {
}
this.flatCoordinates.length = ol.geom.flat.deflate.coordinate(
this.flatCoordinates, 0, coordinates, this.stride);
this.dispatchChangeEvent();
this.changed();
}
};
@@ -119,5 +119,5 @@ ol.geom.Point.prototype.setCoordinates = function(coordinates, opt_layout) {
*/
ol.geom.Point.prototype.setFlatCoordinates = function(layout, flatCoordinates) {
this.setFlatCoordinatesInternal(layout, flatCoordinates);
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -94,7 +94,7 @@ ol.geom.Polygon.prototype.appendLinearRing = function(linearRing) {
ol.array.safeExtend(this.flatCoordinates, linearRing.getFlatCoordinates());
}
this.ends_.push(this.flatCoordinates.length);
this.dispatchChangeEvent();
this.changed();
};
@@ -312,7 +312,7 @@ ol.geom.Polygon.prototype.setCoordinates = function(coordinates, opt_layout) {
var ends = ol.geom.flat.deflate.coordinatess(
this.flatCoordinates, 0, coordinates, this.stride, this.ends_);
this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];
this.dispatchChangeEvent();
this.changed();
}
};
@@ -333,7 +333,7 @@ ol.geom.Polygon.prototype.setFlatCoordinates =
}
this.setFlatCoordinatesInternal(layout, flatCoordinates);
this.ends_ = ends;
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -249,7 +249,7 @@ ol.geom.SimpleGeometry.prototype.setLayout =
ol.geom.SimpleGeometry.prototype.applyTransform = function(transformFn) {
if (!goog.isNull(this.flatCoordinates)) {
transformFn(this.flatCoordinates, this.flatCoordinates, this.stride);
this.dispatchChangeEvent();
this.changed();
}
};

View File

@@ -93,7 +93,7 @@ ol.Image.prototype.getImageElement = function(opt_context) {
ol.Image.prototype.handleImageError_ = function() {
this.state = ol.ImageState.ERROR;
this.unlistenImage_();
this.dispatchChangeEvent();
this.changed();
};
@@ -105,7 +105,7 @@ ol.Image.prototype.handleImageError_ = function() {
ol.Image.prototype.handleImageLoad_ = function() {
this.state = ol.ImageState.LOADED;
this.unlistenImage_();
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -69,7 +69,7 @@ goog.inherits(ol.ImageBase, goog.events.EventTarget);
/**
* @protected
*/
ol.ImageBase.prototype.dispatchChangeEvent = function() {
ol.ImageBase.prototype.changed = function() {
this.dispatchEvent(goog.events.EventType.CHANGE);
};

View File

@@ -103,7 +103,7 @@ ol.ImageTile.prototype.getKey = function() {
ol.ImageTile.prototype.handleImageError_ = function() {
this.state = ol.TileState.ERROR;
this.unlistenImage_();
this.dispatchChangeEvent();
this.changed();
};
@@ -124,7 +124,7 @@ ol.ImageTile.prototype.handleImageLoad_ = function() {
this.state = ol.TileState.EMPTY;
}
this.unlistenImage_();
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -99,5 +99,5 @@ ol.layer.Layer.prototype.getSourceState = function() {
* @private
*/
ol.layer.Layer.prototype.handleSourceChange_ = function() {
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -78,7 +78,7 @@ goog.inherits(ol.layer.Group, ol.layer.Base);
*/
ol.layer.Group.prototype.handleLayerChange_ = function() {
if (this.getVisible()) {
this.dispatchChangeEvent();
this.changed();
}
};
@@ -114,7 +114,7 @@ ol.layer.Group.prototype.handleLayersChanged_ = function(event) {
}
}
this.dispatchChangeEvent();
this.changed();
};
@@ -127,7 +127,7 @@ ol.layer.Group.prototype.handleLayersAdd_ = function(collectionEvent) {
this.listenerKeys_[goog.getUid(layer).toString()] = goog.events.listen(
layer, [ol.ObjectEventType.PROPERTYCHANGE, goog.events.EventType.CHANGE],
this.handleLayerChange_, false, this);
this.dispatchChangeEvent();
this.changed();
};
@@ -140,7 +140,7 @@ ol.layer.Group.prototype.handleLayersRemove_ = function(collectionEvent) {
var key = goog.getUid(layer).toString();
goog.events.unlistenByKey(this.listenerKeys_[key]);
delete this.listenerKeys_[key];
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -121,5 +121,5 @@ ol.layer.Vector.prototype.setStyle = function(style) {
this.style_ = goog.isDef(style) ? style : ol.style.defaultStyleFunction;
this.styleFunction_ = goog.isNull(style) ?
undefined : ol.style.createStyleFunction(this.style_);
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -12,7 +12,7 @@ goog.require('goog.events.EventType');
* instantiated in apps.
* An event target providing convenient methods for listener registration
* and unregistration. A generic `change` event is always available through
* {@link ol.Observable#dispatchChangeEvent}.
* {@link ol.Observable#changed}.
*
* @constructor
* @extends {goog.events.EventTarget}
@@ -35,11 +35,11 @@ goog.inherits(ol.Observable, goog.events.EventTarget);
/**
* Dispatches a `change` event.
* Increases the revision counter and disptches a 'change' event.
* @fires change
* @api
*/
ol.Observable.prototype.dispatchChangeEvent = function() {
ol.Observable.prototype.changed = function() {
++this.revision_;
this.dispatchEvent(goog.events.EventType.CHANGE);
};

View File

@@ -81,7 +81,7 @@ ol.source.Cluster.prototype.onSourceChange_ = function() {
this.clear();
this.cluster_();
this.addFeatures(this.features_);
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -179,7 +179,7 @@ ol.source.ImageMapGuide.getScale = function(extent, size, metersPerUnit, dpi) {
*/
ol.source.ImageMapGuide.prototype.updateParams = function(params) {
goog.object.extend(this.params_, params);
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -204,7 +204,7 @@ ol.source.ImageVector.prototype.getTransform_ =
*/
ol.source.ImageVector.prototype.handleImageChange_ =
function(event) {
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -319,7 +319,7 @@ ol.source.ImageWMS.prototype.setUrl = function(url) {
if (url != this.url_) {
this.url_ = url;
this.image_ = null;
this.dispatchChangeEvent();
this.changed();
}
};
@@ -333,7 +333,7 @@ ol.source.ImageWMS.prototype.updateParams = function(params) {
goog.object.extend(this.params_, params);
this.updateV13_();
this.image_ = null;
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -153,7 +153,7 @@ ol.source.Source.prototype.setLogo = function(logo) {
*/
ol.source.Source.prototype.setState = function(state) {
this.state_ = state;
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -149,7 +149,7 @@ ol.source.TileImage.prototype.getTileUrlFunction = function() {
ol.source.TileImage.prototype.setTileLoadFunction = function(tileLoadFunction) {
this.tileCache.clear();
this.tileLoadFunction = tileLoadFunction;
this.dispatchChangeEvent();
this.changed();
};
@@ -163,7 +163,7 @@ ol.source.TileImage.prototype.setTileUrlFunction = function(tileUrlFunction) {
// FIXME cache key somehow.
this.tileCache.clear();
this.tileUrlFunction = tileUrlFunction;
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -223,7 +223,7 @@ ol.source.TileVector.prototype.removeFeature = goog.abstractMethod;
*/
ol.source.TileVector.prototype.setTileUrlFunction = function(tileUrlFunction) {
this.tileUrlFunction_ = tileUrlFunction;
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -341,7 +341,7 @@ ol.source.TileWMS.prototype.setUrl = function(url) {
ol.source.TileWMS.prototype.setUrls = function(urls) {
this.urls_ = goog.isDefAndNotNull(urls) ? urls : [];
this.resetCoordKeyPrefix_();
this.dispatchChangeEvent();
this.changed();
};
@@ -407,7 +407,7 @@ ol.source.TileWMS.prototype.updateParams = function(params) {
goog.object.extend(this.params_, params);
this.resetCoordKeyPrefix_();
this.updateV13_();
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -106,7 +106,7 @@ goog.inherits(ol.source.Vector, ol.source.Source);
*/
ol.source.Vector.prototype.addFeature = function(feature) {
this.addFeatureInternal(feature);
this.dispatchChangeEvent();
this.changed();
};
@@ -152,7 +152,7 @@ ol.source.Vector.prototype.addFeatureInternal = function(feature) {
*/
ol.source.Vector.prototype.addFeatures = function(features) {
this.addFeaturesInternal(features);
this.dispatchChangeEvent();
this.changed();
};
@@ -181,7 +181,7 @@ ol.source.Vector.prototype.clear = function() {
this.nullGeometryFeatures_, this.removeFeatureInternal, this);
goog.object.clear(this.nullGeometryFeatures_);
goog.asserts.assert(goog.object.isEmpty(this.featureChangeKeys_));
this.dispatchChangeEvent();
this.changed();
};
@@ -403,7 +403,7 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) {
goog.asserts.assert(this.undefIdIndex_[featureKey] === feature);
}
}
this.dispatchChangeEvent();
this.changed();
};
@@ -436,7 +436,7 @@ ol.source.Vector.prototype.removeFeature = function(feature) {
this.rBush_.remove(feature);
}
this.removeFeatureInternal(feature);
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -232,7 +232,7 @@ ol.source.WMTS.prototype.resetCoordKeyPrefix_ = function() {
ol.source.WMTS.prototype.updateDimensions = function(dimensions) {
goog.object.extend(this.dimensions_, dimensions);
this.resetCoordKeyPrefix_();
this.dispatchChangeEvent();
this.changed();
};

View File

@@ -51,7 +51,7 @@ goog.inherits(ol.Tile, goog.events.EventTarget);
/**
* @protected
*/
ol.Tile.prototype.dispatchChangeEvent = function() {
ol.Tile.prototype.changed = function() {
this.dispatchEvent(goog.events.EventType.CHANGE);
};