Remove ol.style.ImageState and use ol.ImageState instead

This commit is contained in:
Frederic Junod
2016-08-29 09:55:48 +02:00
parent c393d43005
commit 1fecb6fd16
6 changed files with 25 additions and 37 deletions

View File

@@ -1,8 +1,8 @@
goog.provide('ol.renderer.vector'); goog.provide('ol.renderer.vector');
goog.require('ol'); goog.require('ol');
goog.require('ol.ImageState');
goog.require('ol.render.ReplayType'); goog.require('ol.render.ReplayType');
goog.require('ol.style.ImageState');
/** /**
@@ -79,15 +79,15 @@ ol.renderer.vector.renderFeature = function(
imageStyle = style.getImage(); imageStyle = style.getImage();
if (imageStyle) { if (imageStyle) {
imageState = imageStyle.getImageState(); imageState = imageStyle.getImageState();
if (imageState == ol.style.ImageState.LOADED || if (imageState == ol.ImageState.LOADED ||
imageState == ol.style.ImageState.ERROR) { imageState == ol.ImageState.ERROR) {
imageStyle.unlistenImageChange(listener, thisArg); imageStyle.unlistenImageChange(listener, thisArg);
} else { } else {
if (imageState == ol.style.ImageState.IDLE) { if (imageState == ol.ImageState.IDLE) {
imageStyle.load(); imageStyle.load();
} }
imageState = imageStyle.getImageState(); imageState = imageStyle.getImageState();
goog.DEBUG && console.assert(imageState == ol.style.ImageState.LOADING, goog.DEBUG && console.assert(imageState == ol.ImageState.LOADING,
'imageState should be LOADING'); 'imageState should be LOADING');
imageStyle.listenImageChange(listener, thisArg); imageStyle.listenImageChange(listener, thisArg);
loading = true; loading = true;
@@ -227,7 +227,7 @@ ol.renderer.vector.renderMultiPolygonGeometry_ = function(replayGroup, geometry,
ol.renderer.vector.renderPointGeometry_ = function(replayGroup, geometry, style, feature) { ol.renderer.vector.renderPointGeometry_ = function(replayGroup, geometry, style, feature) {
var imageStyle = style.getImage(); var imageStyle = style.getImage();
if (imageStyle) { if (imageStyle) {
if (imageStyle.getImageState() != ol.style.ImageState.LOADED) { if (imageStyle.getImageState() != ol.ImageState.LOADED) {
return; return;
} }
var imageReplay = replayGroup.getReplay( 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) { ol.renderer.vector.renderMultiPointGeometry_ = function(replayGroup, geometry, style, feature) {
var imageStyle = style.getImage(); var imageStyle = style.getImage();
if (imageStyle) { if (imageStyle) {
if (imageStyle.getImageState() != ol.style.ImageState.LOADED) { if (imageStyle.getImageState() != ol.ImageState.LOADED) {
return; return;
} }
var imageReplay = replayGroup.getReplay( var imageReplay = replayGroup.getReplay(

View File

@@ -5,9 +5,9 @@ goog.require('ol.color');
goog.require('ol.colorlike'); goog.require('ol.colorlike');
goog.require('ol.dom'); goog.require('ol.dom');
goog.require('ol.has'); goog.require('ol.has');
goog.require('ol.ImageState');
goog.require('ol.render.canvas'); goog.require('ol.render.canvas');
goog.require('ol.style.Image'); goog.require('ol.style.Image');
goog.require('ol.style.ImageState');
/** /**
@@ -150,7 +150,7 @@ ol.style.Circle.prototype.getImage = function(pixelRatio) {
* @inheritDoc * @inheritDoc
*/ */
ol.style.Circle.prototype.getImageState = function() { ol.style.Circle.prototype.getImageState = function() {
return ol.style.ImageState.LOADED; return ol.ImageState.LOADED;
}; };

View File

