Rename _ol_style_IconImage_ to IconImage

This commit is contained in:
Tim Schaub
2018-01-11 13:29:26 -07:00
parent 14ddcf843d
commit 66182f4cfb
4 changed files with 28 additions and 28 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ import {asArray} from '../color.js';
import _ol_events_ from '../events.js'; import _ol_events_ from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
import IconAnchorUnits from '../style/IconAnchorUnits.js'; import IconAnchorUnits from '../style/IconAnchorUnits.js';
import _ol_style_IconImage_ from '../style/IconImage.js'; import IconImage from '../style/IconImage.js';
import IconOrigin from '../style/IconOrigin.js'; import IconOrigin from '../style/IconOrigin.js';
import _ol_style_Image_ from '../style/Image.js'; import _ol_style_Image_ from '../style/Image.js';
@@ -107,7 +107,7 @@ var Icon = function(opt_options) {
* @private * @private
* @type {ol.style.IconImage} * @type {ol.style.IconImage}
*/ */
this.iconImage_ = _ol_style_IconImage_.get( this.iconImage_ = IconImage.get(
image, /** @type {string} */ (src), imgSize, this.crossOrigin_, imageState, this.color_); image, /** @type {string} */ (src), imgSize, this.crossOrigin_, imageState, this.color_);
/** /**
+17 -17
View File
@@ -19,7 +19,7 @@ import {iconImageCache} from '../style.js';
* @param {ol.Color} color Color. * @param {ol.Color} color Color.
* @extends {ol.events.EventTarget} * @extends {ol.events.EventTarget}
*/ */
var _ol_style_IconImage_ = function(image, src, size, crossOrigin, imageState, var IconImage = function(image, src, size, crossOrigin, imageState,
color) { color) {
EventTarget.call(this); EventTarget.call(this);
@@ -89,7 +89,7 @@ var _ol_style_IconImage_ = function(image, src, size, crossOrigin, imageState,
}; };
inherits(_ol_style_IconImage_, EventTarget); inherits(IconImage, EventTarget);
/** /**
@@ -101,11 +101,11 @@ inherits(_ol_style_IconImage_, EventTarget);
* @param {ol.Color} color Color. * @param {ol.Color} color Color.
* @return {ol.style.IconImage} Icon image. * @return {ol.style.IconImage} Icon image.
*/ */
_ol_style_IconImage_.get = function(image, src, size, crossOrigin, imageState, IconImage.get = function(image, src, size, crossOrigin, imageState,
color) { color) {
var iconImage = iconImageCache.get(src, crossOrigin, color); var iconImage = iconImageCache.get(src, crossOrigin, color);
if (!iconImage) { if (!iconImage) {
iconImage = new _ol_style_IconImage_( iconImage = new IconImage(
image, src, size, crossOrigin, imageState, color); image, src, size, crossOrigin, imageState, color);
iconImageCache.set(src, crossOrigin, color, iconImage); iconImageCache.set(src, crossOrigin, color, iconImage);
} }
@@ -116,7 +116,7 @@ _ol_style_IconImage_.get = function(image, src, size, crossOrigin, imageState,
/** /**
* @private * @private
*/ */
_ol_style_IconImage_.prototype.determineTainting_ = function() { IconImage.prototype.determineTainting_ = function() {
var context = createCanvasContext2D(1, 1); var context = createCanvasContext2D(1, 1);
try { try {
context.drawImage(this.image_, 0, 0); context.drawImage(this.image_, 0, 0);
@@ -130,7 +130,7 @@ _ol_style_IconImage_.prototype.determineTainting_ = function() {
/** /**
* @private * @private
*/ */
_ol_style_IconImage_.prototype.dispatchChangeEvent_ = function() { IconImage.prototype.dispatchChangeEvent_ = function() {
this.dispatchEvent(EventType.CHANGE); this.dispatchEvent(EventType.CHANGE);
}; };
@@ -138,7 +138,7 @@ _ol_style_IconImage_.prototype.dispatchChangeEvent_ = function() {
/** /**
* @private * @private
*/ */
_ol_style_IconImage_.prototype.handleImageError_ = function() { IconImage.prototype.handleImageError_ = function() {
this.imageState_ = ImageState.ERROR; this.imageState_ = ImageState.ERROR;
this.unlistenImage_(); this.unlistenImage_();
this.dispatchChangeEvent_(); this.dispatchChangeEvent_();
@@ -148,7 +148,7 @@ _ol_style_IconImage_.prototype.handleImageError_ = function() {
/** /**
* @private * @private
*/ */
_ol_style_IconImage_.prototype.handleImageLoad_ = function() { IconImage.prototype.handleImageLoad_ = function() {
this.imageState_ = ImageState.LOADED; this.imageState_ = ImageState.LOADED;
if (this.size_) { if (this.size_) {
this.image_.width = this.size_[0]; this.image_.width = this.size_[0];
@@ -166,7 +166,7 @@ _ol_style_IconImage_.prototype.handleImageLoad_ = function() {
* @param {number} pixelRatio Pixel ratio. * @param {number} pixelRatio Pixel ratio.
* @return {Image|HTMLCanvasElement} Image or Canvas element. * @return {Image|HTMLCanvasElement} Image or Canvas element.
*/ */
_ol_style_IconImage_.prototype.getImage = function(pixelRatio) { IconImage.prototype.getImage = function(pixelRatio) {
return this.canvas_ ? this.canvas_ : this.image_; return this.canvas_ ? this.canvas_ : this.image_;
}; };
@@ -174,7 +174,7 @@ _ol_style_IconImage_.prototype.getImage = function(pixelRatio) {
/** /**
* @return {ol.ImageState} Image state. * @return {ol.ImageState} Image state.
*/ */
_ol_style_IconImage_.prototype.getImageState = function() { IconImage.prototype.getImageState = function() {
return this.imageState_; return this.imageState_;
}; };
@@ -183,7 +183,7 @@ _ol_style_IconImage_.prototype.getImageState = function() {
* @param {number} pixelRatio Pixel ratio. * @param {number} pixelRatio Pixel ratio.
* @return {Image|HTMLCanvasElement} Image element. * @return {Image|HTMLCanvasElement} Image element.
*/ */
_ol_style_IconImage_.prototype.getHitDetectionImage = function(pixelRatio) { IconImage.prototype.getHitDetectionImage = function(pixelRatio) {
if (!this.hitDetectionImage_) { if (!this.hitDetectionImage_) {
if (this.tainting_) { if (this.tainting_) {
var width = this.size_[0]; var width = this.size_[0];
@@ -202,7 +202,7 @@ _ol_style_IconImage_.prototype.getHitDetectionImage = function(pixelRatio) {
/** /**
* @return {ol.Size} Image size. * @return {ol.Size} Image size.
*/ */
_ol_style_IconImage_.prototype.getSize = function() { IconImage.prototype.getSize = function() {
return this.size_; return this.size_;
}; };
@@ -210,7 +210,7 @@ _ol_style_IconImage_.prototype.getSize = function() {
/** /**
* @return {string|undefined} Image src. * @return {string|undefined} Image src.
*/ */
_ol_style_IconImage_.prototype.getSrc = function() { IconImage.prototype.getSrc = function() {
return this.src_; return this.src_;
}; };
@@ -218,7 +218,7 @@ _ol_style_IconImage_.prototype.getSrc = function() {
/** /**
* Load not yet loaded URI. * Load not yet loaded URI.
*/ */
_ol_style_IconImage_.prototype.load = function() { IconImage.prototype.load = function() {
if (this.imageState_ == ImageState.IDLE) { if (this.imageState_ == ImageState.IDLE) {
this.imageState_ = ImageState.LOADING; this.imageState_ = ImageState.LOADING;
this.imageListenerKeys_ = [ this.imageListenerKeys_ = [
@@ -239,7 +239,7 @@ _ol_style_IconImage_.prototype.load = function() {
/** /**
* @private * @private
*/ */
_ol_style_IconImage_.prototype.replaceColor_ = function() { IconImage.prototype.replaceColor_ = function() {
if (this.tainting_ || this.color_ === null) { if (this.tainting_ || this.color_ === null) {
return; return;
} }
@@ -270,8 +270,8 @@ _ol_style_IconImage_.prototype.replaceColor_ = function() {
* *
* @private * @private
*/ */
_ol_style_IconImage_.prototype.unlistenImage_ = function() { IconImage.prototype.unlistenImage_ = function() {
this.imageListenerKeys_.forEach(_ol_events_.unlistenByKey); this.imageListenerKeys_.forEach(_ol_events_.unlistenByKey);
this.imageListenerKeys_ = null; this.imageListenerKeys_ = null;
}; };
export default _ol_style_IconImage_; export default IconImage;
+3 -3
View File
@@ -1,7 +1,7 @@
import {getUid} from '../../../../src/ol/index.js'; import {getUid} from '../../../../src/ol/index.js';
import {iconImageCache} from '../../../../src/ol/style.js'; import {iconImageCache} from '../../../../src/ol/style.js';
import Icon from '../../../../src/ol/style/Icon.js'; import Icon from '../../../../src/ol/style/Icon.js';
import _ol_style_IconImage_ from '../../../../src/ol/style/IconImage.js'; import IconImage from '../../../../src/ol/style/IconImage.js';
describe('ol.style.Icon', function() { describe('ol.style.Icon', function() {
@@ -17,7 +17,7 @@ describe('ol.style.Icon', function() {
img: canvas, img: canvas,
imgSize: size imgSize: size
}); });
expect(_ol_style_IconImage_.get( expect(IconImage.get(
canvas, getUid(canvas), size, '').getImage()).to.eql(canvas); canvas, getUid(canvas), size, '').getImage()).to.eql(canvas);
}); });
@@ -227,7 +227,7 @@ describe('ol.style.Icon', function() {
// pretend that the image is already in the cache, // pretend that the image is already in the cache,
// this image will be used for the icon. // this image will be used for the icon.
var src = 'test.png'; var src = 'test.png';
var iconImage = new _ol_style_IconImage_(null, 'test.png', imgSize); var iconImage = new IconImage(null, 'test.png', imgSize);
iconImageCache.set(src, null, null, iconImage); iconImageCache.set(src, null, null, iconImage);
var iconStyle = new Icon({ var iconStyle = new Icon({
+6 -6
View File
@@ -1,7 +1,7 @@
import {nullFunction} from '../../../../src/ol/index.js'; import {nullFunction} from '../../../../src/ol/index.js';
import _ol_events_ from '../../../../src/ol/events.js'; import _ol_events_ from '../../../../src/ol/events.js';
import {iconImageCache} from '../../../../src/ol/style.js'; import {iconImageCache} from '../../../../src/ol/style.js';
import _ol_style_IconImage_ from '../../../../src/ol/style/IconImage.js'; import IconImage from '../../../../src/ol/style/IconImage.js';
describe('ol.style.IconImageCache', function() { describe('ol.style.IconImageCache', function() {
var originalMaxCacheSize; var originalMaxCacheSize;
@@ -23,7 +23,7 @@ describe('ol.style.IconImageCache', function() {
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
src = i + ''; src = i + '';
iconImage = new _ol_style_IconImage_(null, src); iconImage = new IconImage(null, src);
iconImageCache.set(src, null, null, iconImage); iconImageCache.set(src, null, null, iconImage);
} }
@@ -33,7 +33,7 @@ describe('ol.style.IconImageCache', function() {
expect(iconImageCache.cacheSize_).to.eql(4); expect(iconImageCache.cacheSize_).to.eql(4);
src = '4'; src = '4';
iconImage = new _ol_style_IconImage_(null, src); iconImage = new IconImage(null, src);
iconImageCache.set(src, null, null, iconImage); iconImageCache.set(src, null, null, iconImage);
expect(iconImageCache.cacheSize_).to.eql(5); expect(iconImageCache.cacheSize_).to.eql(5);
@@ -41,13 +41,13 @@ describe('ol.style.IconImageCache', function() {
expect(iconImageCache.cacheSize_).to.eql(3); expect(iconImageCache.cacheSize_).to.eql(3);
src = '0'; src = '0';
iconImage = new _ol_style_IconImage_(null, src); iconImage = new IconImage(null, src);
_ol_events_.listen(iconImage, 'change', nullFunction, false); _ol_events_.listen(iconImage, 'change', nullFunction, false);
iconImageCache.set(src, null, null, iconImage); iconImageCache.set(src, null, null, iconImage);
expect(iconImageCache.cacheSize_).to.eql(4); expect(iconImageCache.cacheSize_).to.eql(4);
src = '4'; src = '4';
iconImage = new _ol_style_IconImage_(null, src); iconImage = new IconImage(null, src);
_ol_events_.listen(iconImage, 'change', nullFunction, false); _ol_events_.listen(iconImage, 'change', nullFunction, false);
iconImageCache.set(src, null, null, iconImage); iconImageCache.set(src, null, null, iconImage);
expect(iconImageCache.cacheSize_).to.eql(5); expect(iconImageCache.cacheSize_).to.eql(5);
@@ -65,7 +65,7 @@ describe('ol.style.IconImageCache', function() {
for (i = 0; i < 3; ++i) { for (i = 0; i < 3; ++i) {
src = i + ''; src = i + '';
iconImage = new _ol_style_IconImage_(null, src); iconImage = new IconImage(null, src);
iconImageCache.set(src, null, null, iconImage); iconImageCache.set(src, null, null, iconImage);
} }