Rename _ol_Image_ to ImageWrapper

This commit is contained in:
Tim Schaub
2018-02-08 11:49:37 -07:00
parent e075a4fbca
commit 0d5026165f
7 changed files with 22 additions and 21 deletions

View File

@@ -18,7 +18,7 @@ import {getHeight} from './extent.js';
* @param {?string} crossOrigin Cross origin. * @param {?string} crossOrigin Cross origin.
* @param {ol.ImageLoadFunctionType} imageLoadFunction Image load function. * @param {ol.ImageLoadFunctionType} imageLoadFunction Image load function.
*/ */
const _ol_Image_ = function(extent, resolution, pixelRatio, src, crossOrigin, imageLoadFunction) { const ImageWrapper = function(extent, resolution, pixelRatio, src, crossOrigin, imageLoadFunction) {
ImageBase.call(this, extent, resolution, pixelRatio, ImageState.IDLE); ImageBase.call(this, extent, resolution, pixelRatio, ImageState.IDLE);
@@ -57,14 +57,14 @@ const _ol_Image_ = function(extent, resolution, pixelRatio, src, crossOrigin, im
}; };
inherits(_ol_Image_, ImageBase); inherits(ImageWrapper, ImageBase);
/** /**
* @inheritDoc * @inheritDoc
* @api * @api
*/ */
_ol_Image_.prototype.getImage = function() { ImageWrapper.prototype.getImage = function() {
return this.image_; return this.image_;
}; };
@@ -74,7 +74,7 @@ _ol_Image_.prototype.getImage = function() {
* *
* @private * @private
*/ */
_ol_Image_.prototype.handleImageError_ = function() { ImageWrapper.prototype.handleImageError_ = function() {
this.state = ImageState.ERROR; this.state = ImageState.ERROR;
this.unlistenImage_(); this.unlistenImage_();
this.changed(); this.changed();
@@ -86,7 +86,7 @@ _ol_Image_.prototype.handleImageError_ = function() {
* *
* @private * @private
*/ */
_ol_Image_.prototype.handleImageLoad_ = function() { ImageWrapper.prototype.handleImageLoad_ = function() {
if (this.resolution === undefined) { if (this.resolution === undefined) {
this.resolution = getHeight(this.extent) / this.image_.height; this.resolution = getHeight(this.extent) / this.image_.height;
} }
@@ -103,7 +103,7 @@ _ol_Image_.prototype.handleImageLoad_ = function() {
* @override * @override
* @api * @api
*/ */
_ol_Image_.prototype.load = function() { ImageWrapper.prototype.load = function() {
if (this.state == ImageState.IDLE || this.state == ImageState.ERROR) { if (this.state == ImageState.IDLE || this.state == ImageState.ERROR) {
this.state = ImageState.LOADING; this.state = ImageState.LOADING;
this.changed(); this.changed();
@@ -121,7 +121,7 @@ _ol_Image_.prototype.load = function() {
/** /**
* @param {HTMLCanvasElement|Image|HTMLVideoElement} image Image. * @param {HTMLCanvasElement|Image|HTMLVideoElement} image Image.
*/ */
_ol_Image_.prototype.setImage = function(image) { ImageWrapper.prototype.setImage = function(image) {
this.image_ = image; this.image_ = image;
}; };
@@ -131,8 +131,9 @@ _ol_Image_.prototype.setImage = function(image) {
* *
* @private * @private
*/ */
_ol_Image_.prototype.unlistenImage_ = function() { ImageWrapper.prototype.unlistenImage_ = function() {
this.imageListenerKeys_.forEach(unlistenByKey); this.imageListenerKeys_.forEach(unlistenByKey);
this.imageListenerKeys_ = null; this.imageListenerKeys_ = null;
}; };
export default _ol_Image_;
export default ImageWrapper;

View File

@@ -2,7 +2,7 @@
* @module ol/source/ImageArcGISRest * @module ol/source/ImageArcGISRest
*/ */
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import _ol_Image_ from '../Image.js'; import ImageWrapper from '../Image.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import {listen} from '../events.js'; import {listen} from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
@@ -168,7 +168,7 @@ ImageArcGISRest.prototype.getImageInternal = function(extent, resolution, pixelR
const url = this.getRequestUrl_(extent, this.imageSize_, pixelRatio, const url = this.getRequestUrl_(extent, this.imageSize_, pixelRatio,
projection, params); projection, params);
this.image_ = new _ol_Image_(extent, resolution, pixelRatio, this.image_ = new ImageWrapper(extent, resolution, pixelRatio,
url, this.crossOrigin_, this.imageLoadFunction_); url, this.crossOrigin_, this.imageLoadFunction_);
this.renderedRevision_ = this.getRevision(); this.renderedRevision_ = this.getRevision();

View File

@@ -2,7 +2,7 @@
* @module ol/source/ImageMapGuide * @module ol/source/ImageMapGuide
*/ */
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import _ol_Image_ from '../Image.js'; import ImageWrapper from '../Image.js';
import {listen} from '../events.js'; import {listen} from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import {containsExtent, getCenter, getHeight, getWidth, scaleFromCenter} from '../extent.js'; import {containsExtent, getCenter, getHeight, getWidth, scaleFromCenter} from '../extent.js';
@@ -141,7 +141,7 @@ ImageMapGuide.prototype.getImageInternal = function(extent, resolution, pixelRat
if (this.url_ !== undefined) { if (this.url_ !== undefined) {
const imageUrl = this.getUrl(this.url_, this.params_, extent, size, const imageUrl = this.getUrl(this.url_, this.params_, extent, size,
projection); projection);
image = new _ol_Image_(extent, resolution, pixelRatio, image = new ImageWrapper(extent, resolution, pixelRatio,
imageUrl, this.crossOrigin_, imageUrl, this.crossOrigin_,
this.imageLoadFunction_); this.imageLoadFunction_);
listen(image, EventType.CHANGE, listen(image, EventType.CHANGE,

View File

@@ -2,7 +2,7 @@
* @module ol/source/ImageStatic * @module ol/source/ImageStatic
*/ */
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import _ol_Image_ from '../Image.js'; import ImageWrapper from '../Image.js';
import ImageState from '../ImageState.js'; import ImageState from '../ImageState.js';
import {createCanvasContext2D} from '../dom.js'; import {createCanvasContext2D} from '../dom.js';
import {listen} from '../events.js'; import {listen} from '../events.js';
@@ -39,7 +39,7 @@ const Static = function(options) {
* @private * @private
* @type {ol.Image} * @type {ol.Image}
*/ */
this.image_ = new _ol_Image_(imageExtent, undefined, 1, options.url, crossOrigin, imageLoadFunction); this.image_ = new ImageWrapper(imageExtent, undefined, 1, options.url, crossOrigin, imageLoadFunction);
/** /**
* @private * @private

View File

@@ -4,7 +4,7 @@
import {DEFAULT_WMS_VERSION} from './common.js'; import {DEFAULT_WMS_VERSION} from './common.js';
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import _ol_Image_ from '../Image.js'; import ImageWrapper from '../Image.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
import {listen} from '../events.js'; import {listen} from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
@@ -231,7 +231,7 @@ ImageWMS.prototype.getImageInternal = function(extent, resolution, pixelRatio, p
const url = this.getRequestUrl_(requestExtent, this.imageSize_, pixelRatio, const url = this.getRequestUrl_(requestExtent, this.imageSize_, pixelRatio,
projection, params); projection, params);
this.image_ = new _ol_Image_(requestExtent, resolution, pixelRatio, this.image_ = new ImageWrapper(requestExtent, resolution, pixelRatio,
url, this.crossOrigin_, this.imageLoadFunction_); url, this.crossOrigin_, this.imageLoadFunction_);
this.renderedRevision_ = this.getRevision(); this.renderedRevision_ = this.getRevision();

View File

@@ -1,4 +1,4 @@
import _ol_Image_ from '../../../../src/ol/Image.js'; import ImageWrapper from '../../../../src/ol/Image.js';
import Map from '../../../../src/ol/Map.js'; import Map from '../../../../src/ol/Map.js';
import View from '../../../../src/ol/View.js'; import View from '../../../../src/ol/View.js';
import Layer from '../../../../src/ol/layer/Layer.js'; import Layer from '../../../../src/ol/layer/Layer.js';
@@ -28,7 +28,7 @@ describe('ol.renderer.Layer', function() {
const src = ''; const src = '';
const crossOrigin = ''; const crossOrigin = '';
imageLoadFunction = sinon.spy(); imageLoadFunction = sinon.spy();
image = new _ol_Image_(extent, resolution, pixelRatio, src, crossOrigin, imageLoadFunction); image = new ImageWrapper(extent, resolution, pixelRatio, src, crossOrigin, imageLoadFunction);
}); });
describe('load IDLE image', function() { describe('load IDLE image', function() {

View File

@@ -1,4 +1,4 @@
import _ol_Image_ from '../../../../src/ol/Image.js'; import ImageWrapper from '../../../../src/ol/Image.js';
import {listen} from '../../../../src/ol/events.js'; import {listen} from '../../../../src/ol/events.js';
import {get as getProjection} from '../../../../src/ol/proj.js'; import {get as getProjection} from '../../../../src/ol/proj.js';
import ReprojImage from '../../../../src/ol/reproj/Image.js'; import ReprojImage from '../../../../src/ol/reproj/Image.js';
@@ -10,7 +10,7 @@ describe('ol.reproj.Image', function() {
getProjection('EPSG:3857'), getProjection('EPSG:4326'), getProjection('EPSG:3857'), getProjection('EPSG:4326'),
[-180, -85, 180, 85], 10, pixelRatio, [-180, -85, 180, 85], 10, pixelRatio,
function(extent, resolution, pixelRatio) { function(extent, resolution, pixelRatio) {
return new _ol_Image_(extent, resolution, pixelRatio, return new ImageWrapper(extent, resolution, pixelRatio,
'data:image/gif;base64,' + 'data:image/gif;base64,' +
'R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=', null, 'R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=', null,
function(image, src) { function(image, src) {