@@ -7,9 +7,9 @@ goog.require('ol.asserts');
goog.require('ol.color'); goog.require('ol.color');
goog.require('ol.events'); goog.require('ol.events');
goog.require('ol.events.EventType'); goog.require('ol.events.EventType');
goog.require('ol.ImageState');
goog.require('ol.style.IconImage'); goog.require('ol.style.IconImage');
goog.require('ol.style.Image'); goog.require('ol.style.Image');
goog.require('ol.style.ImageState');
/** /**
@@ -113,10 +113,10 @@ ol.style.Icon = function(opt_options) {
6); // A defined and non-empty `src` or `image` must be provided 6); // A defined and non-empty `src` or `image` must be provided
/** /**
* @type {ol.style.ImageState} * @type {ol.ImageState}
*/ */
var imageState = options.src !== undefined ? var imageState = options.src !== undefined ?
ol.style.ImageState.IDLE : ol.style.ImageState.LOADED; ol.ImageState.IDLE : ol.ImageState.LOADED;
/** /**
* @type {ol.Color} * @type {ol.Color}

View File

@@ -5,8 +5,8 @@ goog.require('ol.dom');
goog.require('ol.events'); goog.require('ol.events');
goog.require('ol.events.EventTarget'); goog.require('ol.events.EventTarget');
goog.require('ol.events.EventType'); goog.require('ol.events.EventType');
goog.require('ol.ImageState');
goog.require('ol.style'); goog.require('ol.style');
goog.require('ol.style.ImageState');
/** /**
@@ -15,7 +15,7 @@ goog.require('ol.style.ImageState');
* @param {string|undefined} src Src. * @param {string|undefined} src Src.
* @param {ol.Size} size Size. * @param {ol.Size} size Size.
* @param {?string} crossOrigin Cross origin. * @param {?string} crossOrigin Cross origin.
* @param {ol.style.ImageState} imageState Image state. * @param {ol.ImageState} imageState Image state.
* @param {ol.Color} color Color. * @param {ol.Color} color Color.
* @extends {ol.events.EventTarget} * @extends {ol.events.EventTarget}
*/ */
@@ -62,7 +62,7 @@ ol.style.IconImage = function(image, src, size, crossOrigin, imageState,
/** /**
* @private * @private
* @type {ol.style.ImageState} * @type {ol.ImageState}
*/ */
this.imageState_ = imageState; this.imageState_ = imageState;
@@ -83,7 +83,7 @@ ol.style.IconImage = function(image, src, size, crossOrigin, imageState,
* @type {boolean} * @type {boolean}
*/ */
this.tainting_ = false; this.tainting_ = false;
if (this.imageState_ == ol.style.ImageState.LOADED) { if (this.imageState_ == ol.ImageState.LOADED) {
this.determineTainting_(); this.determineTainting_();
} }
@@ -96,7 +96,7 @@ ol.inherits(ol.style.IconImage, ol.events.EventTarget);
* @param {string} src Src. * @param {string} src Src.
* @param {ol.Size} size Size. * @param {ol.Size} size Size.
* @param {?string} crossOrigin Cross origin. * @param {?string} crossOrigin Cross origin.
* @param {ol.style.ImageState} imageState Image state. * @param {ol.ImageState} imageState Image state.
* @param {ol.Color} color Color. * @param {ol.Color} color Color.
* @return {ol.style.IconImage} Icon image. * @return {ol.style.IconImage} Icon image.
*/ */
@@ -139,7 +139,7 @@ ol.style.IconImage.prototype.dispatchChangeEvent_ = function() {
* @private * @private
*/ */
ol.style.IconImage.prototype.handleImageError_ = function() { ol.style.IconImage.prototype.handleImageError_ = function() {
this.imageState_ = ol.style.ImageState.ERROR; this.imageState_ = ol.ImageState.ERROR;
this.unlistenImage_(); this.unlistenImage_();
this.dispatchChangeEvent_(); this.dispatchChangeEvent_();
}; };
@@ -149,7 +149,7 @@ ol.style.IconImage.prototype.handleImageError_ = function() {
* @private * @private
*/ */
ol.style.IconImage.prototype.handleImageLoad_ = function() { ol.style.IconImage.prototype.handleImageLoad_ = function() {
this.imageState_ = ol.style.ImageState.LOADED; this.imageState_ = ol.ImageState.LOADED;
if (this.size_) { if (this.size_) {
this.image_.width = this.size_[0]; this.image_.width = this.size_[0];
this.image_.height = this.size_[1]; this.image_.height = this.size_[1];
@@ -172,7 +172,7 @@ ol.style.IconImage.prototype.getImage = function(pixelRatio) {
/** /**
* @return {ol.style.ImageState} Image state. * @return {ol.ImageState} Image state.
*/ */
ol.style.IconImage.prototype.getImageState = function() { ol.style.IconImage.prototype.getImageState = function() {
return this.imageState_; return this.imageState_;
@@ -219,12 +219,12 @@ ol.style.IconImage.prototype.getSrc = function() {
* Load not yet loaded URI. * Load not yet loaded URI.
*/ */
ol.style.IconImage.prototype.load = function() { ol.style.IconImage.prototype.load = function() {
if (this.imageState_ == ol.style.ImageState.IDLE) { if (this.imageState_ == ol.ImageState.IDLE) {
goog.DEBUG && console.assert(this.src_ !== undefined, goog.DEBUG && console.assert(this.src_ !== undefined,
'this.src_ must not be undefined'); 'this.src_ must not be undefined');
goog.DEBUG && console.assert(!this.imageListenerKeys_, goog.DEBUG && console.assert(!this.imageListenerKeys_,
'no listener keys existing'); 'no listener keys existing');
this.imageState_ = ol.style.ImageState.LOADING; this.imageState_ = ol.ImageState.LOADING;
this.imageListenerKeys_ = [ this.imageListenerKeys_ = [
ol.events.listenOnce(this.image_, ol.events.EventType.ERROR, ol.events.listenOnce(this.image_, ol.events.EventType.ERROR,
this.handleImageError_, this), this.handleImageError_, this),

View File

@@ -1,16 +1,4 @@
goog.provide('ol.style.Image'); goog.provide('ol.style.Image');
goog.provide('ol.style.ImageState');
/**
* @enum {number}
*/
ol.style.ImageState = {
IDLE: 0,
LOADING: 1,
LOADED: 2,
ERROR: 3
};
/** /**
@@ -136,7 +124,7 @@ ol.style.Image.prototype.getHitDetectionImage = function(pixelRatio) {};
/** /**
* @abstract * @abstract
* @return {ol.style.ImageState} Image state. * @return {ol.ImageState} Image state.
*/ */
ol.style.Image.prototype.getImageState = function() {}; ol.style.Image.prototype.getImageState = function() {};

View File

@@ -5,9 +5,9 @@ goog.require('ol.color');
goog.require('ol.colorlike'); goog.require('ol.colorlike');
goog.require('ol.dom'); goog.require('ol.dom');
goog.require('ol.has'); goog.require('ol.has');
goog.require('ol.ImageState');
goog.require('ol.render.canvas'); goog.require('ol.render.canvas');
goog.require('ol.style.Image'); goog.require('ol.style.Image');
goog.require('ol.style.ImageState');
/** /**
@@ -205,7 +205,7 @@ ol.style.RegularShape.prototype.getHitDetectionImageSize = function() {
* @inheritDoc * @inheritDoc
*/ */
ol.style.RegularShape.prototype.getImageState = function() { ol.style.RegularShape.prototype.getImageState = function() {
return ol.style.ImageState.LOADED; return ol.ImageState.LOADED;
}; };