diff --git a/src/ol/image.js b/src/ol/image.js
index d990a3a7c0..876ba618d7 100644
--- a/src/ol/image.js
+++ b/src/ol/image.js
@@ -2,6 +2,7 @@ goog.provide('ol.Image');
goog.require('ol');
goog.require('ol.ImageBase');
+goog.require('ol.ImageState');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.extent');
@@ -22,7 +23,7 @@ goog.require('ol.obj');
ol.Image = function(extent, resolution, pixelRatio, attributions, src,
crossOrigin, imageLoadFunction) {
- ol.ImageBase.call(this, extent, resolution, pixelRatio, ol.Image.State.IDLE,
+ ol.ImageBase.call(this, extent, resolution, pixelRatio, ol.ImageState.IDLE,
attributions);
/**
@@ -54,9 +55,9 @@ ol.Image = function(extent, resolution, pixelRatio, attributions, src,
/**
* @protected
- * @type {ol.Image.State}
+ * @type {ol.ImageState}
*/
- this.state = ol.Image.State.IDLE;
+ this.state = ol.ImageState.IDLE;
/**
* @private
@@ -99,7 +100,7 @@ ol.Image.prototype.getImage = function(opt_context) {
* @private
*/
ol.Image.prototype.handleImageError_ = function() {
- this.state = ol.Image.State.ERROR;
+ this.state = ol.ImageState.ERROR;
this.unlistenImage_();
this.changed();
};
@@ -114,7 +115,7 @@ ol.Image.prototype.handleImageLoad_ = function() {
if (this.resolution === undefined) {
this.resolution = ol.extent.getHeight(this.extent) / this.image_.height;
}
- this.state = ol.Image.State.LOADED;
+ this.state = ol.ImageState.LOADED;
this.unlistenImage_();
this.changed();
};
@@ -127,8 +128,8 @@ ol.Image.prototype.handleImageLoad_ = function() {
* @api
*/
ol.Image.prototype.load = function() {
- if (this.state == ol.Image.State.IDLE || this.state == ol.Image.State.ERROR) {
- this.state = ol.Image.State.LOADING;
+ if (this.state == ol.ImageState.IDLE || this.state == ol.ImageState.ERROR) {
+ this.state = ol.ImageState.LOADING;
this.changed();
ol.DEBUG && console.assert(!this.imageListenerKeys_,
'this.imageListenerKeys_ should be null');
@@ -160,14 +161,3 @@ ol.Image.prototype.unlistenImage_ = function() {
this.imageListenerKeys_.forEach(ol.events.unlistenByKey);
this.imageListenerKeys_ = null;
};
-
-
-/**
- * @enum {number}
- */
-ol.Image.State = {
- IDLE: 0,
- LOADING: 1,
- LOADED: 2,
- ERROR: 3
-};
diff --git a/src/ol/imagebase.js b/src/ol/imagebase.js
index c8305870b7..451fcd4d95 100644
--- a/src/ol/imagebase.js
+++ b/src/ol/imagebase.js
@@ -11,7 +11,7 @@ goog.require('ol.events.EventType');
* @param {ol.Extent} extent Extent.
* @param {number|undefined} resolution Resolution.
* @param {number} pixelRatio Pixel ratio.
- * @param {ol.Image.State} state State.
+ * @param {ol.ImageState} state State.
* @param {Array.
} attributions Attributions.
*/
ol.ImageBase = function(extent, resolution, pixelRatio, state, attributions) {
@@ -44,7 +44,7 @@ ol.ImageBase = function(extent, resolution, pixelRatio, state, attributions) {
/**
* @protected
- * @type {ol.Image.State}
+ * @type {ol.ImageState}
*/
this.state = state;
@@ -102,7 +102,7 @@ ol.ImageBase.prototype.getResolution = function() {
/**
- * @return {ol.Image.State} State.
+ * @return {ol.ImageState} State.
*/
ol.ImageBase.prototype.getState = function() {
return this.state;
diff --git a/src/ol/imagecanvas.js b/src/ol/imagecanvas.js
index 5e16bf2900..8d70fafafd 100644
--- a/src/ol/imagecanvas.js
+++ b/src/ol/imagecanvas.js
@@ -1,8 +1,8 @@
goog.provide('ol.ImageCanvas');
goog.require('ol');
-goog.require('ol.Image');
goog.require('ol.ImageBase');
+goog.require('ol.ImageState');
/**
@@ -27,7 +27,7 @@ ol.ImageCanvas = function(extent, resolution, pixelRatio, attributions,
this.loader_ = opt_loader !== undefined ? opt_loader : null;
var state = opt_loader !== undefined ?
- ol.Image.State.IDLE : ol.Image.State.LOADED;
+ ol.ImageState.IDLE : ol.ImageState.LOADED;
ol.ImageBase.call(this, extent, resolution, pixelRatio, state, attributions);
@@ -64,9 +64,9 @@ ol.ImageCanvas.prototype.getError = function() {
ol.ImageCanvas.prototype.handleLoad_ = function(err) {
if (err) {
this.error_ = err;
- this.state = ol.Image.State.ERROR;
+ this.state = ol.ImageState.ERROR;
} else {
- this.state = ol.Image.State.LOADED;
+ this.state = ol.ImageState.LOADED;
}
this.changed();
};
@@ -76,9 +76,9 @@ ol.ImageCanvas.prototype.handleLoad_ = function(err) {
* Trigger drawing on canvas.
*/
ol.ImageCanvas.prototype.load = function() {
- if (this.state == ol.Image.State.IDLE) {
+ if (this.state == ol.ImageState.IDLE) {
ol.DEBUG && console.assert(this.loader_, 'this.loader_ must be set');
- this.state = ol.Image.State.LOADING;
+ this.state = ol.ImageState.LOADING;
this.changed();
this.loader_(this.handleLoad_.bind(this));
}
diff --git a/src/ol/imagestate.js b/src/ol/imagestate.js
new file mode 100644
index 0000000000..57b795f652
--- /dev/null
+++ b/src/ol/imagestate.js
@@ -0,0 +1,11 @@
+goog.provide('ol.ImageState');
+
+/**
+ * @enum {number}
+ */
+ol.ImageState = {
+ IDLE: 0,
+ LOADING: 1,
+ LOADED: 2,
+ ERROR: 3
+};
diff --git a/src/ol/renderer/layer.js b/src/ol/renderer/layer.js
index 198d91ca37..df07c26a2a 100644
--- a/src/ol/renderer/layer.js
+++ b/src/ol/renderer/layer.js
@@ -1,7 +1,7 @@
goog.provide('ol.renderer.Layer');
goog.require('ol');
-goog.require('ol.Image');
+goog.require('ol.ImageState');
goog.require('ol.Observable');
goog.require('ol.Tile');
goog.require('ol.asserts');
@@ -98,7 +98,7 @@ ol.renderer.Layer.prototype.getLayer = function() {
*/
ol.renderer.Layer.prototype.handleImageChange_ = function(event) {
var image = /** @type {ol.Image} */ (event.target);
- if (image.getState() === ol.Image.State.LOADED) {
+ if (image.getState() === ol.ImageState.LOADED) {
this.renderIfReadyAndVisible();
}
};
@@ -114,24 +114,24 @@ ol.renderer.Layer.prototype.handleImageChange_ = function(event) {
*/
ol.renderer.Layer.prototype.loadImage = function(image) {
var imageState = image.getState();
- if (imageState != ol.Image.State.LOADED &&
- imageState != ol.Image.State.ERROR) {
+ if (imageState != ol.ImageState.LOADED &&
+ imageState != ol.ImageState.ERROR) {
// the image is either "idle" or "loading", register the change
// listener (a noop if the listener was already registered)
- ol.DEBUG && console.assert(imageState == ol.Image.State.IDLE ||
- imageState == ol.Image.State.LOADING,
+ ol.DEBUG && console.assert(imageState == ol.ImageState.IDLE ||
+ imageState == ol.ImageState.LOADING,
'imageState is "idle" or "loading"');
ol.events.listen(image, ol.events.EventType.CHANGE,
this.handleImageChange_, this);
}
- if (imageState == ol.Image.State.IDLE) {
+ if (imageState == ol.ImageState.IDLE) {
image.load();
imageState = image.getState();
- ol.DEBUG && console.assert(imageState == ol.Image.State.LOADING ||
- imageState == ol.Image.State.LOADED,
+ ol.DEBUG && console.assert(imageState == ol.ImageState.LOADING ||
+ imageState == ol.ImageState.LOADED,
'imageState is "loading" or "loaded"');
}
- return imageState == ol.Image.State.LOADED;
+ return imageState == ol.ImageState.LOADED;
};
diff --git a/src/ol/renderer/vector.js b/src/ol/renderer/vector.js
index ffa74f0889..d9d72f399e 100644
--- a/src/ol/renderer/vector.js
+++ b/src/ol/renderer/vector.js
@@ -1,7 +1,7 @@
goog.provide('ol.renderer.vector');
goog.require('ol');
-goog.require('ol.Image');
+goog.require('ol.ImageState');
goog.require('ol.render.ReplayType');
@@ -79,15 +79,15 @@ ol.renderer.vector.renderFeature = function(
imageStyle = style.getImage();
if (imageStyle) {
imageState = imageStyle.getImageState();
- if (imageState == ol.Image.State.LOADED ||
- imageState == ol.Image.State.ERROR) {
+ if (imageState == ol.ImageState.LOADED ||
+ imageState == ol.ImageState.ERROR) {
imageStyle.unlistenImageChange(listener, thisArg);
} else {
- if (imageState == ol.Image.State.IDLE) {
+ if (imageState == ol.ImageState.IDLE) {
imageStyle.load();
}
imageState = imageStyle.getImageState();
- ol.DEBUG && console.assert(imageState == ol.Image.State.LOADING,
+ ol.DEBUG && console.assert(imageState == ol.ImageState.LOADING,
'imageState should be LOADING');
imageStyle.listenImageChange(listener, thisArg);
loading = true;
@@ -227,7 +227,7 @@ ol.renderer.vector.renderMultiPolygonGeometry_ = function(replayGroup, geometry,
ol.renderer.vector.renderPointGeometry_ = function(replayGroup, geometry, style, feature) {
var imageStyle = style.getImage();
if (imageStyle) {
- if (imageStyle.getImageState() != ol.Image.State.LOADED) {
+ if (imageStyle.getImageState() != ol.ImageState.LOADED) {
return;
}
var imageReplay = replayGroup.getReplay(
@@ -256,7 +256,7 @@ ol.renderer.vector.renderPointGeometry_ = function(replayGroup, geometry, style,
ol.renderer.vector.renderMultiPointGeometry_ = function(replayGroup, geometry, style, feature) {
var imageStyle = style.getImage();
if (imageStyle) {
- if (imageStyle.getImageState() != ol.Image.State.LOADED) {
+ if (imageStyle.getImageState() != ol.ImageState.LOADED) {
return;
}
var imageReplay = replayGroup.getReplay(
diff --git a/src/ol/reproj/image.js b/src/ol/reproj/image.js
index 43c4ada5bc..0ff4aef582 100644
--- a/src/ol/reproj/image.js
+++ b/src/ol/reproj/image.js
@@ -1,8 +1,8 @@
goog.provide('ol.reproj.Image');
goog.require('ol');
-goog.require('ol.Image');
goog.require('ol.ImageBase');
+goog.require('ol.ImageState');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.extent');
@@ -99,11 +99,11 @@ ol.reproj.Image = function(sourceProj, targetProj,
this.sourceListenerKey_ = null;
- var state = ol.Image.State.LOADED;
+ var state = ol.ImageState.LOADED;
var attributions = [];
if (this.sourceImage_) {
- state = ol.Image.State.IDLE;
+ state = ol.ImageState.IDLE;
attributions = this.sourceImage_.getAttributions();
}
@@ -117,7 +117,7 @@ ol.inherits(ol.reproj.Image, ol.ImageBase);
* @inheritDoc
*/
ol.reproj.Image.prototype.disposeInternal = function() {
- if (this.state == ol.Image.State.LOADING) {
+ if (this.state == ol.ImageState.LOADING) {
this.unlistenSource_();
}
ol.ImageBase.prototype.disposeInternal.call(this);
@@ -145,7 +145,7 @@ ol.reproj.Image.prototype.getProjection = function() {
*/
ol.reproj.Image.prototype.reproject_ = function() {
var sourceState = this.sourceImage_.getState();
- if (sourceState == ol.Image.State.LOADED) {
+ if (sourceState == ol.ImageState.LOADED) {
var width = ol.extent.getWidth(this.targetExtent_) / this.targetResolution_;
var height =
ol.extent.getHeight(this.targetExtent_) / this.targetResolution_;
@@ -166,20 +166,20 @@ ol.reproj.Image.prototype.reproject_ = function() {
* @inheritDoc
*/
ol.reproj.Image.prototype.load = function() {
- if (this.state == ol.Image.State.IDLE) {
- this.state = ol.Image.State.LOADING;
+ if (this.state == ol.ImageState.IDLE) {
+ this.state = ol.ImageState.LOADING;
this.changed();
var sourceState = this.sourceImage_.getState();
- if (sourceState == ol.Image.State.LOADED ||
- sourceState == ol.Image.State.ERROR) {
+ if (sourceState == ol.ImageState.LOADED ||
+ sourceState == ol.ImageState.ERROR) {
this.reproject_();
} else {
this.sourceListenerKey_ = ol.events.listen(this.sourceImage_,
ol.events.EventType.CHANGE, function(e) {
var sourceState = this.sourceImage_.getState();
- if (sourceState == ol.Image.State.LOADED ||
- sourceState == ol.Image.State.ERROR) {
+ if (sourceState == ol.ImageState.LOADED ||
+ sourceState == ol.ImageState.ERROR) {
this.unlistenSource_();
this.reproject_();
}
diff --git a/src/ol/source/image.js b/src/ol/source/image.js
index cc8477aea5..25d7a935a4 100644
--- a/src/ol/source/image.js
+++ b/src/ol/source/image.js
@@ -1,7 +1,7 @@
goog.provide('ol.source.Image');
goog.require('ol');
-goog.require('ol.Image');
+goog.require('ol.ImageState');
goog.require('ol.array');
goog.require('ol.events.Event');
goog.require('ol.extent');
@@ -147,17 +147,17 @@ ol.source.Image.prototype.getImageInternal = function(extent, resolution, pixelR
ol.source.Image.prototype.handleImageChange = function(event) {
var image = /** @type {ol.Image} */ (event.target);
switch (image.getState()) {
- case ol.Image.State.LOADING:
+ case ol.ImageState.LOADING:
this.dispatchEvent(
new ol.source.Image.Event(ol.source.Image.EventType.IMAGELOADSTART,
image));
break;
- case ol.Image.State.LOADED:
+ case ol.ImageState.LOADED:
this.dispatchEvent(
new ol.source.Image.Event(ol.source.Image.EventType.IMAGELOADEND,
image));
break;
- case ol.Image.State.ERROR:
+ case ol.ImageState.ERROR:
this.dispatchEvent(
new ol.source.Image.Event(ol.source.Image.EventType.IMAGELOADERROR,
image));
diff --git a/src/ol/source/imagestatic.js b/src/ol/source/imagestatic.js
index 93137f7875..15eb7df329 100644
--- a/src/ol/source/imagestatic.js
+++ b/src/ol/source/imagestatic.js
@@ -2,6 +2,7 @@ goog.provide('ol.source.ImageStatic');
goog.require('ol');
goog.require('ol.Image');
+goog.require('ol.ImageState');
goog.require('ol.dom');
goog.require('ol.events');
goog.require('ol.events.EventType');
@@ -70,7 +71,7 @@ ol.source.ImageStatic.prototype.getImageInternal = function(extent, resolution,
* @inheritDoc
*/
ol.source.ImageStatic.prototype.handleImageChange = function(evt) {
- if (this.image_.getState() == ol.Image.State.LOADED) {
+ if (this.image_.getState() == ol.ImageState.LOADED) {
var imageExtent = this.image_.getExtent();
var image = this.image_.getImage();
var imageWidth, imageHeight;
diff --git a/src/ol/style/icon.js b/src/ol/style/icon.js
index 42c82cf313..b614823deb 100644
--- a/src/ol/style/icon.js
+++ b/src/ol/style/icon.js
@@ -1,11 +1,11 @@
goog.provide('ol.style.Icon');
goog.require('ol');
+goog.require('ol.ImageState');
goog.require('ol.asserts');
goog.require('ol.color');
goog.require('ol.events');
goog.require('ol.events.EventType');
-goog.require('ol.Image');
goog.require('ol.style.IconImage');
goog.require('ol.style.Image');
@@ -90,10 +90,10 @@ ol.style.Icon = function(opt_options) {
6); // A defined and non-empty `src` or `image` must be provided
/**
- * @type {ol.Image.State}
+ * @type {ol.ImageState}
*/
var imageState = options.src !== undefined ?
- ol.Image.State.IDLE : ol.Image.State.LOADED;
+ ol.ImageState.IDLE : ol.ImageState.LOADED;
/**
* @private
@@ -181,7 +181,7 @@ ol.inherits(ol.style.Icon, ol.style.Image);
ol.style.Icon.prototype.clone = function() {
var oldImage = this.getImage(1);
var newImage;
- if (this.iconImage_.getImageState() === ol.Image.State.LOADED) {
+ if (this.iconImage_.getImageState() === ol.ImageState.LOADED) {
if (oldImage.tagName.toUpperCase() === 'IMG') {
newImage = /** @type {Image} */ (oldImage.cloneNode(true));
} else {
diff --git a/src/ol/style/iconimage.js b/src/ol/style/iconimage.js
index 50b11a35b6..bfcd3da984 100644
--- a/src/ol/style/iconimage.js
+++ b/src/ol/style/iconimage.js
@@ -5,7 +5,7 @@ goog.require('ol.dom');
goog.require('ol.events');
goog.require('ol.events.EventTarget');
goog.require('ol.events.EventType');
-goog.require('ol.Image');
+goog.require('ol.ImageState');
goog.require('ol.style');
@@ -15,7 +15,7 @@ goog.require('ol.style');
* @param {string|undefined} src Src.
* @param {ol.Size} size Size.
* @param {?string} crossOrigin Cross origin.
- * @param {ol.Image.State} imageState Image state.
+ * @param {ol.ImageState} imageState Image state.
* @param {ol.Color} color Color.
* @extends {ol.events.EventTarget}
*/
@@ -62,7 +62,7 @@ ol.style.IconImage = function(image, src, size, crossOrigin, imageState,
/**
* @private
- * @type {ol.Image.State}
+ * @type {ol.ImageState}
*/
this.imageState_ = imageState;
@@ -83,7 +83,7 @@ ol.style.IconImage = function(image, src, size, crossOrigin, imageState,
* @type {boolean}
*/
this.tainting_ = false;
- if (this.imageState_ == ol.Image.State.LOADED) {
+ if (this.imageState_ == ol.ImageState.LOADED) {
this.determineTainting_();
}
@@ -96,7 +96,7 @@ ol.inherits(ol.style.IconImage, ol.events.EventTarget);
* @param {string} src Src.
* @param {ol.Size} size Size.
* @param {?string} crossOrigin Cross origin.
- * @param {ol.Image.State} imageState Image state.
+ * @param {ol.ImageState} imageState Image state.
* @param {ol.Color} color Color.
* @return {ol.style.IconImage} Icon image.
*/
@@ -139,7 +139,7 @@ ol.style.IconImage.prototype.dispatchChangeEvent_ = function() {
* @private
*/
ol.style.IconImage.prototype.handleImageError_ = function() {
- this.imageState_ = ol.Image.State.ERROR;
+ this.imageState_ = ol.ImageState.ERROR;
this.unlistenImage_();
this.dispatchChangeEvent_();
};
@@ -149,7 +149,7 @@ ol.style.IconImage.prototype.handleImageError_ = function() {
* @private
*/
ol.style.IconImage.prototype.handleImageLoad_ = function() {
- this.imageState_ = ol.Image.State.LOADED;
+ this.imageState_ = ol.ImageState.LOADED;
if (this.size_) {
this.image_.width = this.size_[0];
this.image_.height = this.size_[1];
@@ -172,7 +172,7 @@ ol.style.IconImage.prototype.getImage = function(pixelRatio) {
/**
- * @return {ol.Image.State} Image state.
+ * @return {ol.ImageState} Image state.
*/
ol.style.IconImage.prototype.getImageState = function() {
return this.imageState_;
@@ -219,12 +219,12 @@ ol.style.IconImage.prototype.getSrc = function() {
* Load not yet loaded URI.
*/
ol.style.IconImage.prototype.load = function() {
- if (this.imageState_ == ol.Image.State.IDLE) {
+ if (this.imageState_ == ol.ImageState.IDLE) {
ol.DEBUG && console.assert(this.src_ !== undefined,
'this.src_ must not be undefined');
ol.DEBUG && console.assert(!this.imageListenerKeys_,
'no listener keys existing');
- this.imageState_ = ol.Image.State.LOADING;
+ this.imageState_ = ol.ImageState.LOADING;
this.imageListenerKeys_ = [
ol.events.listenOnce(this.image_, ol.events.EventType.ERROR,
this.handleImageError_, this),
diff --git a/src/ol/style/image.js b/src/ol/style/image.js
index dc9566a1a9..894a88f960 100644
--- a/src/ol/style/image.js
+++ b/src/ol/style/image.js
@@ -124,7 +124,7 @@ ol.style.Image.prototype.getHitDetectionImage = function(pixelRatio) {};
/**
* @abstract
- * @return {ol.Image.State} Image state.
+ * @return {ol.ImageState} Image state.
*/
ol.style.Image.prototype.getImageState = function() {};
diff --git a/src/ol/style/regularshape.js b/src/ol/style/regularshape.js
index d4003836e7..5b433c3d78 100644
--- a/src/ol/style/regularshape.js
+++ b/src/ol/style/regularshape.js
@@ -4,7 +4,7 @@ goog.require('ol');
goog.require('ol.colorlike');
goog.require('ol.dom');
goog.require('ol.has');
-goog.require('ol.Image');
+goog.require('ol.ImageState');
goog.require('ol.render.canvas');
goog.require('ol.style.Image');
@@ -234,7 +234,7 @@ ol.style.RegularShape.prototype.getHitDetectionImageSize = function() {
* @inheritDoc
*/
ol.style.RegularShape.prototype.getImageState = function() {
- return ol.Image.State.LOADED;
+ return ol.ImageState.LOADED;
};