Add getters to ol.style.Stroke
This commit is contained in:
@@ -385,18 +385,24 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle =
|
|||||||
state.fillStyle = undefined;
|
state.fillStyle = undefined;
|
||||||
}
|
}
|
||||||
if (!goog.isNull(strokeStyle)) {
|
if (!goog.isNull(strokeStyle)) {
|
||||||
state.strokeStyle = ol.color.asString(!goog.isNull(strokeStyle.color) ?
|
var strokeStyleColor = strokeStyle.getColor();
|
||||||
strokeStyle.color : ol.render.canvas.defaultStrokeStyle);
|
state.strokeStyle = ol.color.asString(!goog.isNull(strokeStyleColor) ?
|
||||||
state.lineCap = goog.isDef(strokeStyle.lineCap) ?
|
strokeStyleColor : ol.render.canvas.defaultStrokeStyle);
|
||||||
strokeStyle.lineCap : ol.render.canvas.defaultLineCap;
|
var strokeStyleLineCap = strokeStyle.getLineCap();
|
||||||
state.lineDash = !goog.isNull(strokeStyle.lineDash) ?
|
state.lineCap = goog.isDef(strokeStyleLineCap) ?
|
||||||
strokeStyle.lineDash : ol.render.canvas.defaultLineDash;
|
strokeStyleLineCap : ol.render.canvas.defaultLineCap;
|
||||||
state.lineJoin = goog.isDef(strokeStyle.lineJoin) ?
|
var strokeStyleLineDash = strokeStyle.getLineDash();
|
||||||
strokeStyle.lineJoin : ol.render.canvas.defaultLineJoin;
|
state.lineDash = !goog.isNull(strokeStyleLineDash) ?
|
||||||
state.lineWidth = this.pixelRatio_ * (goog.isDef(strokeStyle.width) ?
|
strokeStyleLineDash : ol.render.canvas.defaultLineDash;
|
||||||
strokeStyle.width : ol.render.canvas.defaultLineWidth);
|
var strokeStyleLineJoin = strokeStyle.getLineJoin();
|
||||||
state.miterLimit = goog.isDef(strokeStyle.miterLimit) ?
|
state.lineJoin = goog.isDef(strokeStyleLineJoin) ?
|
||||||
strokeStyle.miterLimit : ol.render.canvas.defaultMiterLimit;
|
strokeStyleLineJoin : ol.render.canvas.defaultLineJoin;
|
||||||
|
var strokeStyleWidth = strokeStyle.getWidth();
|
||||||
|
state.lineWidth = this.pixelRatio_ * (goog.isDef(strokeStyleWidth) ?
|
||||||
|
strokeStyleWidth : ol.render.canvas.defaultLineWidth);
|
||||||
|
var strokeStyleMiterLimit = strokeStyle.getMiterLimit();
|
||||||
|
state.miterLimit = goog.isDef(strokeStyleMiterLimit) ?
|
||||||
|
strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit;
|
||||||
} else {
|
} else {
|
||||||
state.strokeStyle = undefined;
|
state.strokeStyle = undefined;
|
||||||
state.lineCap = undefined;
|
state.lineCap = undefined;
|
||||||
|
|||||||
@@ -810,18 +810,24 @@ ol.render.canvas.LineStringReplay.prototype.setFillStrokeStyle =
|
|||||||
goog.asserts.assert(!goog.isNull(this.state_));
|
goog.asserts.assert(!goog.isNull(this.state_));
|
||||||
goog.asserts.assert(goog.isNull(fillStyle));
|
goog.asserts.assert(goog.isNull(fillStyle));
|
||||||
goog.asserts.assert(!goog.isNull(strokeStyle));
|
goog.asserts.assert(!goog.isNull(strokeStyle));
|
||||||
this.state_.strokeStyle = ol.color.asString(!goog.isNull(strokeStyle.color) ?
|
var strokeStyleColor = strokeStyle.getColor();
|
||||||
strokeStyle.color : ol.render.canvas.defaultStrokeStyle);
|
this.state_.strokeStyle = ol.color.asString(!goog.isNull(strokeStyleColor) ?
|
||||||
this.state_.lineCap = goog.isDef(strokeStyle.lineCap) ?
|
strokeStyleColor : ol.render.canvas.defaultStrokeStyle);
|
||||||
strokeStyle.lineCap : ol.render.canvas.defaultLineCap;
|
var strokeStyleLineCap = strokeStyle.getLineCap();
|
||||||
this.state_.lineDash = !goog.isNull(strokeStyle.lineDash) ?
|
this.state_.lineCap = goog.isDef(strokeStyleLineCap) ?
|
||||||
strokeStyle.lineDash : ol.render.canvas.defaultLineDash;
|
strokeStyleLineCap : ol.render.canvas.defaultLineCap;
|
||||||
this.state_.lineJoin = goog.isDef(strokeStyle.lineJoin) ?
|
var strokeStyleLineDash = strokeStyle.getLineDash();
|
||||||
strokeStyle.lineJoin : ol.render.canvas.defaultLineJoin;
|
this.state_.lineDash = !goog.isNull(strokeStyleLineDash) ?
|
||||||
this.state_.lineWidth = this.pixelRatio * (goog.isDef(strokeStyle.width) ?
|
strokeStyleLineDash : ol.render.canvas.defaultLineDash;
|
||||||
strokeStyle.width : ol.render.canvas.defaultLineWidth);
|
var strokeStyleLineJoin = strokeStyle.getLineJoin();
|
||||||
this.state_.miterLimit = goog.isDef(strokeStyle.miterLimit) ?
|
this.state_.lineJoin = goog.isDef(strokeStyleLineJoin) ?
|
||||||
strokeStyle.miterLimit : ol.render.canvas.defaultMiterLimit;
|
strokeStyleLineJoin : ol.render.canvas.defaultLineJoin;
|
||||||
|
var strokeStyleWidth = strokeStyle.getWidth();
|
||||||
|
this.state_.lineWidth = this.pixelRatio * (goog.isDef(strokeStyleWidth) ?
|
||||||
|
strokeStyleWidth : ol.render.canvas.defaultLineWidth);
|
||||||
|
var strokeStyleMiterLimit = strokeStyle.getMiterLimit();
|
||||||
|
this.state_.miterLimit = goog.isDef(strokeStyleMiterLimit) ?
|
||||||
|
strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1036,18 +1042,24 @@ ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyle =
|
|||||||
state.fillStyle = undefined;
|
state.fillStyle = undefined;
|
||||||
}
|
}
|
||||||
if (!goog.isNull(strokeStyle)) {
|
if (!goog.isNull(strokeStyle)) {
|
||||||
state.strokeStyle = ol.color.asString(!goog.isNull(strokeStyle.color) ?
|
var strokeStyleColor = strokeStyle.getColor();
|
||||||
strokeStyle.color : ol.render.canvas.defaultStrokeStyle);
|
state.strokeStyle = ol.color.asString(!goog.isNull(strokeStyleColor) ?
|
||||||
state.lineCap = goog.isDef(strokeStyle.lineCap) ?
|
strokeStyleColor : ol.render.canvas.defaultStrokeStyle);
|
||||||
strokeStyle.lineCap : ol.render.canvas.defaultLineCap;
|
var strokeStyleLineCap = strokeStyle.getLineCap();
|
||||||
state.lineDash = !goog.isNull(strokeStyle.lineDash) ?
|
state.lineCap = goog.isDef(strokeStyleLineCap) ?
|
||||||
strokeStyle.lineDash : ol.render.canvas.defaultLineDash;
|
strokeStyleLineCap : ol.render.canvas.defaultLineCap;
|
||||||
state.lineJoin = goog.isDef(strokeStyle.lineJoin) ?
|
var strokeStyleLineDash = strokeStyle.getLineDash();
|
||||||
strokeStyle.lineJoin : ol.render.canvas.defaultLineJoin;
|
state.lineDash = !goog.isNull(strokeStyleLineDash) ?
|
||||||
state.lineWidth = this.pixelRatio * (goog.isDef(strokeStyle.width) ?
|
strokeStyleLineDash : ol.render.canvas.defaultLineDash;
|
||||||
strokeStyle.width : ol.render.canvas.defaultLineWidth);
|
var strokeStyleLineJoin = strokeStyle.getLineJoin();
|
||||||
state.miterLimit = goog.isDef(strokeStyle.miterLimit) ?
|
state.lineJoin = goog.isDef(strokeStyleLineJoin) ?
|
||||||
strokeStyle.miterLimit : ol.render.canvas.defaultMiterLimit;
|
strokeStyleLineJoin : ol.render.canvas.defaultLineJoin;
|
||||||
|
var strokeStyleWidth = strokeStyle.getWidth();
|
||||||
|
state.lineWidth = this.pixelRatio * (goog.isDef(strokeStyleWidth) ?
|
||||||
|
strokeStyleWidth : ol.render.canvas.defaultLineWidth);
|
||||||
|
var strokeStyleMiterLimit = strokeStyle.getMiterLimit();
|
||||||
|
state.miterLimit = goog.isDef(strokeStyleMiterLimit) ?
|
||||||
|
strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit;
|
||||||
} else {
|
} else {
|
||||||
state.strokeStyle = undefined;
|
state.strokeStyle = undefined;
|
||||||
state.lineCap = undefined;
|
state.lineCap = undefined;
|
||||||
|
|||||||
@@ -131,8 +131,10 @@ ol.style.Circle.prototype.render_ = function() {
|
|||||||
context.fill();
|
context.fill();
|
||||||
}
|
}
|
||||||
if (!goog.isNull(this.stroke_)) {
|
if (!goog.isNull(this.stroke_)) {
|
||||||
context.strokeStyle = ol.color.asString(this.stroke_.color);
|
var strokeColor = this.stroke_.getColor();
|
||||||
context.lineWidth = goog.isDef(this.stroke_.width) ? this.stroke_.width : 1;
|
context.strokeStyle = ol.color.asString(strokeColor);
|
||||||
|
var strokeWidth = this.stroke_.getWidth();
|
||||||
|
context.lineWidth = goog.isDef(strokeWidth) ? strokeWidth : 1;
|
||||||
context.stroke();
|
context.stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,32 +13,86 @@ ol.style.Stroke = function(opt_options) {
|
|||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
* @type {ol.Color|string}
|
* @type {ol.Color|string}
|
||||||
*/
|
*/
|
||||||
this.color = goog.isDef(options.color) ? options.color : null;
|
this.color_ = goog.isDef(options.color) ? options.color : null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
* @type {string|undefined}
|
* @type {string|undefined}
|
||||||
*/
|
*/
|
||||||
this.lineCap = options.lineCap;
|
this.lineCap_ = options.lineCap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
* @type {Array.<number>}
|
* @type {Array.<number>}
|
||||||
*/
|
*/
|
||||||
this.lineDash = goog.isDef(options.lineDash) ? options.lineDash : null;
|
this.lineDash_ = goog.isDef(options.lineDash) ? options.lineDash : null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
* @type {string|undefined}
|
* @type {string|undefined}
|
||||||
*/
|
*/
|
||||||
this.lineJoin = options.lineJoin;
|
this.lineJoin_ = options.lineJoin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
* @type {number|undefined}
|
* @type {number|undefined}
|
||||||
*/
|
*/
|
||||||
this.miterLimit = options.miterLimit;
|
this.miterLimit_ = options.miterLimit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @private
|
||||||
* @type {number|undefined}
|
* @type {number|undefined}
|
||||||
*/
|
*/
|
||||||
this.width = options.width;
|
this.width_ = options.width;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {ol.Color|string} Color.
|
||||||
|
*/
|
||||||
|
ol.style.Stroke.prototype.getColor = function() {
|
||||||
|
return this.color_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string|undefined} Line cap.
|
||||||
|
*/
|
||||||
|
ol.style.Stroke.prototype.getLineCap = function() {
|
||||||
|
return this.lineCap_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {Array.<number>} Line dash.
|
||||||
|
*/
|
||||||
|
ol.style.Stroke.prototype.getLineDash = function() {
|
||||||
|
return this.lineDash_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string|undefined} Line join.
|
||||||
|
*/
|
||||||
|
ol.style.Stroke.prototype.getLineJoin = function() {
|
||||||
|
return this.lineJoin_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number|undefined} Miter limit.
|
||||||
|
*/
|
||||||
|
ol.style.Stroke.prototype.getMiterLimit = function() {
|
||||||
|
return this.miterLimit_;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {number|undefined} Width.
|
||||||
|
*/
|
||||||
|
ol.style.Stroke.prototype.getWidth = function() {
|
||||||
|
return this.width_;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user