From cef2cac0d3efa4a3dbb6443b233c829e5a2e1343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 20 Nov 2013 14:42:05 +0100 Subject: [PATCH] Add ol.style.Text constructor --- src/ol/style/textstyle.js | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/ol/style/textstyle.js diff --git a/src/ol/style/textstyle.js b/src/ol/style/textstyle.js new file mode 100644 index 0000000000..d937db1fdc --- /dev/null +++ b/src/ol/style/textstyle.js @@ -0,0 +1,70 @@ +goog.provide('ol.style.Text'); + + +/** + * @typedef {{font: (string|undefined), + * text: (string|undefined), + * textAlign: (string|undefined), + * textBaseline: (string|undefined)}} + */ +ol.style.TextOptions; + + + +/** + * @constructor + * @param {ol.style.TextOptions} options Options. + */ +ol.style.Text = function(options) { + + /** + * @type {string|undefined} + */ + this.font = options.font; + + /** + * @type {string|undefined} + */ + this.text = options.text; + + /** + * @type {string|undefined} + */ + this.textAlign = options.textAlign; + + /** + * @type {string|undefined} + */ + this.textBaseline = options.textBaseline; + + /** + * @type {number} + */ + this.width = options.width; +}; + + +/** + * @param {ol.style.Text} textStyle1 Text style 1. + * @param {ol.style.Text} textStyle2 Text style 2. + * @return {boolean} Equals. + */ +ol.style.Text.equals = function(textStyle1, textStyle2) { + if (!goog.isNull(textStyle1)) { + if (!goog.isNull(textStyle2)) { + return textStyle1 === textStyle2 || ( + textStyle1.font == textStyle2.font && + textStyle1.text == textStyle2.text && + textStyle1.textAlign == textStyle2.textAlign && + textStyle1.textBaseline == textStyle2.textBaseline); + } else { + return false; + } + } else { + if (!goog.isNull(textStyle2)) { + return false; + } else { + return true; + } + } +};