Mutable symbolizer properties for style functions
This change adds setters for symbolizer properties. In addition, it introduces a mutable flag on all styles. By default, this is set to true. ol.style.createStyleFunction sets it to false for all static styles. The new setters assert that the mutable flag is true, so whenever an application tries to set a symbolizer property on a style that was assigned to a vector layer or feature overlay, the assertion will fail.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
goog.provide('ol.style.Stroke');
|
||||
|
||||
goog.require('ol.color');
|
||||
goog.require('goog.asserts');
|
||||
|
||||
|
||||
|
||||
@@ -54,6 +54,13 @@ ol.style.Stroke = function(opt_options) {
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.width_ = options.width;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.mutable_ = true;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -109,3 +116,71 @@ ol.style.Stroke.prototype.getMiterLimit = function() {
|
||||
ol.style.Stroke.prototype.getWidth = function() {
|
||||
return this.width_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Color|string} color Color.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Stroke.prototype.setColor = function(color) {
|
||||
goog.asserts.assert(this.mutable_);
|
||||
this.color_ = color;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string|undefined} lineCap Line cap.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Stroke.prototype.setLineCap = function(lineCap) {
|
||||
goog.asserts.assert(this.mutable_);
|
||||
this.lineCap_ = lineCap;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {Array.<number>} lineDash Line dash.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Stroke.prototype.setLineDash = function(lineDash) {
|
||||
goog.asserts.assert(this.mutable_);
|
||||
this.lineDash_ = lineDash;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string|undefined} lineJoin Line join.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Stroke.prototype.setLineJoin = function(lineJoin) {
|
||||
goog.asserts.assert(this.mutable_);
|
||||
this.lineJoin_ = lineJoin;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number|undefined} miterLimit Miter limit.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Stroke.prototype.setMiterLimit = function(miterLimit) {
|
||||
goog.asserts.assert(this.mutable_);
|
||||
this.miterLimit_ = miterLimit;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number|undefined} width Width.
|
||||
* @api
|
||||
*/
|
||||
ol.style.Stroke.prototype.setWidth = function(width) {
|
||||
goog.asserts.assert(this.mutable_);
|
||||
this.width_ = width;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {boolean} mutable Mutable.
|
||||
*/
|
||||
ol.style.Stroke.prototype.setMutable = function(mutable) {
|
||||
this.mutable_ = mutable;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user