Rename _ol_ImageState_ to ImageState
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {inherits} from './index.js';
|
||||
import _ol_ImageBase_ from './ImageBase.js';
|
||||
import _ol_ImageState_ from './ImageState.js';
|
||||
import ImageState from './ImageState.js';
|
||||
import _ol_events_ from './events.js';
|
||||
import EventType from './events/EventType.js';
|
||||
import {getHeight} from './extent.js';
|
||||
@@ -20,7 +20,7 @@ import {getHeight} from './extent.js';
|
||||
*/
|
||||
var _ol_Image_ = function(extent, resolution, pixelRatio, src, crossOrigin, imageLoadFunction) {
|
||||
|
||||
_ol_ImageBase_.call(this, extent, resolution, pixelRatio, _ol_ImageState_.IDLE);
|
||||
_ol_ImageBase_.call(this, extent, resolution, pixelRatio, ImageState.IDLE);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -47,7 +47,7 @@ var _ol_Image_ = function(extent, resolution, pixelRatio, src, crossOrigin, imag
|
||||
* @protected
|
||||
* @type {ol.ImageState}
|
||||
*/
|
||||
this.state = _ol_ImageState_.IDLE;
|
||||
this.state = ImageState.IDLE;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -75,7 +75,7 @@ _ol_Image_.prototype.getImage = function() {
|
||||
* @private
|
||||
*/
|
||||
_ol_Image_.prototype.handleImageError_ = function() {
|
||||
this.state = _ol_ImageState_.ERROR;
|
||||
this.state = ImageState.ERROR;
|
||||
this.unlistenImage_();
|
||||
this.changed();
|
||||
};
|
||||
@@ -90,7 +90,7 @@ _ol_Image_.prototype.handleImageLoad_ = function() {
|
||||
if (this.resolution === undefined) {
|
||||
this.resolution = getHeight(this.extent) / this.image_.height;
|
||||
}
|
||||
this.state = _ol_ImageState_.LOADED;
|
||||
this.state = ImageState.LOADED;
|
||||
this.unlistenImage_();
|
||||
this.changed();
|
||||
};
|
||||
@@ -104,8 +104,8 @@ _ol_Image_.prototype.handleImageLoad_ = function() {
|
||||
* @api
|
||||
*/
|
||||
_ol_Image_.prototype.load = function() {
|
||||
if (this.state == _ol_ImageState_.IDLE || this.state == _ol_ImageState_.ERROR) {
|
||||
this.state = _ol_ImageState_.LOADING;
|
||||
if (this.state == ImageState.IDLE || this.state == ImageState.ERROR) {
|
||||
this.state = ImageState.LOADING;
|
||||
this.changed();
|
||||
this.imageListenerKeys_ = [
|
||||
_ol_events_.listenOnce(this.image_, EventType.ERROR,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {inherits} from './index.js';
|
||||
import _ol_ImageBase_ from './ImageBase.js';
|
||||
import _ol_ImageState_ from './ImageState.js';
|
||||
import ImageState from './ImageState.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -24,8 +24,7 @@ var _ol_ImageCanvas_ = function(extent, resolution, pixelRatio, canvas, opt_load
|
||||
*/
|
||||
this.loader_ = opt_loader !== undefined ? opt_loader : null;
|
||||
|
||||
var state = opt_loader !== undefined ?
|
||||
_ol_ImageState_.IDLE : _ol_ImageState_.LOADED;
|
||||
var state = opt_loader !== undefined ? ImageState.IDLE : ImageState.LOADED;
|
||||
|
||||
_ol_ImageBase_.call(this, extent, resolution, pixelRatio, state);
|
||||
|
||||
@@ -63,9 +62,9 @@ _ol_ImageCanvas_.prototype.getError = function() {
|
||||
_ol_ImageCanvas_.prototype.handleLoad_ = function(err) {
|
||||
if (err) {
|
||||
this.error_ = err;
|
||||
this.state = _ol_ImageState_.ERROR;
|
||||
this.state = ImageState.ERROR;
|
||||
} else {
|
||||
this.state = _ol_ImageState_.LOADED;
|
||||
this.state = ImageState.LOADED;
|
||||
}
|
||||
this.changed();
|
||||
};
|
||||
@@ -75,8 +74,8 @@ _ol_ImageCanvas_.prototype.handleLoad_ = function(err) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
_ol_ImageCanvas_.prototype.load = function() {
|
||||
if (this.state == _ol_ImageState_.IDLE) {
|
||||
this.state = _ol_ImageState_.LOADING;
|
||||
if (this.state == ImageState.IDLE) {
|
||||
this.state = ImageState.LOADING;
|
||||
this.changed();
|
||||
this.loader_(this.handleLoad_.bind(this));
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/renderer/Layer
|
||||
*/
|
||||
import {getUid, inherits, nullFunction} from '../index.js';
|
||||
import _ol_ImageState_ from '../ImageState.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import _ol_Observable_ from '../Observable.js';
|
||||
import _ol_TileState_ from '../TileState.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
@@ -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_ImageState_.LOADED) {
|
||||
if (image.getState() === ImageState.LOADED) {
|
||||
this.renderIfReadyAndVisible();
|
||||
}
|
||||
};
|
||||
@@ -114,16 +114,14 @@ _ol_renderer_Layer_.prototype.handleImageChange_ = function(event) {
|
||||
*/
|
||||
_ol_renderer_Layer_.prototype.loadImage = function(image) {
|
||||
var imageState = image.getState();
|
||||
if (imageState != _ol_ImageState_.LOADED &&
|
||||
imageState != _ol_ImageState_.ERROR) {
|
||||
_ol_events_.listen(image, EventType.CHANGE,
|
||||
this.handleImageChange_, this);
|
||||
if (imageState != ImageState.LOADED && imageState != ImageState.ERROR) {
|
||||
_ol_events_.listen(image, EventType.CHANGE, this.handleImageChange_, this);
|
||||
}
|
||||
if (imageState == _ol_ImageState_.IDLE) {
|
||||
if (imageState == ImageState.IDLE) {
|
||||
image.load();
|
||||
imageState = image.getState();
|
||||
}
|
||||
return imageState == _ol_ImageState_.LOADED;
|
||||
return imageState == ImageState.LOADED;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/renderer/vector
|
||||
*/
|
||||
import {getUid} from '../index.js';
|
||||
import _ol_ImageState_ from '../ImageState.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import GeometryType from '../geom/GeometryType.js';
|
||||
import _ol_render_ReplayType_ from '../render/ReplayType.js';
|
||||
var _ol_renderer_vector_ = {};
|
||||
@@ -88,11 +88,10 @@ _ol_renderer_vector_.renderFeature = function(
|
||||
imageStyle = style.getImage();
|
||||
if (imageStyle) {
|
||||
imageState = imageStyle.getImageState();
|
||||
if (imageState == _ol_ImageState_.LOADED ||
|
||||
imageState == _ol_ImageState_.ERROR) {
|
||||
if (imageState == ImageState.LOADED || imageState == ImageState.ERROR) {
|
||||
imageStyle.unlistenImageChange(listener, thisArg);
|
||||
} else {
|
||||
if (imageState == _ol_ImageState_.IDLE) {
|
||||
if (imageState == ImageState.IDLE) {
|
||||
imageStyle.load();
|
||||
}
|
||||
imageState = imageStyle.getImageState();
|
||||
@@ -256,7 +255,7 @@ _ol_renderer_vector_.renderMultiPolygonGeometry_ = function(replayGroup, geometr
|
||||
_ol_renderer_vector_.renderPointGeometry_ = function(replayGroup, geometry, style, feature) {
|
||||
var imageStyle = style.getImage();
|
||||
if (imageStyle) {
|
||||
if (imageStyle.getImageState() != _ol_ImageState_.LOADED) {
|
||||
if (imageStyle.getImageState() != ImageState.LOADED) {
|
||||
return;
|
||||
}
|
||||
var imageReplay = replayGroup.getReplay(
|
||||
@@ -284,7 +283,7 @@ _ol_renderer_vector_.renderPointGeometry_ = function(replayGroup, geometry, styl
|
||||
_ol_renderer_vector_.renderMultiPointGeometry_ = function(replayGroup, geometry, style, feature) {
|
||||
var imageStyle = style.getImage();
|
||||
if (imageStyle) {
|
||||
if (imageStyle.getImageState() != _ol_ImageState_.LOADED) {
|
||||
if (imageStyle.getImageState() != ImageState.LOADED) {
|
||||
return;
|
||||
}
|
||||
var imageReplay = replayGroup.getReplay(
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {ERROR_THRESHOLD} from './common.js';
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_ImageBase_ from '../ImageBase.js';
|
||||
import _ol_ImageState_ from '../ImageState.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import {getCenter, getIntersection, getHeight, getWidth} from '../extent.js';
|
||||
@@ -100,10 +100,10 @@ var _ol_reproj_Image_ = function(sourceProj, targetProj,
|
||||
this.sourceListenerKey_ = null;
|
||||
|
||||
|
||||
var state = _ol_ImageState_.LOADED;
|
||||
var state = ImageState.LOADED;
|
||||
|
||||
if (this.sourceImage_) {
|
||||
state = _ol_ImageState_.IDLE;
|
||||
state = ImageState.IDLE;
|
||||
}
|
||||
|
||||
_ol_ImageBase_.call(this, targetExtent, targetResolution, this.sourcePixelRatio_, state);
|
||||
@@ -116,7 +116,7 @@ inherits(_ol_reproj_Image_, _ol_ImageBase_);
|
||||
* @inheritDoc
|
||||
*/
|
||||
_ol_reproj_Image_.prototype.disposeInternal = function() {
|
||||
if (this.state == _ol_ImageState_.LOADING) {
|
||||
if (this.state == ImageState.LOADING) {
|
||||
this.unlistenSource_();
|
||||
}
|
||||
_ol_ImageBase_.prototype.disposeInternal.call(this);
|
||||
@@ -144,7 +144,7 @@ _ol_reproj_Image_.prototype.getProjection = function() {
|
||||
*/
|
||||
_ol_reproj_Image_.prototype.reproject_ = function() {
|
||||
var sourceState = this.sourceImage_.getState();
|
||||
if (sourceState == _ol_ImageState_.LOADED) {
|
||||
if (sourceState == ImageState.LOADED) {
|
||||
var width = getWidth(this.targetExtent_) / this.targetResolution_;
|
||||
var height = getHeight(this.targetExtent_) / this.targetResolution_;
|
||||
|
||||
@@ -164,20 +164,18 @@ _ol_reproj_Image_.prototype.reproject_ = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
_ol_reproj_Image_.prototype.load = function() {
|
||||
if (this.state == _ol_ImageState_.IDLE) {
|
||||
this.state = _ol_ImageState_.LOADING;
|
||||
if (this.state == ImageState.IDLE) {
|
||||
this.state = ImageState.LOADING;
|
||||
this.changed();
|
||||
|
||||
var sourceState = this.sourceImage_.getState();
|
||||
if (sourceState == _ol_ImageState_.LOADED ||
|
||||
sourceState == _ol_ImageState_.ERROR) {
|
||||
if (sourceState == ImageState.LOADED || sourceState == ImageState.ERROR) {
|
||||
this.reproject_();
|
||||
} else {
|
||||
this.sourceListenerKey_ = _ol_events_.listen(this.sourceImage_,
|
||||
EventType.CHANGE, function(e) {
|
||||
var sourceState = this.sourceImage_.getState();
|
||||
if (sourceState == _ol_ImageState_.LOADED ||
|
||||
sourceState == _ol_ImageState_.ERROR) {
|
||||
if (sourceState == ImageState.LOADED || sourceState == ImageState.ERROR) {
|
||||
this.unlistenSource_();
|
||||
this.reproject_();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {ENABLE_RASTER_REPROJECTION} from '../reproj/common.js';
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_ImageState_ from '../ImageState.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import Event from '../events/Event.js';
|
||||
import {equals} from '../extent.js';
|
||||
@@ -142,17 +142,17 @@ _ol_source_Image_.prototype.getImageInternal = function(extent, resolution, pixe
|
||||
_ol_source_Image_.prototype.handleImageChange = function(event) {
|
||||
var image = /** @type {ol.Image} */ (event.target);
|
||||
switch (image.getState()) {
|
||||
case _ol_ImageState_.LOADING:
|
||||
case ImageState.LOADING:
|
||||
this.dispatchEvent(
|
||||
new _ol_source_Image_.Event(_ol_source_Image_.EventType_.IMAGELOADSTART,
|
||||
image));
|
||||
break;
|
||||
case _ol_ImageState_.LOADED:
|
||||
case ImageState.LOADED:
|
||||
this.dispatchEvent(
|
||||
new _ol_source_Image_.Event(_ol_source_Image_.EventType_.IMAGELOADEND,
|
||||
image));
|
||||
break;
|
||||
case _ol_ImageState_.ERROR:
|
||||
case ImageState.ERROR:
|
||||
this.dispatchEvent(
|
||||
new _ol_source_Image_.Event(_ol_source_Image_.EventType_.IMAGELOADERROR,
|
||||
image));
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
import {inherits} from '../index.js';
|
||||
import _ol_Image_ from '../Image.js';
|
||||
import _ol_ImageState_ from '../ImageState.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import {createCanvasContext2D} from '../dom.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
@@ -70,7 +70,7 @@ _ol_source_ImageStatic_.prototype.getImageInternal = function(extent, resolution
|
||||
* @inheritDoc
|
||||
*/
|
||||
_ol_source_ImageStatic_.prototype.handleImageChange = function(evt) {
|
||||
if (this.image_.getState() == _ol_ImageState_.LOADED) {
|
||||
if (this.image_.getState() == ImageState.LOADED) {
|
||||
var imageExtent = this.image_.getExtent();
|
||||
var image = this.image_.getImage();
|
||||
var imageWidth, imageHeight;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @module ol/style/Icon
|
||||
*/
|
||||
import {getUid, inherits} from '../index.js';
|
||||
import _ol_ImageState_ from '../ImageState.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import {assert} from '../asserts.js';
|
||||
import _ol_color_ from '../color.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
@@ -95,7 +95,7 @@ var _ol_style_Icon_ = function(opt_options) {
|
||||
* @type {ol.ImageState}
|
||||
*/
|
||||
var imageState = options.src !== undefined ?
|
||||
_ol_ImageState_.IDLE : _ol_ImageState_.LOADED;
|
||||
ImageState.IDLE : ImageState.LOADED;
|
||||
|
||||
/**
|
||||
* @private
|
||||
|
||||
@@ -6,7 +6,7 @@ import {createCanvasContext2D} from '../dom.js';
|
||||
import _ol_events_ from '../events.js';
|
||||
import EventTarget from '../events/EventTarget.js';
|
||||
import EventType from '../events/EventType.js';
|
||||
import _ol_ImageState_ from '../ImageState.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import _ol_style_ from '../style.js';
|
||||
|
||||
/**
|
||||
@@ -83,7 +83,7 @@ var _ol_style_IconImage_ = function(image, src, size, crossOrigin, imageState,
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.tainting_ = false;
|
||||
if (this.imageState_ == _ol_ImageState_.LOADED) {
|
||||
if (this.imageState_ == ImageState.LOADED) {
|
||||
this.determineTainting_();
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ _ol_style_IconImage_.prototype.dispatchChangeEvent_ = function() {
|
||||
* @private
|
||||
*/
|
||||
_ol_style_IconImage_.prototype.handleImageError_ = function() {
|
||||
this.imageState_ = _ol_ImageState_.ERROR;
|
||||
this.imageState_ = ImageState.ERROR;
|
||||
this.unlistenImage_();
|
||||
this.dispatchChangeEvent_();
|
||||
};
|
||||
@@ -150,7 +150,7 @@ _ol_style_IconImage_.prototype.handleImageError_ = function() {
|
||||
* @private
|
||||
*/
|
||||
_ol_style_IconImage_.prototype.handleImageLoad_ = function() {
|
||||
this.imageState_ = _ol_ImageState_.LOADED;
|
||||
this.imageState_ = ImageState.LOADED;
|
||||
if (this.size_) {
|
||||
this.image_.width = this.size_[0];
|
||||
this.image_.height = this.size_[1];
|
||||
@@ -220,8 +220,8 @@ _ol_style_IconImage_.prototype.getSrc = function() {
|
||||
* Load not yet loaded URI.
|
||||
*/
|
||||
_ol_style_IconImage_.prototype.load = function() {
|
||||
if (this.imageState_ == _ol_ImageState_.IDLE) {
|
||||
this.imageState_ = _ol_ImageState_.LOADING;
|
||||
if (this.imageState_ == ImageState.IDLE) {
|
||||
this.imageState_ = ImageState.LOADING;
|
||||
this.imageListenerKeys_ = [
|
||||
_ol_events_.listenOnce(this.image_, EventType.ERROR,
|
||||
this.handleImageError_, this),
|
||||
|
||||
@@ -5,7 +5,7 @@ import {inherits} from '../index.js';
|
||||
import {asColorLike} from '../colorlike.js';
|
||||
import {createCanvasContext2D} from '../dom.js';
|
||||
import _ol_has_ from '../has.js';
|
||||
import _ol_ImageState_ from '../ImageState.js';
|
||||
import ImageState from '../ImageState.js';
|
||||
import _ol_render_canvas_ from '../render/canvas.js';
|
||||
import _ol_style_Image_ from '../style/Image.js';
|
||||
|
||||
@@ -228,7 +228,7 @@ _ol_style_RegularShape_.prototype.getHitDetectionImageSize = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
_ol_style_RegularShape_.prototype.getImageState = function() {
|
||||
return _ol_ImageState_.LOADED;
|
||||
return ImageState.LOADED;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user