Merge pull request #3254 from fredj/regular-stroke

Use lineCap, lineJoin and miterLimit stroke properties in RegularShape
This commit is contained in:
Frédéric Junod
2015-02-19 13:26:52 +01:00

View File

@@ -278,8 +278,15 @@ ol.style.RegularShape.prototype.unlistenImageChange = goog.nullFunction;
/**
* @typedef {{strokeStyle: (string|undefined), strokeWidth: number,
* size: number, lineDash: Array.<number>}}
* @typedef {{
* strokeStyle: (string|undefined),
* strokeWidth: number,
* size: number,
* lineCap: string,
* lineDash: Array.<number>,
* lineJoin: string,
* miterLimit: number
* }}
*/
ol.style.RegularShape.RenderOptions;
@@ -290,6 +297,9 @@ ol.style.RegularShape.RenderOptions;
*/
ol.style.RegularShape.prototype.render_ = function(atlasManager) {
var imageSize;
var lineCap = '';
var lineJoin = '';
var miterLimit = 0;
var lineDash = null;
var strokeStyle;
var strokeWidth = 0;
@@ -304,6 +314,18 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
if (!ol.has.CANVAS_LINE_DASH) {
lineDash = null;
}
lineJoin = this.stroke_.getLineJoin();
if (!goog.isDef(lineJoin)) {
lineJoin = ol.render.canvas.defaultLineJoin;
}
lineCap = this.stroke_.getLineCap();
if (!goog.isDef(lineCap)) {
lineCap = ol.render.canvas.defaultLineCap;
}
miterLimit = this.stroke_.getMiterLimit();
if (!goog.isDef(miterLimit)) {
miterLimit = ol.render.canvas.defaultMiterLimit;
}
}
var size = 2 * (this.radius_ + strokeWidth) + 1;
@@ -313,7 +335,10 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
strokeStyle: strokeStyle,
strokeWidth: strokeWidth,
size: size,
lineDash: lineDash
lineCap: lineCap,
lineDash: lineDash,
lineJoin: lineJoin,
miterLimit: miterLimit
};
if (!goog.isDef(atlasManager)) {
@@ -373,7 +398,7 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
/**
* @private
* @param {ol.style.Circle.RenderOptions} renderOptions
* @param {ol.style.RegularShape.RenderOptions} renderOptions
* @param {CanvasRenderingContext2D} context
* @param {number} x The origin for the symbol (x).
* @param {number} y The origin for the symbol (y).
@@ -407,6 +432,9 @@ ol.style.RegularShape.prototype.draw_ = function(renderOptions, context, x, y) {
if (!goog.isNull(renderOptions.lineDash)) {
context.setLineDash(renderOptions.lineDash);
}
context.lineCap = renderOptions.lineCap;
context.lineJoin = renderOptions.lineJoin;
context.miterLimit = renderOptions.miterLimit;
context.stroke();
}
context.closePath();