Separate literals from symbolizers
This commit is contained in:
53
src/ol/style/iconliteral.js
Normal file
53
src/ol/style/iconliteral.js
Normal file
@@ -0,0 +1,53 @@
|
||||
goog.provide('ol.style.IconLiteral');
|
||||
goog.provide('ol.style.IconType');
|
||||
|
||||
goog.require('ol.style.PointLiteral');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{url: (string),
|
||||
* width: (number|undefined),
|
||||
* height: (number|undefined),
|
||||
* opacity: (number),
|
||||
* rotation: (number)}}
|
||||
*/
|
||||
ol.style.IconLiteralOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.PointLiteral}
|
||||
* @param {ol.style.IconLiteralOptions} options Icon literal options.
|
||||
*/
|
||||
ol.style.IconLiteral = function(options) {
|
||||
|
||||
/** @type {string} */
|
||||
this.url = options.url;
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.width = options.width;
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.height = options.height;
|
||||
|
||||
/** @type {number} */
|
||||
this.opacity = options.opacity;
|
||||
|
||||
/** @type {number} */
|
||||
this.rotation = options.rotation;
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.IconLiteral, ol.style.PointLiteral);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.IconLiteral.prototype.equals = function(iconLiteral) {
|
||||
return this.url == iconLiteral.url &&
|
||||
this.width == iconLiteral.width &&
|
||||
this.height == iconLiteral.height &&
|
||||
this.opacity == iconLiteral.opacity &&
|
||||
this.rotation == iconLiteral.rotation;
|
||||
};
|
||||
@@ -1,64 +1,15 @@
|
||||
goog.provide('ol.style.Icon');
|
||||
goog.provide('ol.style.IconLiteral');
|
||||
goog.provide('ol.style.IconType');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Expression');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.style.IconLiteral');
|
||||
goog.require('ol.style.IconType');
|
||||
goog.require('ol.style.Point');
|
||||
goog.require('ol.style.PointLiteral');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{url: (string),
|
||||
* width: (number|undefined),
|
||||
* height: (number|undefined),
|
||||
* opacity: (number),
|
||||
* rotation: (number)}}
|
||||
*/
|
||||
ol.style.IconLiteralOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.PointLiteral}
|
||||
* @param {ol.style.IconLiteralOptions} options Icon literal options.
|
||||
*/
|
||||
ol.style.IconLiteral = function(options) {
|
||||
|
||||
/** @type {string} */
|
||||
this.url = options.url;
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.width = options.width;
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.height = options.height;
|
||||
|
||||
/** @type {number} */
|
||||
this.opacity = options.opacity;
|
||||
|
||||
/** @type {number} */
|
||||
this.rotation = options.rotation;
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.IconLiteral, ol.style.PointLiteral);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.IconLiteral.prototype.equals = function(iconLiteral) {
|
||||
return this.url == iconLiteral.url &&
|
||||
this.width == iconLiteral.width &&
|
||||
this.height == iconLiteral.height &&
|
||||
this.opacity == iconLiteral.opacity &&
|
||||
this.rotation == iconLiteral.rotation;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
50
src/ol/style/lineliteral.js
Normal file
50
src/ol/style/lineliteral.js
Normal file
@@ -0,0 +1,50 @@
|
||||
goog.provide('ol.style.LineLiteral');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.style.Literal');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{strokeColor: (string),
|
||||
* strokeOpacity: (number),
|
||||
* strokeWidth: (number)}}
|
||||
*/
|
||||
ol.style.LineLiteralOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Literal}
|
||||
* @param {ol.style.LineLiteralOptions} options Line literal options.
|
||||
*/
|
||||
ol.style.LineLiteral = function(options) {
|
||||
goog.base(this);
|
||||
|
||||
goog.asserts.assertString(
|
||||
options.strokeColor, 'strokeColor must be a string');
|
||||
/** @type {string} */
|
||||
this.strokeColor = options.strokeColor;
|
||||
|
||||
goog.asserts.assertNumber(
|
||||
options.strokeOpacity, 'strokeOpacity must be a number');
|
||||
/** @type {number} */
|
||||
this.strokeOpacity = options.strokeOpacity;
|
||||
|
||||
goog.asserts.assertNumber(
|
||||
options.strokeWidth, 'strokeWidth must be a number');
|
||||
/** @type {number} */
|
||||
this.strokeWidth = options.strokeWidth;
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.LineLiteral, ol.style.Literal);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.LineLiteral.prototype.equals = function(lineLiteral) {
|
||||
return this.strokeColor == lineLiteral.strokeColor &&
|
||||
this.strokeOpacity == lineLiteral.strokeOpacity &&
|
||||
this.strokeWidth == lineLiteral.strokeWidth;
|
||||
};
|
||||
@@ -1,60 +1,14 @@
|
||||
goog.provide('ol.style.Line');
|
||||
goog.provide('ol.style.LineLiteral');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Expression');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.style.LineLiteral');
|
||||
goog.require('ol.style.Symbolizer');
|
||||
goog.require('ol.style.Literal');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{strokeColor: (string),
|
||||
* strokeOpacity: (number),
|
||||
* strokeWidth: (number)}}
|
||||
*/
|
||||
ol.style.LineLiteralOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Literal}
|
||||
* @param {ol.style.LineLiteralOptions} options Line literal options.
|
||||
*/
|
||||
ol.style.LineLiteral = function(options) {
|
||||
goog.base(this);
|
||||
|
||||
goog.asserts.assertString(
|
||||
options.strokeColor, 'strokeColor must be a string');
|
||||
/** @type {string} */
|
||||
this.strokeColor = options.strokeColor;
|
||||
|
||||
goog.asserts.assertNumber(
|
||||
options.strokeOpacity, 'strokeOpacity must be a number');
|
||||
/** @type {number} */
|
||||
this.strokeOpacity = options.strokeOpacity;
|
||||
|
||||
goog.asserts.assertNumber(
|
||||
options.strokeWidth, 'strokeWidth must be a number');
|
||||
/** @type {number} */
|
||||
this.strokeWidth = options.strokeWidth;
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.LineLiteral, ol.style.Literal);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.LineLiteral.prototype.equals = function(lineLiteral) {
|
||||
return this.strokeColor == lineLiteral.strokeColor &&
|
||||
this.strokeOpacity == lineLiteral.strokeOpacity &&
|
||||
this.strokeWidth == lineLiteral.strokeWidth;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
16
src/ol/style/literal.js
Normal file
16
src/ol/style/literal.js
Normal file
@@ -0,0 +1,16 @@
|
||||
goog.provide('ol.style.Literal');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
ol.style.Literal = function() {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.style.Literal} symbolizerLiteral Symbolizer literal to
|
||||
* compare to.
|
||||
* @return {boolean} Is the passed symbolizer literal equal to this instance?
|
||||
*/
|
||||
ol.style.Literal.prototype.equals = goog.abstractMethod;
|
||||
14
src/ol/style/pointliteral.js
Normal file
14
src/ol/style/pointliteral.js
Normal file
@@ -0,0 +1,14 @@
|
||||
goog.provide('ol.style.PointLiteral');
|
||||
|
||||
goog.require('ol.style.Literal');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Literal}
|
||||
*/
|
||||
ol.style.PointLiteral = function() {
|
||||
goog.base(this);
|
||||
};
|
||||
goog.inherits(ol.style.PointLiteral, ol.style.Literal);
|
||||
@@ -1,19 +1,6 @@
|
||||
goog.provide('ol.style.Point');
|
||||
goog.provide('ol.style.PointLiteral');
|
||||
|
||||
goog.require('ol.style.Symbolizer');
|
||||
goog.require('ol.style.Literal');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Literal}
|
||||
*/
|
||||
ol.style.PointLiteral = function() {
|
||||
goog.base(this);
|
||||
};
|
||||
goog.inherits(ol.style.PointLiteral, ol.style.Literal);
|
||||
|
||||
|
||||
|
||||
82
src/ol/style/polygonliteral.js
Normal file
82
src/ol/style/polygonliteral.js
Normal file
@@ -0,0 +1,82 @@
|
||||
goog.provide('ol.style.PolygonLiteral');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.style.Literal');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{fillColor: (string|undefined),
|
||||
* fillOpacity: (number|undefined),
|
||||
* strokeColor: (string|undefined),
|
||||
* strokeOpacity: (number|undefined),
|
||||
* strokeWidth: (number|undefined)}}
|
||||
*/
|
||||
ol.style.PolygonLiteralOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Literal}
|
||||
* @param {ol.style.PolygonLiteralOptions} options Polygon literal options.
|
||||
*/
|
||||
ol.style.PolygonLiteral = function(options) {
|
||||
goog.base(this);
|
||||
|
||||
/** @type {string|undefined} */
|
||||
this.fillColor = options.fillColor;
|
||||
if (goog.isDef(options.fillColor)) {
|
||||
goog.asserts.assertString(options.fillColor, 'fillColor must be a string');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.fillOpacity = options.fillOpacity;
|
||||
if (goog.isDef(options.fillOpacity)) {
|
||||
goog.asserts.assertNumber(
|
||||
options.fillOpacity, 'fillOpacity must be a number');
|
||||
}
|
||||
|
||||
/** @type {string|undefined} */
|
||||
this.strokeColor = options.strokeColor;
|
||||
if (goog.isDef(this.strokeColor)) {
|
||||
goog.asserts.assertString(
|
||||
this.strokeColor, 'strokeColor must be a string');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.strokeOpacity = options.strokeOpacity;
|
||||
if (goog.isDef(this.strokeOpacity)) {
|
||||
goog.asserts.assertNumber(
|
||||
this.strokeOpacity, 'strokeOpacity must be a number');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.strokeWidth = options.strokeWidth;
|
||||
if (goog.isDef(this.strokeWidth)) {
|
||||
goog.asserts.assertNumber(
|
||||
this.strokeWidth, 'strokeWidth must be a number');
|
||||
}
|
||||
|
||||
// fill and/or stroke properties must be defined
|
||||
var fillDef = goog.isDef(this.fillColor) && goog.isDef(this.fillOpacity);
|
||||
var strokeDef = goog.isDef(this.strokeColor) &&
|
||||
goog.isDef(this.strokeOpacity) &&
|
||||
goog.isDef(this.strokeWidth);
|
||||
goog.asserts.assert(fillDef || strokeDef,
|
||||
'Either fillColor and fillOpacity or ' +
|
||||
'strokeColor and strokeOpacity and strokeWidth must be set');
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.PolygonLiteral, ol.style.Literal);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.PolygonLiteral.prototype.equals = function(polygonLiteral) {
|
||||
return this.fillColor == polygonLiteral.fillColor &&
|
||||
this.fillOpacity == polygonLiteral.fillOpacity &&
|
||||
this.strokeColor == polygonLiteral.strokeColor &&
|
||||
this.strokeOpacity == polygonLiteral.strokeOpacity &&
|
||||
this.strokeWidth == polygonLiteral.strokeWidth;
|
||||
};
|
||||
@@ -1,90 +1,11 @@
|
||||
goog.provide('ol.style.Polygon');
|
||||
goog.provide('ol.style.PolygonLiteral');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Expression');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.style.PolygonLiteral');
|
||||
goog.require('ol.style.Symbolizer');
|
||||
goog.require('ol.style.Literal');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{fillColor: (string|undefined),
|
||||
* fillOpacity: (number|undefined),
|
||||
* strokeColor: (string|undefined),
|
||||
* strokeOpacity: (number|undefined),
|
||||
* strokeWidth: (number|undefined)}}
|
||||
*/
|
||||
ol.style.PolygonLiteralOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Literal}
|
||||
* @param {ol.style.PolygonLiteralOptions} options Polygon literal options.
|
||||
*/
|
||||
ol.style.PolygonLiteral = function(options) {
|
||||
goog.base(this);
|
||||
|
||||
/** @type {string|undefined} */
|
||||
this.fillColor = options.fillColor;
|
||||
if (goog.isDef(options.fillColor)) {
|
||||
goog.asserts.assertString(options.fillColor, 'fillColor must be a string');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.fillOpacity = options.fillOpacity;
|
||||
if (goog.isDef(options.fillOpacity)) {
|
||||
goog.asserts.assertNumber(
|
||||
options.fillOpacity, 'fillOpacity must be a number');
|
||||
}
|
||||
|
||||
/** @type {string|undefined} */
|
||||
this.strokeColor = options.strokeColor;
|
||||
if (goog.isDef(this.strokeColor)) {
|
||||
goog.asserts.assertString(
|
||||
this.strokeColor, 'strokeColor must be a string');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.strokeOpacity = options.strokeOpacity;
|
||||
if (goog.isDef(this.strokeOpacity)) {
|
||||
goog.asserts.assertNumber(
|
||||
this.strokeOpacity, 'strokeOpacity must be a number');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.strokeWidth = options.strokeWidth;
|
||||
if (goog.isDef(this.strokeWidth)) {
|
||||
goog.asserts.assertNumber(
|
||||
this.strokeWidth, 'strokeWidth must be a number');
|
||||
}
|
||||
|
||||
// fill and/or stroke properties must be defined
|
||||
var fillDef = goog.isDef(this.fillColor) && goog.isDef(this.fillOpacity);
|
||||
var strokeDef = goog.isDef(this.strokeColor) &&
|
||||
goog.isDef(this.strokeOpacity) &&
|
||||
goog.isDef(this.strokeWidth);
|
||||
goog.asserts.assert(fillDef || strokeDef,
|
||||
'Either fillColor and fillOpacity or ' +
|
||||
'strokeColor and strokeOpacity and strokeWidth must be set');
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.PolygonLiteral, ol.style.Literal);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.PolygonLiteral.prototype.equals = function(polygonLiteral) {
|
||||
return this.fillColor == polygonLiteral.fillColor &&
|
||||
this.fillOpacity == polygonLiteral.fillOpacity &&
|
||||
this.strokeColor == polygonLiteral.strokeColor &&
|
||||
this.strokeOpacity == polygonLiteral.strokeOpacity &&
|
||||
this.strokeWidth == polygonLiteral.strokeWidth;
|
||||
};
|
||||
|
||||
|
||||
|
||||
102
src/ol/style/shapeliteral.js
Normal file
102
src/ol/style/shapeliteral.js
Normal file
@@ -0,0 +1,102 @@
|
||||
goog.provide('ol.style.ShapeLiteral');
|
||||
goog.provide('ol.style.ShapeType');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.style.PointLiteral');
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.style.ShapeType = {
|
||||
CIRCLE: 'circle'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{type: (ol.style.ShapeType),
|
||||
* size: (number),
|
||||
* fillColor: (string|undefined),
|
||||
* fillOpacity: (number|undefined),
|
||||
* strokeColor: (string|undefined),
|
||||
* strokeOpacity: (number|undefined),
|
||||
* strokeWidth: (number|undefined)}}
|
||||
*/
|
||||
ol.style.ShapeLiteralOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.PointLiteral}
|
||||
* @param {ol.style.ShapeLiteralOptions} options Shape literal options.
|
||||
*/
|
||||
ol.style.ShapeLiteral = function(options) {
|
||||
|
||||
goog.asserts.assertString(options.type, 'type must be a string');
|
||||
/** @type {ol.style.ShapeType} */
|
||||
this.type = options.type;
|
||||
|
||||
goog.asserts.assertNumber(options.size, 'size must be a number');
|
||||
/** @type {number} */
|
||||
this.size = options.size;
|
||||
|
||||
/** @type {string|undefined} */
|
||||
this.fillColor = options.fillColor;
|
||||
if (goog.isDef(options.fillColor)) {
|
||||
goog.asserts.assertString(options.fillColor, 'fillColor must be a string');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.fillOpacity = options.fillOpacity;
|
||||
if (goog.isDef(options.fillOpacity)) {
|
||||
goog.asserts.assertNumber(
|
||||
options.fillOpacity, 'fillOpacity must be a number');
|
||||
}
|
||||
|
||||
/** @type {string|undefined} */
|
||||
this.strokeColor = options.strokeColor;
|
||||
if (goog.isDef(this.strokeColor)) {
|
||||
goog.asserts.assertString(
|
||||
this.strokeColor, 'strokeColor must be a string');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.strokeOpacity = options.strokeOpacity;
|
||||
if (goog.isDef(this.strokeOpacity)) {
|
||||
goog.asserts.assertNumber(
|
||||
this.strokeOpacity, 'strokeOpacity must be a number');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.strokeWidth = options.strokeWidth;
|
||||
if (goog.isDef(this.strokeWidth)) {
|
||||
goog.asserts.assertNumber(
|
||||
this.strokeWidth, 'strokeWidth must be a number');
|
||||
}
|
||||
|
||||
// fill and/or stroke properties must be defined
|
||||
var fillDef = goog.isDef(this.fillColor) && goog.isDef(this.fillOpacity);
|
||||
var strokeDef = goog.isDef(this.strokeColor) &&
|
||||
goog.isDef(this.strokeOpacity) &&
|
||||
goog.isDef(this.strokeWidth);
|
||||
goog.asserts.assert(fillDef || strokeDef,
|
||||
'Either fillColor and fillOpacity or ' +
|
||||
'strokeColor and strokeOpacity and strokeWidth must be set');
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.ShapeLiteral, ol.style.PointLiteral);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.ShapeLiteral.prototype.equals = function(shapeLiteral) {
|
||||
return this.type == shapeLiteral.type &&
|
||||
this.size == shapeLiteral.size &&
|
||||
this.fillColor == shapeLiteral.fillColor &&
|
||||
this.fillOpacity == shapeLiteral.fillOpacity &&
|
||||
this.strokeColor == shapeLiteral.strokeColor &&
|
||||
this.strokeOpacity == shapeLiteral.strokeOpacity &&
|
||||
this.strokeWidth == shapeLiteral.strokeWidth;
|
||||
};
|
||||
@@ -1,6 +1,4 @@
|
||||
goog.provide('ol.style.Shape');
|
||||
goog.provide('ol.style.ShapeLiteral');
|
||||
goog.provide('ol.style.ShapeType');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.expr');
|
||||
@@ -8,103 +6,8 @@ goog.require('ol.expr.Expression');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.style.Point');
|
||||
goog.require('ol.style.PointLiteral');
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.style.ShapeType = {
|
||||
CIRCLE: 'circle'
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{type: (ol.style.ShapeType),
|
||||
* size: (number),
|
||||
* fillColor: (string|undefined),
|
||||
* fillOpacity: (number|undefined),
|
||||
* strokeColor: (string|undefined),
|
||||
* strokeOpacity: (number|undefined),
|
||||
* strokeWidth: (number|undefined)}}
|
||||
*/
|
||||
ol.style.ShapeLiteralOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.PointLiteral}
|
||||
* @param {ol.style.ShapeLiteralOptions} options Shape literal options.
|
||||
*/
|
||||
ol.style.ShapeLiteral = function(options) {
|
||||
|
||||
goog.asserts.assertString(options.type, 'type must be a string');
|
||||
/** @type {ol.style.ShapeType} */
|
||||
this.type = options.type;
|
||||
|
||||
goog.asserts.assertNumber(options.size, 'size must be a number');
|
||||
/** @type {number} */
|
||||
this.size = options.size;
|
||||
|
||||
/** @type {string|undefined} */
|
||||
this.fillColor = options.fillColor;
|
||||
if (goog.isDef(options.fillColor)) {
|
||||
goog.asserts.assertString(options.fillColor, 'fillColor must be a string');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.fillOpacity = options.fillOpacity;
|
||||
if (goog.isDef(options.fillOpacity)) {
|
||||
goog.asserts.assertNumber(
|
||||
options.fillOpacity, 'fillOpacity must be a number');
|
||||
}
|
||||
|
||||
/** @type {string|undefined} */
|
||||
this.strokeColor = options.strokeColor;
|
||||
if (goog.isDef(this.strokeColor)) {
|
||||
goog.asserts.assertString(
|
||||
this.strokeColor, 'strokeColor must be a string');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.strokeOpacity = options.strokeOpacity;
|
||||
if (goog.isDef(this.strokeOpacity)) {
|
||||
goog.asserts.assertNumber(
|
||||
this.strokeOpacity, 'strokeOpacity must be a number');
|
||||
}
|
||||
|
||||
/** @type {number|undefined} */
|
||||
this.strokeWidth = options.strokeWidth;
|
||||
if (goog.isDef(this.strokeWidth)) {
|
||||
goog.asserts.assertNumber(
|
||||
this.strokeWidth, 'strokeWidth must be a number');
|
||||
}
|
||||
|
||||
// fill and/or stroke properties must be defined
|
||||
var fillDef = goog.isDef(this.fillColor) && goog.isDef(this.fillOpacity);
|
||||
var strokeDef = goog.isDef(this.strokeColor) &&
|
||||
goog.isDef(this.strokeOpacity) &&
|
||||
goog.isDef(this.strokeWidth);
|
||||
goog.asserts.assert(fillDef || strokeDef,
|
||||
'Either fillColor and fillOpacity or ' +
|
||||
'strokeColor and strokeOpacity and strokeWidth must be set');
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.ShapeLiteral, ol.style.PointLiteral);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.ShapeLiteral.prototype.equals = function(shapeLiteral) {
|
||||
return this.type == shapeLiteral.type &&
|
||||
this.size == shapeLiteral.size &&
|
||||
this.fillColor == shapeLiteral.fillColor &&
|
||||
this.fillOpacity == shapeLiteral.fillOpacity &&
|
||||
this.strokeColor == shapeLiteral.strokeColor &&
|
||||
this.strokeOpacity == shapeLiteral.strokeOpacity &&
|
||||
this.strokeWidth == shapeLiteral.strokeWidth;
|
||||
};
|
||||
goog.require('ol.style.ShapeLiteral');
|
||||
goog.require('ol.style.ShapeType');
|
||||
|
||||
|
||||
|
||||
@@ -1,22 +1,7 @@
|
||||
goog.provide('ol.style.Symbolizer');
|
||||
goog.provide('ol.style.Literal');
|
||||
|
||||
goog.require('ol.Feature');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
ol.style.Literal = function() {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.style.Literal} symbolizerLiteral Symbolizer literal to
|
||||
* compare to.
|
||||
* @return {boolean} Is the passed symbolizer literal equal to this instance?
|
||||
*/
|
||||
ol.style.Literal.prototype.equals = goog.abstractMethod;
|
||||
goog.require('ol.style.Literal');
|
||||
|
||||
|
||||
|
||||
|
||||
57
src/ol/style/textliteral.js
Normal file
57
src/ol/style/textliteral.js
Normal file
@@ -0,0 +1,57 @@
|
||||
goog.provide('ol.style.TextLiteral');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.style.Literal');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{color: string,
|
||||
* fontFamily: string,
|
||||
* fontSize: number,
|
||||
* text: string,
|
||||
* opacity: number}}
|
||||
*/
|
||||
ol.style.TextLiteralOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Literal}
|
||||
* @param {ol.style.TextLiteralOptions} options Text literal options.
|
||||
*/
|
||||
ol.style.TextLiteral = function(options) {
|
||||
|
||||
goog.asserts.assertString(options.color, 'color must be a string');
|
||||
/** @type {string} */
|
||||
this.color = options.color;
|
||||
|
||||
goog.asserts.assertString(options.fontFamily, 'fontFamily must be a string');
|
||||
/** @type {string} */
|
||||
this.fontFamily = options.fontFamily;
|
||||
|
||||
goog.asserts.assertNumber(options.fontSize, 'fontSize must be a number');
|
||||
/** @type {number} */
|
||||
this.fontSize = options.fontSize;
|
||||
|
||||
goog.asserts.assertString(options.text, 'text must be a string');
|
||||
/** @type {string} */
|
||||
this.text = options.text;
|
||||
|
||||
goog.asserts.assertNumber(options.opacity, 'opacity must be a number');
|
||||
/** @type {number} */
|
||||
this.opacity = options.opacity;
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.TextLiteral, ol.style.Literal);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.TextLiteral.prototype.equals = function(textLiteral) {
|
||||
return this.color == textLiteral.color &&
|
||||
this.fontFamily == textLiteral.fontFamily &&
|
||||
this.fontSize == textLiteral.fontSize &&
|
||||
this.opacity == textLiteral.opacity;
|
||||
};
|
||||
@@ -1,65 +1,11 @@
|
||||
goog.provide('ol.style.Text');
|
||||
goog.provide('ol.style.TextLiteral');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol.expr');
|
||||
goog.require('ol.expr.Expression');
|
||||
goog.require('ol.expr.Literal');
|
||||
goog.require('ol.style.Symbolizer');
|
||||
goog.require('ol.style.Literal');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{color: string,
|
||||
* fontFamily: string,
|
||||
* fontSize: number,
|
||||
* text: string,
|
||||
* opacity: number}}
|
||||
*/
|
||||
ol.style.TextLiteralOptions;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.style.Literal}
|
||||
* @param {ol.style.TextLiteralOptions} options Text literal options.
|
||||
*/
|
||||
ol.style.TextLiteral = function(options) {
|
||||
|
||||
goog.asserts.assertString(options.color, 'color must be a string');
|
||||
/** @type {string} */
|
||||
this.color = options.color;
|
||||
|
||||
goog.asserts.assertString(options.fontFamily, 'fontFamily must be a string');
|
||||
/** @type {string} */
|
||||
this.fontFamily = options.fontFamily;
|
||||
|
||||
goog.asserts.assertNumber(options.fontSize, 'fontSize must be a number');
|
||||
/** @type {number} */
|
||||
this.fontSize = options.fontSize;
|
||||
|
||||
goog.asserts.assertString(options.text, 'text must be a string');
|
||||
/** @type {string} */
|
||||
this.text = options.text;
|
||||
|
||||
goog.asserts.assertNumber(options.opacity, 'opacity must be a number');
|
||||
/** @type {number} */
|
||||
this.opacity = options.opacity;
|
||||
|
||||
};
|
||||
goog.inherits(ol.style.TextLiteral, ol.style.Literal);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.style.TextLiteral.prototype.equals = function(textLiteral) {
|
||||
return this.color == textLiteral.color &&
|
||||
this.fontFamily == textLiteral.fontFamily &&
|
||||
this.fontSize == textLiteral.fontSize &&
|
||||
this.opacity == textLiteral.opacity;
|
||||
};
|
||||
goog.require('ol.style.TextLiteral');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user