Remove static members from ImageSource

This commit is contained in:
Tim Schaub
2018-02-25 08:27:23 -07:00
parent 12eccdc52d
commit 2188c5fa91
7 changed files with 46 additions and 46 deletions

View File

@@ -41,6 +41,32 @@ const ImageSourceEventType = {
}; };
/**
* @classdesc
* Events emitted by {@link ol.source.Image} instances are instances of this
* type.
*
* @constructor
* @extends {ol.events.Event}
* @implements {oli.source.ImageEvent}
* @param {string} type Type.
* @param {ol.Image} image The image.
*/
const ImageSourceEvent = function(type, image) {
Event.call(this, type);
/**
* The image related to the event.
* @type {ol.Image}
* @api
*/
this.image = image;
};
inherits(ImageSourceEvent, Event);
/** /**
* @classdesc * @classdesc
* Abstract base class; normally only used for creating subclasses and not * Abstract base class; normally only used for creating subclasses and not
@@ -174,17 +200,17 @@ ImageSource.prototype.handleImageChange = function(event) {
switch (image.getState()) { switch (image.getState()) {
case ImageState.LOADING: case ImageState.LOADING:
this.dispatchEvent( this.dispatchEvent(
new ImageSource.Event(ImageSourceEventType.IMAGELOADSTART, new ImageSourceEvent(ImageSourceEventType.IMAGELOADSTART,
image)); image));
break; break;
case ImageState.LOADED: case ImageState.LOADED:
this.dispatchEvent( this.dispatchEvent(
new ImageSource.Event(ImageSourceEventType.IMAGELOADEND, new ImageSourceEvent(ImageSourceEventType.IMAGELOADEND,
image)); image));
break; break;
case ImageState.ERROR: case ImageState.ERROR:
this.dispatchEvent( this.dispatchEvent(
new ImageSource.Event(ImageSourceEventType.IMAGELOADERROR, new ImageSourceEvent(ImageSourceEventType.IMAGELOADERROR,
image)); image));
break; break;
default: default:
@@ -199,35 +225,9 @@ ImageSource.prototype.handleImageChange = function(event) {
* @param {ol.Image} image Image. * @param {ol.Image} image Image.
* @param {string} src Source. * @param {string} src Source.
*/ */
ImageSource.defaultImageLoadFunction = function(image, src) { export function defaultImageLoadFunction(image, src) {
image.getImage().src = src; image.getImage().src = src;
}; }
/**
* @classdesc
* Events emitted by {@link ol.source.Image} instances are instances of this
* type.
*
* @constructor
* @extends {ol.events.Event}
* @implements {oli.source.ImageEvent}
* @param {string} type Type.
* @param {ol.Image} image The image.
*/
ImageSource.Event = function(type, image) {
Event.call(this, type);
/**
* The image related to the event.
* @type {ol.Image}
* @api
*/
this.image = image;
};
inherits(ImageSource.Event, Event);
export default ImageSource; export default ImageSource;

View File

