Rename _ol_style_AtlasManager_ to AtlasManager
This commit is contained in:
@@ -4,14 +4,14 @@ import View from '../src/ol/View.js';
|
|||||||
import Point from '../src/ol/geom/Point.js';
|
import Point from '../src/ol/geom/Point.js';
|
||||||
import VectorLayer from '../src/ol/layer/Vector.js';
|
import VectorLayer from '../src/ol/layer/Vector.js';
|
||||||
import VectorSource from '../src/ol/source/Vector.js';
|
import VectorSource from '../src/ol/source/Vector.js';
|
||||||
import _ol_style_AtlasManager_ from '../src/ol/style/AtlasManager.js';
|
import AtlasManager from '../src/ol/style/AtlasManager.js';
|
||||||
import _ol_style_Circle_ from '../src/ol/style/Circle.js';
|
import _ol_style_Circle_ from '../src/ol/style/Circle.js';
|
||||||
import _ol_style_Fill_ from '../src/ol/style/Fill.js';
|
import _ol_style_Fill_ from '../src/ol/style/Fill.js';
|
||||||
import _ol_style_RegularShape_ from '../src/ol/style/RegularShape.js';
|
import _ol_style_RegularShape_ from '../src/ol/style/RegularShape.js';
|
||||||
import _ol_style_Stroke_ from '../src/ol/style/Stroke.js';
|
import _ol_style_Stroke_ from '../src/ol/style/Stroke.js';
|
||||||
import _ol_style_Style_ from '../src/ol/style/Style.js';
|
import _ol_style_Style_ from '../src/ol/style/Style.js';
|
||||||
|
|
||||||
var atlasManager = new _ol_style_AtlasManager_({
|
var atlasManager = new AtlasManager({
|
||||||
// we increase the initial size so that all symbols fit into
|
// we increase the initial size so that all symbols fit into
|
||||||
// a single atlas image
|
// a single atlas image
|
||||||
initialSize: 512
|
initialSize: 512
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import _ol_has_ from '../../has.js';
|
|||||||
import _ol_render_replay_ from '../replay.js';
|
import _ol_render_replay_ from '../replay.js';
|
||||||
import _ol_render_webgl_ from '../webgl.js';
|
import _ol_render_webgl_ from '../webgl.js';
|
||||||
import _ol_render_webgl_TextureReplay_ from '../webgl/TextureReplay.js';
|
import _ol_render_webgl_TextureReplay_ from '../webgl/TextureReplay.js';
|
||||||
import _ol_style_AtlasManager_ from '../../style/AtlasManager.js';
|
import AtlasManager from '../../style/AtlasManager.js';
|
||||||
import _ol_webgl_Buffer_ from '../../webgl/Buffer.js';
|
import _ol_webgl_Buffer_ from '../../webgl/Buffer.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -421,7 +421,7 @@ _ol_render_webgl_TextReplay_.prototype.getAtlas_ = function(state) {
|
|||||||
state.lineWidth / 2) * state.scale);
|
state.lineWidth / 2) * state.scale);
|
||||||
|
|
||||||
this.atlases_[hash] = {
|
this.atlases_[hash] = {
|
||||||
atlas: new _ol_style_AtlasManager_({
|
atlas: new AtlasManager({
|
||||||
space: state.lineWidth + 1
|
space: state.lineWidth + 1
|
||||||
}),
|
}),
|
||||||
width: {},
|
width: {},
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ var MAX_ATLAS_SIZE = -1;
|
|||||||
* @api
|
* @api
|
||||||
* @param {olx.style.AtlasManagerOptions=} opt_options Options.
|
* @param {olx.style.AtlasManagerOptions=} opt_options Options.
|
||||||
*/
|
*/
|
||||||
var _ol_style_AtlasManager_ = function(opt_options) {
|
var AtlasManager = function(opt_options) {
|
||||||
|
|
||||||
var options = opt_options || {};
|
var options = opt_options || {};
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ var _ol_style_AtlasManager_ = function(opt_options) {
|
|||||||
* @return {?ol.AtlasManagerInfo} The position and atlas image for the
|
* @return {?ol.AtlasManagerInfo} The position and atlas image for the
|
||||||
* entry, or `null` if the entry is not part of the atlas manager.
|
* entry, or `null` if the entry is not part of the atlas manager.
|
||||||
*/
|
*/
|
||||||
_ol_style_AtlasManager_.prototype.getInfo = function(id) {
|
AtlasManager.prototype.getInfo = function(id) {
|
||||||
/** @type {?ol.AtlasInfo} */
|
/** @type {?ol.AtlasInfo} */
|
||||||
var info = this.getInfo_(this.atlases_, id);
|
var info = this.getInfo_(this.atlases_, id);
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ _ol_style_AtlasManager_.prototype.getInfo = function(id) {
|
|||||||
* @return {?ol.AtlasInfo} The position and atlas image for the entry,
|
* @return {?ol.AtlasInfo} The position and atlas image for the entry,
|
||||||
* or `null` if the entry is not part of the atlases.
|
* or `null` if the entry is not part of the atlases.
|
||||||
*/
|
*/
|
||||||
_ol_style_AtlasManager_.prototype.getInfo_ = function(atlases, id) {
|
AtlasManager.prototype.getInfo_ = function(atlases, id) {
|
||||||
var atlas, info, i, ii;
|
var atlas, info, i, ii;
|
||||||
for (i = 0, ii = atlases.length; i < ii; ++i) {
|
for (i = 0, ii = atlases.length; i < ii; ++i) {
|
||||||
atlas = atlases[i];
|
atlas = atlases[i];
|
||||||
@@ -129,7 +129,7 @@ _ol_style_AtlasManager_.prototype.getInfo_ = function(atlases, id) {
|
|||||||
* @return {?ol.AtlasManagerInfo} The position and atlas image for the
|
* @return {?ol.AtlasManagerInfo} The position and atlas image for the
|
||||||
* entry, or `null` if the entry is not part of the atlases.
|
* entry, or `null` if the entry is not part of the atlases.
|
||||||
*/
|
*/
|
||||||
_ol_style_AtlasManager_.prototype.mergeInfos_ = function(info, hitInfo) {
|
AtlasManager.prototype.mergeInfos_ = function(info, hitInfo) {
|
||||||
return /** @type {ol.AtlasManagerInfo} */ ({
|
return /** @type {ol.AtlasManagerInfo} */ ({
|
||||||
offsetX: info.offsetX,
|
offsetX: info.offsetX,
|
||||||
offsetY: info.offsetY,
|
offsetY: info.offsetY,
|
||||||
@@ -161,7 +161,7 @@ _ol_style_AtlasManager_.prototype.mergeInfos_ = function(info, hitInfo) {
|
|||||||
* @return {?ol.AtlasManagerInfo} The position and atlas image for the
|
* @return {?ol.AtlasManagerInfo} The position and atlas image for the
|
||||||
* entry, or `null` if the image is too big.
|
* entry, or `null` if the image is too big.
|
||||||
*/
|
*/
|
||||||
_ol_style_AtlasManager_.prototype.add = function(id, width, height,
|
AtlasManager.prototype.add = function(id, width, height,
|
||||||
renderCallback, opt_renderHitCallback, opt_this) {
|
renderCallback, opt_renderHitCallback, opt_this) {
|
||||||
if (width + this.space_ > this.maxSize_ ||
|
if (width + this.space_ > this.maxSize_ ||
|
||||||
height + this.space_ > this.maxSize_) {
|
height + this.space_ > this.maxSize_) {
|
||||||
@@ -201,7 +201,7 @@ _ol_style_AtlasManager_.prototype.add = function(id, width, height,
|
|||||||
* @return {?ol.AtlasInfo} The position and atlas image for the entry,
|
* @return {?ol.AtlasInfo} The position and atlas image for the entry,
|
||||||
* or `null` if the image is too big.
|
* or `null` if the image is too big.
|
||||||
*/
|
*/
|
||||||
_ol_style_AtlasManager_.prototype.add_ = function(isHitAtlas, id, width, height,
|
AtlasManager.prototype.add_ = function(isHitAtlas, id, width, height,
|
||||||
renderCallback, opt_this) {
|
renderCallback, opt_this) {
|
||||||
var atlases = (isHitAtlas) ? this.hitAtlases_ : this.atlases_;
|
var atlases = (isHitAtlas) ? this.hitAtlases_ : this.atlases_;
|
||||||
var atlas, info, i, ii;
|
var atlas, info, i, ii;
|
||||||
@@ -229,4 +229,4 @@ _ol_style_AtlasManager_.prototype.add_ = function(isHitAtlas, id, width, height,
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
export default _ol_style_AtlasManager_;
|
export default AtlasManager;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 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';
|
import AtlasManager from '../../../../src/ol/style/AtlasManager.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.style.Atlas', function() {
|
describe('ol.style.Atlas', function() {
|
||||||
@@ -179,7 +179,7 @@ describe('ol.style.AtlasManager', function() {
|
|||||||
describe('#constructor', function() {
|
describe('#constructor', function() {
|
||||||
|
|
||||||
it('inits the atlas manager', function() {
|
it('inits the atlas manager', function() {
|
||||||
var manager = new _ol_style_AtlasManager_();
|
var manager = new AtlasManager();
|
||||||
expect(manager.atlases_).to.not.be.empty();
|
expect(manager.atlases_).to.not.be.empty();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -187,7 +187,7 @@ describe('ol.style.AtlasManager', function() {
|
|||||||
describe('#add', function() {
|
describe('#add', function() {
|
||||||
|
|
||||||
it('adds one entry', function() {
|
it('adds one entry', function() {
|
||||||
var manager = new _ol_style_AtlasManager_({initialSize: 128});
|
var manager = new AtlasManager({initialSize: 128});
|
||||||
var info = manager.add('1', 32, 32, defaultRender);
|
var info = manager.add('1', 32, 32, defaultRender);
|
||||||
|
|
||||||
expect(info).to.eql({
|
expect(info).to.eql({
|
||||||
@@ -198,7 +198,7 @@ describe('ol.style.AtlasManager', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('adds one entry (also to the hit detection atlas)', function() {
|
it('adds one entry (also to the hit detection atlas)', function() {
|
||||||
var manager = new _ol_style_AtlasManager_({initialSize: 128});
|
var manager = new AtlasManager({initialSize: 128});
|
||||||
var info = manager.add('1', 32, 32, defaultRender, defaultRender);
|
var info = manager.add('1', 32, 32, defaultRender, defaultRender);
|
||||||
|
|
||||||
expect(info).to.eql({
|
expect(info).to.eql({
|
||||||
@@ -209,7 +209,7 @@ describe('ol.style.AtlasManager', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('creates a new atlas if needed', function() {
|
it('creates a new atlas if needed', function() {
|
||||||
var manager = new _ol_style_AtlasManager_({initialSize: 128});
|
var manager = new AtlasManager({initialSize: 128});
|
||||||
expect(manager.add('1', 100, 100, defaultRender, defaultRender))
|
expect(manager.add('1', 100, 100, defaultRender, defaultRender))
|
||||||
.to.be.ok();
|
.to.be.ok();
|
||||||
var info = manager.add('2', 100, 100, defaultRender, defaultRender);
|
var info = manager.add('2', 100, 100, defaultRender, defaultRender);
|
||||||
@@ -221,7 +221,7 @@ describe('ol.style.AtlasManager', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('creates new atlases until one is large enough', function() {
|
it('creates new atlases until one is large enough', function() {
|
||||||
var manager = new _ol_style_AtlasManager_({initialSize: 128});
|
var manager = new AtlasManager({initialSize: 128});
|
||||||
expect(manager.add('1', 100, 100, defaultRender, defaultRender))
|
expect(manager.add('1', 100, 100, defaultRender, defaultRender))
|
||||||
.to.be.ok();
|
.to.be.ok();
|
||||||
expect(manager.atlases_).to.have.length(1);
|
expect(manager.atlases_).to.have.length(1);
|
||||||
@@ -235,7 +235,7 @@ describe('ol.style.AtlasManager', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('checks all existing atlases and create a new if needed', function() {
|
it('checks all existing atlases and create a new if needed', function() {
|
||||||
var manager = new _ol_style_AtlasManager_({initialSize: 128});
|
var manager = new AtlasManager({initialSize: 128});
|
||||||
expect(manager.add('1', 100, 100, defaultRender, defaultRender))
|
expect(manager.add('1', 100, 100, defaultRender, defaultRender))
|
||||||
.to.be.ok();
|
.to.be.ok();
|
||||||
expect(manager.add('2', 100, 100, defaultRender, defaultRender))
|
expect(manager.add('2', 100, 100, defaultRender, defaultRender))
|
||||||
@@ -251,7 +251,7 @@ describe('ol.style.AtlasManager', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns null if the size exceeds the maximum size', function() {
|
it('returns null if the size exceeds the maximum size', function() {
|
||||||
var manager = new _ol_style_AtlasManager_(
|
var manager = new AtlasManager(
|
||||||
{initialSize: 128, maxSize: 2048});
|
{initialSize: 128, maxSize: 2048});
|
||||||
expect(manager.add('1', 100, 100, defaultRender, defaultRender))
|
expect(manager.add('1', 100, 100, defaultRender, defaultRender))
|
||||||
.to.be.ok();
|
.to.be.ok();
|
||||||
@@ -260,7 +260,7 @@ describe('ol.style.AtlasManager', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('always has the same offset for the hit-detection', function() {
|
it('always has the same offset for the hit-detection', function() {
|
||||||
var manager = new _ol_style_AtlasManager_({initialSize: 128});
|
var manager = new AtlasManager({initialSize: 128});
|
||||||
// add one image without hit-detection callback
|
// add one image without hit-detection callback
|
||||||
var info = manager.add('1', 32, 32, defaultRender);
|
var info = manager.add('1', 32, 32, defaultRender);
|
||||||
// add then one with hit-detection callback
|
// add then one with hit-detection callback
|
||||||
@@ -277,7 +277,7 @@ describe('ol.style.AtlasManager', function() {
|
|||||||
describe('#getInfo', function() {
|
describe('#getInfo', function() {
|
||||||
|
|
||||||
it('returns null if no entry for the given id', function() {
|
it('returns null if no entry for the given id', function() {
|
||||||
var manager = new _ol_style_AtlasManager_({initialSize: 128});
|
var manager = new AtlasManager({initialSize: 128});
|
||||||
expect(manager.getInfo('123456')).to.eql(null);
|
expect(manager.getInfo('123456')).to.eql(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import _ol_style_AtlasManager_ from '../../../../src/ol/style/AtlasManager.js';
|
import AtlasManager from '../../../../src/ol/style/AtlasManager.js';
|
||||||
import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js';
|
import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js';
|
||||||
import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js';
|
import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js';
|
||||||
import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js';
|
import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js';
|
||||||
@@ -40,7 +40,7 @@ describe('ol.style.Circle', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('adds itself to an atlas manager (no fill-style)', function() {
|
it('adds itself to an atlas manager (no fill-style)', function() {
|
||||||
var atlasManager = new _ol_style_AtlasManager_({initialSize: 512});
|
var atlasManager = new AtlasManager({initialSize: 512});
|
||||||
var style = new _ol_style_Circle_({radius: 10, atlasManager: atlasManager});
|
var style = new _ol_style_Circle_({radius: 10, atlasManager: atlasManager});
|
||||||
expect(style.getImage()).to.be.an(HTMLCanvasElement);
|
expect(style.getImage()).to.be.an(HTMLCanvasElement);
|
||||||
expect(style.getSize()).to.eql([21, 21]);
|
expect(style.getSize()).to.eql([21, 21]);
|
||||||
@@ -54,7 +54,7 @@ describe('ol.style.Circle', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('adds itself to an atlas manager (fill-style)', function() {
|
it('adds itself to an atlas manager (fill-style)', function() {
|
||||||
var atlasManager = new _ol_style_AtlasManager_({initialSize: 512});
|
var atlasManager = new AtlasManager({initialSize: 512});
|
||||||
var style = new _ol_style_Circle_({
|
var style = new _ol_style_Circle_({
|
||||||
radius: 10,
|
radius: 10,
|
||||||
atlasManager: atlasManager,
|
atlasManager: atlasManager,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import _ol_style_AtlasManager_ from '../../../../src/ol/style/AtlasManager.js';
|
import AtlasManager from '../../../../src/ol/style/AtlasManager.js';
|
||||||
import _ol_style_RegularShape_ from '../../../../src/ol/style/RegularShape.js';
|
import _ol_style_RegularShape_ from '../../../../src/ol/style/RegularShape.js';
|
||||||
import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js';
|
import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js';
|
||||||
import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js';
|
import _ol_style_Stroke_ from '../../../../src/ol/style/Stroke.js';
|
||||||
@@ -66,7 +66,7 @@ describe('ol.style.RegularShape', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('adds itself to an atlas manager (no fill-style)', function() {
|
it('adds itself to an atlas manager (no fill-style)', function() {
|
||||||
var atlasManager = new _ol_style_AtlasManager_({initialSize: 512});
|
var atlasManager = new AtlasManager({initialSize: 512});
|
||||||
var style = new _ol_style_RegularShape_(
|
var style = new _ol_style_RegularShape_(
|
||||||
{radius: 10, atlasManager: atlasManager});
|
{radius: 10, atlasManager: atlasManager});
|
||||||
expect(style.getImage()).to.be.an(HTMLCanvasElement);
|
expect(style.getImage()).to.be.an(HTMLCanvasElement);
|
||||||
@@ -81,7 +81,7 @@ describe('ol.style.RegularShape', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('adds itself to an atlas manager (fill-style)', function() {
|
it('adds itself to an atlas manager (fill-style)', function() {
|
||||||
var atlasManager = new _ol_style_AtlasManager_({initialSize: 512});
|
var atlasManager = new AtlasManager({initialSize: 512});
|
||||||
var style = new _ol_style_RegularShape_({
|
var style = new _ol_style_RegularShape_({
|
||||||
radius: 10,
|
radius: 10,
|
||||||
atlasManager: atlasManager,
|
atlasManager: atlasManager,
|
||||||
|
|||||||
Reference in New Issue
Block a user