From 12d4db5045acb3a7d1f7d67caeb73a8ba5752f50 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 11 Jan 2018 10:56:24 -0700 Subject: [PATCH] Rename _ol_style_Atlas_ to Atlas --- src/ol/style/Atlas.js | 12 ++++++------ src/ol/style/AtlasManager.js | 8 ++++---- test/spec/ol/style/atlasmanager.test.js | 26 ++++++++++++------------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/ol/style/Atlas.js b/src/ol/style/Atlas.js index b5932d59c1..7b0f802500 100644 --- a/src/ol/style/Atlas.js +++ b/src/ol/style/Atlas.js @@ -20,7 +20,7 @@ import {createCanvasContext2D} from '../dom.js'; * edges overlap when being rendered). To avoid this we add a * padding around each image. */ -var _ol_style_Atlas_ = function(size, space) { +var Atlas = function(size, space) { /** * @private @@ -58,7 +58,7 @@ var _ol_style_Atlas_ = function(size, space) { * @param {string} id The identifier of the entry to check. * @return {?ol.AtlasInfo} The atlas info. */ -_ol_style_Atlas_.prototype.get = function(id) { +Atlas.prototype.get = function(id) { return this.entries_[id] || null; }; @@ -73,7 +73,7 @@ _ol_style_Atlas_.prototype.get = function(id) { * `renderCallback`. * @return {?ol.AtlasInfo} The position and atlas image for the entry. */ -_ol_style_Atlas_.prototype.add = function(id, width, height, renderCallback, opt_this) { +Atlas.prototype.add = function(id, width, height, renderCallback, opt_this) { var block, i, ii; for (i = 0, ii = this.emptyBlocks_.length; i < ii; ++i) { block = this.emptyBlocks_[i]; @@ -110,7 +110,7 @@ _ol_style_Atlas_.prototype.add = function(id, width, height, renderCallback, opt * @param {number} width The width of the entry to insert. * @param {number} height The height of the entry to insert. */ -_ol_style_Atlas_.prototype.split_ = function(index, block, width, height) { +Atlas.prototype.split_ = function(index, block, width, height) { var deltaWidth = block.width - width; var deltaHeight = block.height - height; @@ -168,7 +168,7 @@ _ol_style_Atlas_.prototype.split_ = function(index, block, width, height) { * @param {ol.AtlasBlock} newBlock1 The 1st block to add. * @param {ol.AtlasBlock} newBlock2 The 2nd block to add. */ -_ol_style_Atlas_.prototype.updateBlocks_ = function(index, newBlock1, newBlock2) { +Atlas.prototype.updateBlocks_ = function(index, newBlock1, newBlock2) { var args = [index, 1]; if (newBlock1.width > 0 && newBlock1.height > 0) { args.push(newBlock1); @@ -178,4 +178,4 @@ _ol_style_Atlas_.prototype.updateBlocks_ = function(index, newBlock1, newBlock2) } this.emptyBlocks_.splice.apply(this.emptyBlocks_, args); }; -export default _ol_style_Atlas_; +export default Atlas; diff --git a/src/ol/style/AtlasManager.js b/src/ol/style/AtlasManager.js index 9d67ff1a2d..3862e1d019 100644 --- a/src/ol/style/AtlasManager.js +++ b/src/ol/style/AtlasManager.js @@ -2,7 +2,7 @@ * @module ol/style/AtlasManager */ import {WEBGL_MAX_TEXTURE_SIZE, nullFunction} from '../index.js'; -import _ol_style_Atlas_ from '../style/Atlas.js'; +import Atlas from '../style/Atlas.js'; /** @@ -66,7 +66,7 @@ var _ol_style_AtlasManager_ = function(opt_options) { * @private * @type {Array.} */ - this.atlases_ = [new _ol_style_Atlas_(this.currentSize_, this.space_)]; + this.atlases_ = [new Atlas(this.currentSize_, this.space_)]; /** * The size in pixels of the latest atlas image for hit-detection images. @@ -79,7 +79,7 @@ var _ol_style_AtlasManager_ = function(opt_options) { * @private * @type {Array.} */ - this.hitAtlases_ = [new _ol_style_Atlas_(this.currentHitSize_, this.space_)]; + this.hitAtlases_ = [new Atlas(this.currentHitSize_, this.space_)]; }; @@ -221,7 +221,7 @@ _ol_style_AtlasManager_.prototype.add_ = function(isHitAtlas, id, width, height, size = Math.min(this.currentSize_ * 2, this.maxSize_); this.currentSize_ = size; } - atlas = new _ol_style_Atlas_(size, this.space_); + atlas = new Atlas(size, this.space_); atlases.push(atlas); // run the loop another time ++ii; diff --git a/test/spec/ol/style/atlasmanager.test.js b/test/spec/ol/style/atlasmanager.test.js index be06e9151f..83778a81bd 100644 --- a/test/spec/ol/style/atlasmanager.test.js +++ b/test/spec/ol/style/atlasmanager.test.js @@ -1,4 +1,4 @@ -import _ol_style_Atlas_ from '../../../../src/ol/style/Atlas.js'; +import Atlas from '../../../../src/ol/style/Atlas.js'; import _ol_style_AtlasManager_ from '../../../../src/ol/style/AtlasManager.js'; @@ -10,7 +10,7 @@ describe('ol.style.Atlas', function() { describe('#constructor', function() { it('inits the atlas', function() { - var atlas = new _ol_style_Atlas_(256, 1); + var atlas = new Atlas(256, 1); expect(atlas.emptyBlocks_).to.eql( [{x: 0, y: 0, width: 256, height: 256}]); }); @@ -19,7 +19,7 @@ describe('ol.style.Atlas', function() { describe('#add (squares with same size)', function() { it('adds one entry', function() { - var atlas = new _ol_style_Atlas_(128, 1); + var atlas = new Atlas(128, 1); var info = atlas.add('1', 32, 32, defaultRender); expect(info).to.eql( @@ -29,7 +29,7 @@ describe('ol.style.Atlas', function() { }); it('adds two entries', function() { - var atlas = new _ol_style_Atlas_(128, 1); + var atlas = new Atlas(128, 1); atlas.add('1', 32, 32, defaultRender); var info = atlas.add('2', 32, 32, defaultRender); @@ -41,7 +41,7 @@ describe('ol.style.Atlas', function() { }); it('adds three entries', function() { - var atlas = new _ol_style_Atlas_(128, 1); + var atlas = new Atlas(128, 1); atlas.add('1', 32, 32, defaultRender); atlas.add('2', 32, 32, defaultRender); @@ -54,7 +54,7 @@ describe('ol.style.Atlas', function() { }); it('adds four entries (new row)', function() { - var atlas = new _ol_style_Atlas_(128, 1); + var atlas = new Atlas(128, 1); atlas.add('1', 32, 32, defaultRender); atlas.add('2', 32, 32, defaultRender); @@ -68,7 +68,7 @@ describe('ol.style.Atlas', function() { }); it('returns null when an entry is too big', function() { - var atlas = new _ol_style_Atlas_(128, 1); + var atlas = new Atlas(128, 1); atlas.add('1', 32, 32, defaultRender); atlas.add('2', 32, 32, defaultRender); @@ -79,7 +79,7 @@ describe('ol.style.Atlas', function() { }); it('fills up the whole atlas', function() { - var atlas = new _ol_style_Atlas_(128, 1); + var atlas = new Atlas(128, 1); for (var i = 1; i <= 16; i++) { expect(atlas.add(i.toString(), 28, 28, defaultRender)).to.be.ok(); @@ -93,7 +93,7 @@ describe('ol.style.Atlas', function() { describe('#add (rectangles with different sizes)', function() { it('adds a bunch of rectangles', function() { - var atlas = new _ol_style_Atlas_(128, 1); + var atlas = new Atlas(128, 1); expect(atlas.add('1', 64, 32, defaultRender)).to.eql( {offsetX: 1, offsetY: 1, image: atlas.canvas_}); @@ -116,7 +116,7 @@ describe('ol.style.Atlas', function() { }); it('fills up the whole atlas (rectangles in portrait format)', function() { - var atlas = new _ol_style_Atlas_(128, 1); + var atlas = new Atlas(128, 1); for (var i = 1; i <= 32; i++) { expect(atlas.add(i.toString(), 28, 14, defaultRender)).to.be.ok(); @@ -127,7 +127,7 @@ describe('ol.style.Atlas', function() { }); it('fills up the whole atlas (rectangles in landscape format)', function() { - var atlas = new _ol_style_Atlas_(128, 1); + var atlas = new Atlas(128, 1); for (var i = 1; i <= 32; i++) { expect(atlas.add(i.toString(), 14, 28, defaultRender)).to.be.ok(); @@ -141,7 +141,7 @@ describe('ol.style.Atlas', function() { describe('#add (rendering)', function() { it('calls the render callback with the right values', function() { - var atlas = new _ol_style_Atlas_(128, 1); + var atlas = new Atlas(128, 1); var rendererCallback = sinon.spy(); atlas.add('1', 32, 32, rendererCallback); @@ -156,7 +156,7 @@ describe('ol.style.Atlas', function() { }); it('is possible to actually draw on the canvas', function() { - var atlas = new _ol_style_Atlas_(128, 1); + var atlas = new Atlas(128, 1); var rendererCallback = function(context, x, y) { context.fillStyle = '#FFA500';