@@ -8,7 +8,7 @@ import {listen} from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import {containsExtent, getHeight, getWidth} from '../extent.js'; import {containsExtent, getHeight, getWidth} from '../extent.js';
import {assign} from '../obj.js'; import {assign} from '../obj.js';
import ImageSource from '../source/Image.js'; import ImageSource, {defaultImageLoadFunction} from '../source/Image.js';
import {appendParams} from '../uri.js'; import {appendParams} from '../uri.js';
/** /**
@@ -60,7 +60,7 @@ const ImageArcGISRest = function(opt_options) {
* @type {ol.ImageLoadFunctionType} * @type {ol.ImageLoadFunctionType}
*/ */
this.imageLoadFunction_ = options.imageLoadFunction !== undefined ? this.imageLoadFunction_ = options.imageLoadFunction !== undefined ?
options.imageLoadFunction : ImageSource.defaultImageLoadFunction; options.imageLoadFunction : defaultImageLoadFunction;
/** /**

View File

@@ -7,7 +7,7 @@ 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';
import {assign} from '../obj.js'; import {assign} from '../obj.js';
import ImageSource from '../source/Image.js'; import ImageSource, {defaultImageLoadFunction} from '../source/Image.js';
import {appendParams} from '../uri.js'; import {appendParams} from '../uri.js';
/** /**
@@ -58,7 +58,7 @@ const ImageMapGuide = function(options) {
* @type {ol.ImageLoadFunctionType} * @type {ol.ImageLoadFunctionType}
*/ */
this.imageLoadFunction_ = options.imageLoadFunction !== undefined ? this.imageLoadFunction_ = options.imageLoadFunction !== undefined ?
options.imageLoadFunction : ImageSource.defaultImageLoadFunction; options.imageLoadFunction : defaultImageLoadFunction;
/** /**
* @private * @private

View File

@@ -9,7 +9,7 @@ import {listen} from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import {intersects, getHeight, getWidth} from '../extent.js'; import {intersects, getHeight, getWidth} from '../extent.js';
import {get as getProjection} from '../proj.js'; import {get as getProjection} from '../proj.js';
import ImageSource from '../source/Image.js'; import ImageSource, {defaultImageLoadFunction} from '../source/Image.js';
/** /**
* @classdesc * @classdesc
@@ -28,7 +28,7 @@ const Static = function(options) {
const /** @type {ol.ImageLoadFunctionType} */ imageLoadFunction = const /** @type {ol.ImageLoadFunctionType} */ imageLoadFunction =
options.imageLoadFunction !== undefined ? options.imageLoadFunction !== undefined ?
options.imageLoadFunction : ImageSource.defaultImageLoadFunction; options.imageLoadFunction : defaultImageLoadFunction;
ImageSource.call(this, { ImageSource.call(this, {
attributions: options.attributions, attributions: options.attributions,

View File

@@ -12,7 +12,7 @@ import {containsExtent, getCenter, getForViewAndSize, getHeight, getWidth} from
import {assign} from '../obj.js'; import {assign} from '../obj.js';
import {get as getProjection, transform} from '../proj.js'; import {get as getProjection, transform} from '../proj.js';
import {calculateSourceResolution} from '../reproj.js'; import {calculateSourceResolution} from '../reproj.js';
import ImageSource from '../source/Image.js'; import ImageSource, {defaultImageLoadFunction} from '../source/Image.js';
import WMSServerType from '../source/WMSServerType.js'; import WMSServerType from '../source/WMSServerType.js';
import {compareVersions} from '../string.js'; import {compareVersions} from '../string.js';
import {appendParams} from '../uri.js'; import {appendParams} from '../uri.js';
@@ -55,7 +55,7 @@ const ImageWMS = function(opt_options) {
* @type {ol.ImageLoadFunctionType} * @type {ol.ImageLoadFunctionType}
*/ */
this.imageLoadFunction_ = options.imageLoadFunction !== undefined ? this.imageLoadFunction_ = options.imageLoadFunction !== undefined ?
options.imageLoadFunction : ImageSource.defaultImageLoadFunction; options.imageLoadFunction : defaultImageLoadFunction;
/** /**
* @private * @private

View File

@@ -2,7 +2,7 @@ import ImageTile from '../../../src/ol/ImageTile.js';
import TileState from '../../../src/ol/TileState.js'; import TileState from '../../../src/ol/TileState.js';
import {listen, unlistenByKey} from '../../../src/ol/events.js'; import {listen, unlistenByKey} from '../../../src/ol/events.js';
import EventType from '../../../src/ol/events/EventType.js'; import EventType from '../../../src/ol/events/EventType.js';
import ImageSource from '../../../src/ol/source/Image.js'; import {defaultImageLoadFunction} from '../../../src/ol/source/Image.js';
describe('ol.ImageTile', function() { describe('ol.ImageTile', function() {
@@ -13,7 +13,7 @@ describe('ol.ImageTile', function() {
const tileCoord = [0, 0, 0]; const tileCoord = [0, 0, 0];
const state = TileState.IDLE; const state = TileState.IDLE;
const src = 'spec/ol/data/osm-0-0-0.png'; const src = 'spec/ol/data/osm-0-0-0.png';
const tileLoadFunction = ImageSource.defaultImageLoadFunction; const tileLoadFunction = defaultImageLoadFunction;
const tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction); const tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
let previousState = tile.getState(); let previousState = tile.getState();
@@ -38,7 +38,7 @@ describe('ol.ImageTile', function() {
const tileCoord = [0, 0, 0]; const tileCoord = [0, 0, 0];
const state = TileState.ERROR; const state = TileState.ERROR;
const src = 'spec/ol/data/osm-0-0-0.png'; const src = 'spec/ol/data/osm-0-0-0.png';
const tileLoadFunction = ImageSource.defaultImageLoadFunction; const tileLoadFunction = defaultImageLoadFunction;
const tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction); const tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
let previousState = tile.getState(); let previousState = tile.getState();
@@ -63,7 +63,7 @@ describe('ol.ImageTile', function() {
const tileCoord = [0, 0, 0]; const tileCoord = [0, 0, 0];
const state = TileState.IDLE; const state = TileState.IDLE;
const src = 'spec/ol/data/osm-0-0-99.png'; const src = 'spec/ol/data/osm-0-0-99.png';
const tileLoadFunction = ImageSource.defaultImageLoadFunction; const tileLoadFunction = defaultImageLoadFunction;
const tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction); const tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
const key = listen(tile, EventType.CHANGE, function(event) { const key = listen(tile, EventType.CHANGE, function(event) {
@@ -89,7 +89,7 @@ describe('ol.ImageTile', function() {
const tileCoord = [0, 0, 0]; const tileCoord = [0, 0, 0];
const state = TileState.IDLE; const state = TileState.IDLE;
const src = 'spec/ol/data/osm-0-0-0.png'; const src = 'spec/ol/data/osm-0-0-0.png';
const tileLoadFunction = ImageSource.defaultImageLoadFunction; const tileLoadFunction = defaultImageLoadFunction;
const tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction); const tile = new ImageTile(tileCoord, state, src, null, tileLoadFunction);
tile.load(); tile.load();
expect(tile.getState()).to.be(TileState.LOADING); expect(tile.getState()).to.be(TileState.LOADING);

View File

@@ -2,7 +2,7 @@ import ImageTile from '../../../src/ol/ImageTile.js';
import Tile from '../../../src/ol/Tile.js'; import Tile from '../../../src/ol/Tile.js';
import TileQueue from '../../../src/ol/TileQueue.js'; import TileQueue from '../../../src/ol/TileQueue.js';
import TileState from '../../../src/ol/TileState.js'; import TileState from '../../../src/ol/TileState.js';
import ImageSource from '../../../src/ol/source/Image.js'; import {defaultImageLoadFunction} from '../../../src/ol/source/Image.js';
import {DROP} from '../../../src/ol/structs/PriorityQueue.js'; import {DROP} from '../../../src/ol/structs/PriorityQueue.js';
@@ -32,7 +32,7 @@ describe('ol.TileQueue', function() {
'yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw=='; 'yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==';
const tileLoadFunction = opt_tileLoadFunction ? const tileLoadFunction = opt_tileLoadFunction ?
opt_tileLoadFunction : ImageSource.defaultImageLoadFunction; opt_tileLoadFunction : defaultImageLoadFunction;
return new ImageTile(tileCoord, state, src, null, tileLoadFunction); return new ImageTile(tileCoord, state, src, null, tileLoadFunction);
} }