From b92fdaf9111f151abd55c756b861a7c6780f0a01 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 18 Jan 2013 17:20:10 -0700 Subject: [PATCH] Going with point, line, and polygon symbolizers Separate fill and stroke symbolizers make a nicer API, but less efficient rendering --- src/ol/style/fill.js | 27 --------------------------- src/ol/style/line.js | 31 +++++++++++++++++++++++++++++++ src/ol/style/point.js | 11 +++++++++++ src/ol/style/polygon.js | 35 +++++++++++++++++++++++++++++++++++ src/ol/style/shape.js | 27 +++++++++++++++++---------- src/ol/style/stroke.js | 32 -------------------------------- 6 files changed, 94 insertions(+), 69 deletions(-) delete mode 100644 src/ol/style/fill.js create mode 100644 src/ol/style/line.js create mode 100644 src/ol/style/point.js create mode 100644 src/ol/style/polygon.js delete mode 100644 src/ol/style/stroke.js diff --git a/src/ol/style/fill.js b/src/ol/style/fill.js deleted file mode 100644 index a583b8beff..0000000000 --- a/src/ol/style/fill.js +++ /dev/null @@ -1,27 +0,0 @@ -goog.provide('ol.style.LiteralFill'); - -goog.require('ol.style.LiteralSymbolizer'); - - -/** - * @typedef {{color: (string), - * opacity: (number)}} - */ -ol.style.LiteralFillConfig; - - - -/** - * @constructor - * @implements {ol.style.LiteralSymbolizer} - * @param {ol.style.LiteralFillConfig} config Symbolizer properties. - */ -ol.style.LiteralFill = function(config) { - - /** @type {string} */ - this.color = config.color; - - /** @type {number} */ - this.opacity = config.opacity; - -}; diff --git a/src/ol/style/line.js b/src/ol/style/line.js new file mode 100644 index 0000000000..e3bc7352c7 --- /dev/null +++ b/src/ol/style/line.js @@ -0,0 +1,31 @@ +goog.provide('ol.style.LiteralLine'); + +goog.require('ol.style.LiteralSymbolizer'); + + +/** + * @typedef {{strokeStyle: (string), + * strokeWidth: (number), + * opacity: (number)}} + */ +ol.style.LiteralLineConfig; + + + +/** + * @constructor + * @implements {ol.style.LiteralSymbolizer} + * @param {ol.style.LiteralLineConfig} config Symbolizer properties. + */ +ol.style.LiteralLine = function(config) { + + /** @type {string} */ + this.strokeStyle = config.strokeStyle; + + /** @type {number} */ + this.strokeWidth = config.strokeWidth; + + /** @type {number} */ + this.opacity = config.opacity; + +}; diff --git a/src/ol/style/point.js b/src/ol/style/point.js new file mode 100644 index 0000000000..d15cf89383 --- /dev/null +++ b/src/ol/style/point.js @@ -0,0 +1,11 @@ +goog.provide('ol.style.LiteralPoint'); + +goog.require('ol.style.LiteralSymbolizer'); + + + +/** + * @interface + * @implements {ol.style.LiteralSymbolizer} + */ +ol.style.LiteralPoint = function() {}; diff --git a/src/ol/style/polygon.js b/src/ol/style/polygon.js new file mode 100644 index 0000000000..160cdfa310 --- /dev/null +++ b/src/ol/style/polygon.js @@ -0,0 +1,35 @@ +goog.provide('ol.style.LiteralPolygon'); + +goog.require('ol.style.LiteralSymbolizer'); + + +/** + * @typedef {{fillStyle: (string), + * strokeStyle: (string), + * strokeWidth: (number), + * opacity: (number)}} + */ +ol.style.LiteralPolygonConfig; + + + +/** + * @constructor + * @implements {ol.style.LiteralSymbolizer} + * @param {ol.style.LiteralPolygonConfig} config Symbolizer properties. + */ +ol.style.LiteralPolygon = function(config) { + + /** @type {string} */ + this.fillStyle = config.fillStyle; + + /** @type {string} */ + this.strokeStyle = config.strokeStyle; + + /** @type {number} */ + this.strokeWidth = config.strokeWidth; + + /** @type {number} */ + this.opacity = config.opacity; + +}; diff --git a/src/ol/style/shape.js b/src/ol/style/shape.js index 09ce5a4a8c..a64e46b437 100644 --- a/src/ol/style/shape.js +++ b/src/ol/style/shape.js @@ -1,8 +1,7 @@ goog.provide('ol.style.LiteralShape'); +goog.provide('ol.style.ShapeType'); -goog.require('ol.style.LiteralFill'); -goog.require('ol.style.LiteralStroke'); -goog.require('ol.style.LiteralSymbolizer'); +goog.require('ol.style.LiteralPoint'); /** @@ -16,8 +15,10 @@ ol.style.ShapeType = { /** * @typedef {{type: (ol.style.ShapeType), * size: (number), - * fill: (ol.style.LiteralFill), - * stroke: (ol.style.LiteralStroke)}} + * fillStyle: (string), + * strokeStyle: (string), + * strokeWidth: (number), + * opacity: (number)}} */ ol.style.LiteralShapeConfig; @@ -25,7 +26,7 @@ ol.style.LiteralShapeConfig; /** * @constructor - * @implements {ol.style.LiteralSymbolizer} + * @implements {ol.style.LiteralPoint} * @param {ol.style.LiteralShapeConfig} config Symbolizer properties. */ ol.style.LiteralShape = function(config) { @@ -36,10 +37,16 @@ ol.style.LiteralShape = function(config) { /** @type {number} */ this.size = config.size; - /** @type {ol.style.LiteralFill} */ - this.fill = config.fill; + /** @type {string} */ + this.fillStyle = config.fillStyle; - /** @type {ol.style.LiteralStroke} */ - this.stroke = config.stroke; + /** @type {string} */ + this.strokeStyle = config.strokeStyle; + + /** @type {number} */ + this.strokeWidth = config.strokeWidth; + + /** @type {number} */ + this.opacity = config.opacity; }; diff --git a/src/ol/style/stroke.js b/src/ol/style/stroke.js deleted file mode 100644 index c8ac1a76a2..0000000000 --- a/src/ol/style/stroke.js +++ /dev/null @@ -1,32 +0,0 @@ -goog.provide('ol.style.LiteralStroke'); - -goog.require('ol.style.LiteralSymbolizer'); - - -/** - * @typedef {{width: (number), - * color: (string), - * opacity: (number)}} - */ -ol.style.LiteralStrokeConfig; - - - -/** - * @constructor - * @implements {ol.style.LiteralSymbolizer} - * @param {ol.style.LiteralStrokeConfig} config Symbolizer properties. - */ -ol.style.LiteralStroke = function(config) { - - /** @type {string} */ - this.color = config.color; - - /** @type {number} */ - this.opacity = config.opacity; - - /** @type {number} */ - this.width = config.width; - -}; -