From f1d67f69c3947bba5b4467e587e1651fb0f10aed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 20 Nov 2013 14:41:24 +0100 Subject: [PATCH] Add ol.style.Stroke constructor --- src/ol/style/strokestyle.js | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/ol/style/strokestyle.js diff --git a/src/ol/style/strokestyle.js b/src/ol/style/strokestyle.js new file mode 100644 index 0000000000..8eb2a5f285 --- /dev/null +++ b/src/ol/style/strokestyle.js @@ -0,0 +1,54 @@ +goog.provide('ol.style.Stroke'); + +goog.require('ol.color'); + + +/** + * @typedef {{color: (ol.Color|string), + * width: number}} + */ +ol.style.StrokeOptions; + + + +/** + * @constructor + * @param {ol.style.StrokeOptions} options Options. + */ +ol.style.Stroke = function(options) { + + /** + * @type {ol.Color|string} + */ + this.color = options.color; + + /** + * @type {number} + */ + this.width = options.width; +}; + + +/** + * @param {ol.style.Stroke} strokeStyle1 Stroke style 1. + * @param {ol.style.Stroke} strokeStyle2 Stroke style 2. + * @return {boolean} Equals. + */ +ol.style.Stroke.equals = function(strokeStyle1, strokeStyle2) { + if (!goog.isNull(strokeStyle1)) { + if (!goog.isNull(strokeStyle2)) { + return strokeStyle1 === strokeStyle2 || + (ol.color.stringOrColorEquals(strokeStyle1.color, + strokeStyle2.color) && + strokeStyle1.width == strokeStyle2.width); + } else { + return false; + } + } else { + if (!goog.isNull(strokeStyle2)) { + return false; + } else { + return true; + } + } +};