Always same format for color strings

This commit is contained in:
Éric Lemoine
2013-11-22 15:37:07 +01:00
parent b78bcce8ab
commit 6ca2fef0a3
3 changed files with 19 additions and 20 deletions

View File

@@ -1,16 +1,18 @@
goog.provide('ol.render.canvas'); goog.provide('ol.render.canvas');
goog.require('ol.color');
/**
* @const {string}
*/
ol.render.canvas.defaultFillStyle = 'black';
/** /**
* @const {string} * @const {ol.Color}
*/ */
ol.render.canvas.defaultStrokeStyle = 'black'; ol.render.canvas.defaultFillStyle = ol.color.fromString('black');
/**
* @const {ol.Color}
*/
ol.render.canvas.defaultStrokeStyle = ol.color.fromString('black');
/** /**

View File

@@ -337,15 +337,14 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle =
function(fillStyle, strokeStyle) { function(fillStyle, strokeStyle) {
var state = this.state_; var state = this.state_;
if (!goog.isNull(fillStyle)) { if (!goog.isNull(fillStyle)) {
state.fillStyle = !goog.isNull(fillStyle.color) ? state.fillStyle = ol.color.asString(!goog.isNull(fillStyle.color) ?
ol.color.asString(fillStyle.color) : ol.render.canvas.defaultFillStyle; fillStyle.color : ol.render.canvas.defaultFillStyle);
} else { } else {
state.fillStyle = undefined; state.fillStyle = undefined;
} }
if (!goog.isNull(strokeStyle)) { if (!goog.isNull(strokeStyle)) {
state.strokeStyle = !goog.isNull(strokeStyle.color) ? state.strokeStyle = ol.color.asString(!goog.isNull(strokeStyle.color) ?
ol.color.asString(strokeStyle.color) : strokeStyle.color : ol.render.canvas.defaultStrokeStyle);
ol.render.canvas.defaultStrokeStyle;
state.lineWidth = goog.isDef(strokeStyle.width) ? state.lineWidth = goog.isDef(strokeStyle.width) ?
strokeStyle.width : ol.render.canvas.defaultLineWidth; strokeStyle.width : ol.render.canvas.defaultLineWidth;
} else { } else {

View File

@@ -587,9 +587,8 @@ 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 = !goog.isNull(strokeStyle.color) ? this.state_.strokeStyle = ol.color.asString(!goog.isNull(strokeStyle.color) ?
ol.color.asString(strokeStyle.color) : strokeStyle.color : ol.render.canvas.defaultStrokeStyle);
ol.render.canvas.defaultStrokeStyle;
this.state_.lineWidth = goog.isDef(strokeStyle.width) ? this.state_.lineWidth = goog.isDef(strokeStyle.width) ?
strokeStyle.width : ol.render.canvas.defaultLineWidth; strokeStyle.width : ol.render.canvas.defaultLineWidth;
}; };
@@ -737,15 +736,14 @@ ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyle =
goog.asserts.assert(!goog.isNull(fillStyle) || !goog.isNull(strokeStyle)); goog.asserts.assert(!goog.isNull(fillStyle) || !goog.isNull(strokeStyle));
var state = this.state_; var state = this.state_;
if (!goog.isNull(fillStyle)) { if (!goog.isNull(fillStyle)) {
state.fillStyle = !goog.isNull(fillStyle.color) ? state.fillStyle = ol.color.asString(!goog.isNull(fillStyle.color) ?
ol.color.asString(fillStyle.color) : ol.render.canvas.defaultFillStyle; fillStyle.color : ol.render.canvas.defaultFillStyle);
} else { } else {
state.fillStyle = undefined; state.fillStyle = undefined;
} }
if (!goog.isNull(strokeStyle)) { if (!goog.isNull(strokeStyle)) {
state.strokeStyle = !goog.isNull(strokeStyle.color) ? state.strokeStyle = ol.color.asString(!goog.isNull(strokeStyle.color) ?
ol.color.asString(strokeStyle.color) : strokeStyle.color : ol.render.canvas.defaultStrokeStyle);
ol.render.canvas.defaultStrokeStyle;
state.lineWidth = goog.isDef(strokeStyle.width) ? state.lineWidth = goog.isDef(strokeStyle.width) ?
strokeStyle.width : ol.render.canvas.defaultLineWidth; strokeStyle.width : ol.render.canvas.defaultLineWidth;
} else { } else {