From 16c8d2c246001fa748f91e1e8132131c3e3aaaa0 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 11 Jan 2018 13:26:51 -0700 Subject: [PATCH] Rename _ol_style_RegularShape_ to RegularShape --- examples/earthquake-clusters.js | 4 +- examples/layer-z-index.js | 8 +-- examples/regularshape.js | 12 ++--- examples/symbol-atlas-webgl.js | 4 +- src/ol/style/Circle.js | 6 +-- src/ol/style/RegularShape.js | 54 +++++++++---------- test/rendering/ol/style/regularshape.test.js | 10 ++-- test/spec/ol/style/regularshape.test.js | 56 ++++++++++---------- 8 files changed, 77 insertions(+), 77 deletions(-) diff --git a/examples/earthquake-clusters.js b/examples/earthquake-clusters.js index 03992f1620..2afa0de9ee 100644 --- a/examples/earthquake-clusters.js +++ b/examples/earthquake-clusters.js @@ -11,7 +11,7 @@ import Stamen from '../src/ol/source/Stamen.js'; import VectorSource from '../src/ol/source/Vector.js'; import _ol_style_Circle_ from '../src/ol/style/Circle.js'; import Fill from '../src/ol/style/Fill.js'; -import _ol_style_RegularShape_ from '../src/ol/style/RegularShape.js'; +import RegularShape from '../src/ol/style/RegularShape.js'; import Stroke from '../src/ol/style/Stroke.js'; import Style from '../src/ol/style/Style.js'; import Text from '../src/ol/style/Text.js'; @@ -45,7 +45,7 @@ function createEarthquakeStyle(feature) { return new Style({ geometry: feature.getGeometry(), - image: new _ol_style_RegularShape_({ + image: new RegularShape({ radius1: radius, radius2: 3, points: 5, diff --git a/examples/layer-z-index.js b/examples/layer-z-index.js index e3921bebe7..b20297559c 100644 --- a/examples/layer-z-index.js +++ b/examples/layer-z-index.js @@ -5,7 +5,7 @@ import Point from '../src/ol/geom/Point.js'; import VectorLayer from '../src/ol/layer/Vector.js'; import VectorSource from '../src/ol/source/Vector.js'; import Fill from '../src/ol/style/Fill.js'; -import _ol_style_RegularShape_ from '../src/ol/style/RegularShape.js'; +import RegularShape from '../src/ol/style/RegularShape.js'; import Stroke from '../src/ol/style/Stroke.js'; import Style from '../src/ol/style/Style.js'; @@ -14,7 +14,7 @@ var stroke = new Stroke({color: 'black', width: 1}); var styles = { 'square': new Style({ - image: new _ol_style_RegularShape_({ + image: new RegularShape({ fill: new Fill({color: 'blue'}), stroke: stroke, points: 4, @@ -23,7 +23,7 @@ var styles = { }) }), 'triangle': new Style({ - image: new _ol_style_RegularShape_({ + image: new RegularShape({ fill: new Fill({color: 'red'}), stroke: stroke, points: 3, @@ -33,7 +33,7 @@ var styles = { }) }), 'star': new Style({ - image: new _ol_style_RegularShape_({ + image: new RegularShape({ fill: new Fill({color: 'green'}), stroke: stroke, points: 5, diff --git a/examples/regularshape.js b/examples/regularshape.js index 74236462de..34f851515e 100644 --- a/examples/regularshape.js +++ b/examples/regularshape.js @@ -5,7 +5,7 @@ import Point from '../src/ol/geom/Point.js'; import VectorLayer from '../src/ol/layer/Vector.js'; import VectorSource from '../src/ol/source/Vector.js'; import Fill from '../src/ol/style/Fill.js'; -import _ol_style_RegularShape_ from '../src/ol/style/RegularShape.js'; +import RegularShape from '../src/ol/style/RegularShape.js'; import Stroke from '../src/ol/style/Stroke.js'; import Style from '../src/ol/style/Style.js'; @@ -15,7 +15,7 @@ var fill = new Fill({color: 'red'}); var styles = { 'square': new Style({ - image: new _ol_style_RegularShape_({ + image: new RegularShape({ fill: fill, stroke: stroke, points: 4, @@ -24,7 +24,7 @@ var styles = { }) }), 'triangle': new Style({ - image: new _ol_style_RegularShape_({ + image: new RegularShape({ fill: fill, stroke: stroke, points: 3, @@ -34,7 +34,7 @@ var styles = { }) }), 'star': new Style({ - image: new _ol_style_RegularShape_({ + image: new RegularShape({ fill: fill, stroke: stroke, points: 5, @@ -44,7 +44,7 @@ var styles = { }) }), 'cross': new Style({ - image: new _ol_style_RegularShape_({ + image: new RegularShape({ fill: fill, stroke: stroke, points: 4, @@ -54,7 +54,7 @@ var styles = { }) }), 'x': new Style({ - image: new _ol_style_RegularShape_({ + image: new RegularShape({ fill: fill, stroke: stroke, points: 4, diff --git a/examples/symbol-atlas-webgl.js b/examples/symbol-atlas-webgl.js index e470aec390..1e1153098d 100644 --- a/examples/symbol-atlas-webgl.js +++ b/examples/symbol-atlas-webgl.js @@ -7,7 +7,7 @@ import VectorSource from '../src/ol/source/Vector.js'; import AtlasManager from '../src/ol/style/AtlasManager.js'; import _ol_style_Circle_ from '../src/ol/style/Circle.js'; import Fill from '../src/ol/style/Fill.js'; -import _ol_style_RegularShape_ from '../src/ol/style/RegularShape.js'; +import RegularShape from '../src/ol/style/RegularShape.js'; import Stroke from '../src/ol/style/Stroke.js'; import Style from '../src/ol/style/Style.js'; @@ -64,7 +64,7 @@ for (i = 0; i < symbolInfo.length; ++i) { })); // star symbol - symbols.push(new _ol_style_RegularShape_({ + symbols.push(new RegularShape({ points: 8, opacity: info.opacity, scale: info.scale, diff --git a/src/ol/style/Circle.js b/src/ol/style/Circle.js index 3cb75c995a..a2d9215edb 100644 --- a/src/ol/style/Circle.js +++ b/src/ol/style/Circle.js @@ -2,7 +2,7 @@ * @module ol/style/Circle */ import {inherits} from '../index.js'; -import _ol_style_RegularShape_ from '../style/RegularShape.js'; +import RegularShape from '../style/RegularShape.js'; /** * @classdesc @@ -17,7 +17,7 @@ var _ol_style_Circle_ = function(opt_options) { var options = opt_options || {}; - _ol_style_RegularShape_.call(this, { + RegularShape.call(this, { points: Infinity, fill: options.fill, radius: options.radius, @@ -28,7 +28,7 @@ var _ol_style_Circle_ = function(opt_options) { }; -inherits(_ol_style_Circle_, _ol_style_RegularShape_); +inherits(_ol_style_Circle_, RegularShape); /** diff --git a/src/ol/style/RegularShape.js b/src/ol/style/RegularShape.js index c08d7066bb..84babb07e0 100644 --- a/src/ol/style/RegularShape.js +++ b/src/ol/style/RegularShape.js @@ -20,7 +20,7 @@ import _ol_style_Image_ from '../style/Image.js'; * @extends {ol.style.Image} * @api */ -var _ol_style_RegularShape_ = function(options) { +var RegularShape = function(options) { /** * @private * @type {Array.} @@ -135,7 +135,7 @@ var _ol_style_RegularShape_ = function(options) { }); }; -inherits(_ol_style_RegularShape_, _ol_style_Image_); +inherits(RegularShape, _ol_style_Image_); /** @@ -143,8 +143,8 @@ inherits(_ol_style_RegularShape_, _ol_style_Image_); * @return {ol.style.RegularShape} The cloned style. * @api */ -_ol_style_RegularShape_.prototype.clone = function() { - var style = new _ol_style_RegularShape_({ +RegularShape.prototype.clone = function() { + var style = new RegularShape({ fill: this.getFill() ? this.getFill().clone() : undefined, points: this.getPoints(), radius: this.getRadius(), @@ -166,7 +166,7 @@ _ol_style_RegularShape_.prototype.clone = function() { * @inheritDoc * @api */ -_ol_style_RegularShape_.prototype.getAnchor = function() { +RegularShape.prototype.getAnchor = function() { return this.anchor_; }; @@ -176,7 +176,7 @@ _ol_style_RegularShape_.prototype.getAnchor = function() { * @return {number} Shape's rotation in radians. * @api */ -_ol_style_RegularShape_.prototype.getAngle = function() { +RegularShape.prototype.getAngle = function() { return this.angle_; }; @@ -186,7 +186,7 @@ _ol_style_RegularShape_.prototype.getAngle = function() { * @return {ol.style.Fill} Fill style. * @api */ -_ol_style_RegularShape_.prototype.getFill = function() { +RegularShape.prototype.getFill = function() { return this.fill_; }; @@ -194,7 +194,7 @@ _ol_style_RegularShape_.prototype.getFill = function() { /** * @inheritDoc */ -_ol_style_RegularShape_.prototype.getHitDetectionImage = function(pixelRatio) { +RegularShape.prototype.getHitDetectionImage = function(pixelRatio) { return this.hitDetectionCanvas_; }; @@ -203,7 +203,7 @@ _ol_style_RegularShape_.prototype.getHitDetectionImage = function(pixelRatio) { * @inheritDoc * @api */ -_ol_style_RegularShape_.prototype.getImage = function(pixelRatio) { +RegularShape.prototype.getImage = function(pixelRatio) { return this.canvas_; }; @@ -211,7 +211,7 @@ _ol_style_RegularShape_.prototype.getImage = function(pixelRatio) { /** * @inheritDoc */ -_ol_style_RegularShape_.prototype.getImageSize = function() { +RegularShape.prototype.getImageSize = function() { return this.imageSize_; }; @@ -219,7 +219,7 @@ _ol_style_RegularShape_.prototype.getImageSize = function() { /** * @inheritDoc */ -_ol_style_RegularShape_.prototype.getHitDetectionImageSize = function() { +RegularShape.prototype.getHitDetectionImageSize = function() { return this.hitDetectionImageSize_; }; @@ -227,7 +227,7 @@ _ol_style_RegularShape_.prototype.getHitDetectionImageSize = function() { /** * @inheritDoc */ -_ol_style_RegularShape_.prototype.getImageState = function() { +RegularShape.prototype.getImageState = function() { return ImageState.LOADED; }; @@ -236,7 +236,7 @@ _ol_style_RegularShape_.prototype.getImageState = function() { * @inheritDoc * @api */ -_ol_style_RegularShape_.prototype.getOrigin = function() { +RegularShape.prototype.getOrigin = function() { return this.origin_; }; @@ -246,7 +246,7 @@ _ol_style_RegularShape_.prototype.getOrigin = function() { * @return {number} Number of points for stars and regular polygons. * @api */ -_ol_style_RegularShape_.prototype.getPoints = function() { +RegularShape.prototype.getPoints = function() { return this.points_; }; @@ -256,7 +256,7 @@ _ol_style_RegularShape_.prototype.getPoints = function() { * @return {number} Radius. * @api */ -_ol_style_RegularShape_.prototype.getRadius = function() { +RegularShape.prototype.getRadius = function() { return this.radius_; }; @@ -266,7 +266,7 @@ _ol_style_RegularShape_.prototype.getRadius = function() { * @return {number|undefined} Radius2. * @api */ -_ol_style_RegularShape_.prototype.getRadius2 = function() { +RegularShape.prototype.getRadius2 = function() { return this.radius2_; }; @@ -275,7 +275,7 @@ _ol_style_RegularShape_.prototype.getRadius2 = function() { * @inheritDoc * @api */ -_ol_style_RegularShape_.prototype.getSize = function() { +RegularShape.prototype.getSize = function() { return this.size_; }; @@ -285,7 +285,7 @@ _ol_style_RegularShape_.prototype.getSize = function() { * @return {ol.style.Stroke} Stroke style. * @api */ -_ol_style_RegularShape_.prototype.getStroke = function() { +RegularShape.prototype.getStroke = function() { return this.stroke_; }; @@ -293,26 +293,26 @@ _ol_style_RegularShape_.prototype.getStroke = function() { /** * @inheritDoc */ -_ol_style_RegularShape_.prototype.listenImageChange = function(listener, thisArg) {}; +RegularShape.prototype.listenImageChange = function(listener, thisArg) {}; /** * @inheritDoc */ -_ol_style_RegularShape_.prototype.load = function() {}; +RegularShape.prototype.load = function() {}; /** * @inheritDoc */ -_ol_style_RegularShape_.prototype.unlistenImageChange = function(listener, thisArg) {}; +RegularShape.prototype.unlistenImageChange = function(listener, thisArg) {}; /** * @protected * @param {ol.style.AtlasManager|undefined} atlasManager An atlas manager. */ -_ol_style_RegularShape_.prototype.render_ = function(atlasManager) { +RegularShape.prototype.render_ = function(atlasManager) { var imageSize; var lineCap = ''; var lineJoin = ''; @@ -422,7 +422,7 @@ _ol_style_RegularShape_.prototype.render_ = function(atlasManager) { * @param {number} x The origin for the symbol (x). * @param {number} y The origin for the symbol (y). */ -_ol_style_RegularShape_.prototype.draw_ = function(renderOptions, context, x, y) { +RegularShape.prototype.draw_ = function(renderOptions, context, x, y) { var i, angle0, radiusC; // reset transform context.setTransform(1, 0, 0, 1, 0, 0); @@ -480,7 +480,7 @@ _ol_style_RegularShape_.prototype.draw_ = function(renderOptions, context, x, y) * @private * @param {ol.RegularShapeRenderOptions} renderOptions Render options. */ -_ol_style_RegularShape_.prototype.createHitDetectionCanvas_ = function(renderOptions) { +RegularShape.prototype.createHitDetectionCanvas_ = function(renderOptions) { this.hitDetectionImageSize_ = [renderOptions.size, renderOptions.size]; if (this.fill_) { this.hitDetectionCanvas_ = this.canvas_; @@ -503,7 +503,7 @@ _ol_style_RegularShape_.prototype.createHitDetectionCanvas_ = function(renderOpt * @param {number} x The origin for the symbol (x). * @param {number} y The origin for the symbol (y). */ -_ol_style_RegularShape_.prototype.drawHitDetectionCanvas_ = function(renderOptions, context, x, y) { +RegularShape.prototype.drawHitDetectionCanvas_ = function(renderOptions, context, x, y) { // reset transform context.setTransform(1, 0, 0, 1, 0, 0); @@ -550,7 +550,7 @@ _ol_style_RegularShape_.prototype.drawHitDetectionCanvas_ = function(renderOptio /** * @return {string} The checksum. */ -_ol_style_RegularShape_.prototype.getChecksum = function() { +RegularShape.prototype.getChecksum = function() { var strokeChecksum = this.stroke_ ? this.stroke_.getChecksum() : '-'; var fillChecksum = this.fill_ ? @@ -576,4 +576,4 @@ _ol_style_RegularShape_.prototype.getChecksum = function() { return this.checksums_[0]; }; -export default _ol_style_RegularShape_; +export default RegularShape; diff --git a/test/rendering/ol/style/regularshape.test.js b/test/rendering/ol/style/regularshape.test.js index 508387b077..fca045054e 100644 --- a/test/rendering/ol/style/regularshape.test.js +++ b/test/rendering/ol/style/regularshape.test.js @@ -5,7 +5,7 @@ import View from '../../../../src/ol/View.js'; import VectorLayer from '../../../../src/ol/layer/Vector.js'; import VectorSource from '../../../../src/ol/source/Vector.js'; import Fill from '../../../../src/ol/style/Fill.js'; -import _ol_style_RegularShape_ from '../../../../src/ol/style/RegularShape.js'; +import RegularShape from '../../../../src/ol/style/RegularShape.js'; import Style from '../../../../src/ol/style/Style.js'; import Stroke from '../../../../src/ol/style/Stroke.js'; @@ -47,7 +47,7 @@ describe('ol.rendering.style.RegularShape', function() { }); // square feature.setStyle(new Style({ - image: new _ol_style_RegularShape_({ + image: new RegularShape({ fill: fill, stroke: stroke, points: 4, @@ -62,7 +62,7 @@ describe('ol.rendering.style.RegularShape', function() { }); // triangle feature.setStyle(new Style({ - image: new _ol_style_RegularShape_({ + image: new RegularShape({ fill: fill, stroke: stroke, points: 3, @@ -78,7 +78,7 @@ describe('ol.rendering.style.RegularShape', function() { }); // star feature.setStyle(new Style({ - image: new _ol_style_RegularShape_({ + image: new RegularShape({ fill: fill, stroke: stroke, points: 5, @@ -94,7 +94,7 @@ describe('ol.rendering.style.RegularShape', function() { }); // cross feature.setStyle(new Style({ - image: new _ol_style_RegularShape_({ + image: new RegularShape({ fill: fill, stroke: stroke, points: 4, diff --git a/test/spec/ol/style/regularshape.test.js b/test/spec/ol/style/regularshape.test.js index 41ab809858..e0a96ebad4 100644 --- a/test/spec/ol/style/regularshape.test.js +++ b/test/spec/ol/style/regularshape.test.js @@ -1,5 +1,5 @@ import AtlasManager from '../../../../src/ol/style/AtlasManager.js'; -import _ol_style_RegularShape_ from '../../../../src/ol/style/RegularShape.js'; +import RegularShape from '../../../../src/ol/style/RegularShape.js'; import Fill from '../../../../src/ol/style/Fill.js'; import Stroke from '../../../../src/ol/style/Stroke.js'; @@ -9,7 +9,7 @@ describe('ol.style.RegularShape', function() { describe('#constructor', function() { it('can use rotateWithView', function() { - var style = new _ol_style_RegularShape_({ + var style = new RegularShape({ rotateWithView: true, radius: 0 }); @@ -17,7 +17,7 @@ describe('ol.style.RegularShape', function() { }); it('can use radius', function() { - var style = new _ol_style_RegularShape_({ + var style = new RegularShape({ radius: 5, radius2: 10 }); @@ -26,7 +26,7 @@ describe('ol.style.RegularShape', function() { }); it('can use radius1 as an alias for radius', function() { - var style = new _ol_style_RegularShape_({ + var style = new RegularShape({ radius1: 5, radius2: 10 }); @@ -35,7 +35,7 @@ describe('ol.style.RegularShape', function() { }); it('creates a canvas if no atlas is used (no fill-style)', function() { - var style = new _ol_style_RegularShape_({radius: 10}); + var style = new RegularShape({radius: 10}); expect(style.getImage()).to.be.an(HTMLCanvasElement); expect(style.getSize()).to.eql([21, 21]); expect(style.getImageSize()).to.eql([21, 21]); @@ -48,7 +48,7 @@ describe('ol.style.RegularShape', function() { }); it('creates a canvas if no atlas is used (fill-style)', function() { - var style = new _ol_style_RegularShape_({ + var style = new RegularShape({ radius: 10, fill: new Fill({ color: '#FFFF00' @@ -67,7 +67,7 @@ describe('ol.style.RegularShape', function() { it('adds itself to an atlas manager (no fill-style)', function() { var atlasManager = new AtlasManager({initialSize: 512}); - var style = new _ol_style_RegularShape_( + var style = new RegularShape( {radius: 10, atlasManager: atlasManager}); expect(style.getImage()).to.be.an(HTMLCanvasElement); expect(style.getSize()).to.eql([21, 21]); @@ -82,7 +82,7 @@ describe('ol.style.RegularShape', function() { it('adds itself to an atlas manager (fill-style)', function() { var atlasManager = new AtlasManager({initialSize: 512}); - var style = new _ol_style_RegularShape_({ + var style = new RegularShape({ radius: 10, atlasManager: atlasManager, fill: new Fill({ @@ -104,16 +104,16 @@ describe('ol.style.RegularShape', function() { describe('#clone', function() { it('creates a new ol.style.RegularShape', function() { - var original = new _ol_style_RegularShape_({ + var original = new RegularShape({ points: 5 }); var clone = original.clone(); - expect(clone).to.be.an(_ol_style_RegularShape_); + expect(clone).to.be.an(RegularShape); expect(clone).to.not.be(original); }); it('copies all values', function() { - var original = new _ol_style_RegularShape_({ + var original = new RegularShape({ fill: new Fill({ color: '#319FD3' }), @@ -145,7 +145,7 @@ describe('ol.style.RegularShape', function() { }); it('the clone does not reference the same objects as the original', function() { - var original = new _ol_style_RegularShape_({ + var original = new RegularShape({ fill: new Fill({ color: '#319FD3' }), @@ -168,11 +168,11 @@ describe('ol.style.RegularShape', function() { describe('#getChecksum', function() { it('calculates not the same hash code (radius)', function() { - var style1 = new _ol_style_RegularShape_({ + var style1 = new RegularShape({ radius: 4, radius2: 5 }); - var style2 = new _ol_style_RegularShape_({ + var style2 = new RegularShape({ radius: 3, radius2: 5 }); @@ -180,11 +180,11 @@ describe('ol.style.RegularShape', function() { }); it('calculates not the same hash code (radius2)', function() { - var style1 = new _ol_style_RegularShape_({ + var style1 = new RegularShape({ radius: 4, radius2: 5 }); - var style2 = new _ol_style_RegularShape_({ + var style2 = new RegularShape({ radius: 4, radius2: 6 }); @@ -192,23 +192,23 @@ describe('ol.style.RegularShape', function() { }); it('calculates the same hash code (radius)', function() { - var style1 = new _ol_style_RegularShape_({ + var style1 = new RegularShape({ radius: 5 }); - var style2 = new _ol_style_RegularShape_({ + var style2 = new RegularShape({ radius: 5 }); expect(style1.getChecksum()).to.eql(style2.getChecksum()); }); it('calculates not the same hash code (color)', function() { - var style1 = new _ol_style_RegularShape_({ + var style1 = new RegularShape({ radius: 5, fill: new Fill({ color: '#319FD3' }) }); - var style2 = new _ol_style_RegularShape_({ + var style2 = new RegularShape({ radius: 5, stroke: new Stroke({ color: '#319FD3' @@ -218,7 +218,7 @@ describe('ol.style.RegularShape', function() { }); it('calculates the same hash code (everything set)', function() { - var style1 = new _ol_style_RegularShape_({ + var style1 = new RegularShape({ radius: 5, radius2: 3, angle: 1.41, @@ -235,7 +235,7 @@ describe('ol.style.RegularShape', function() { width: 2 }) }); - var style2 = new _ol_style_RegularShape_({ + var style2 = new RegularShape({ radius: 5, radius2: 3, angle: 1.41, @@ -256,7 +256,7 @@ describe('ol.style.RegularShape', function() { }); it('calculates not the same hash code (stroke width differs)', function() { - var style1 = new _ol_style_RegularShape_({ + var style1 = new RegularShape({ radius: 5, radius2: 3, angle: 1.41, @@ -273,7 +273,7 @@ describe('ol.style.RegularShape', function() { width: 3 }) }); - var style2 = new _ol_style_RegularShape_({ + var style2 = new RegularShape({ radius: 5, radius2: 3, angle: 1.41, @@ -294,7 +294,7 @@ describe('ol.style.RegularShape', function() { }); it('invalidates a cached checksum if values change (fill)', function() { - var style1 = new _ol_style_RegularShape_({ + var style1 = new RegularShape({ radius: 5, fill: new Fill({ color: '#319FD3' @@ -303,7 +303,7 @@ describe('ol.style.RegularShape', function() { color: '#319FD3' }) }); - var style2 = new _ol_style_RegularShape_({ + var style2 = new RegularShape({ radius: 5, fill: new Fill({ color: '#319FD3' @@ -319,7 +319,7 @@ describe('ol.style.RegularShape', function() { }); it('invalidates a cached checksum if values change (stroke)', function() { - var style1 = new _ol_style_RegularShape_({ + var style1 = new RegularShape({ radius: 5, fill: new Fill({ color: '#319FD3' @@ -328,7 +328,7 @@ describe('ol.style.RegularShape', function() { color: '#319FD3' }) }); - var style2 = new _ol_style_RegularShape_({ + var style2 = new RegularShape({ radius: 5, fill: new Fill({ color: '#319FD3'