Adding point, line, polygon, text, and raster symbolizer constructors. This paves the way for rendering multiple symbolizers per rule. The SLD parser now successfully round-trips documents with multiple symbolizers and multiple FeatureTypeStyle elements (through the symbolizer zIndex property). The Style2 (yes, ack) constructor is used to represent a collection of rules with multiple symbolizers. Style2 objects are currently only used by the SLD parser if the multipleSymbolizer property is set to true. Future enhancements to the renderers can be made to account for multiple symbolizers. r=ahocevar (closes #2760).
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10560 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
106
lib/OpenLayers/Style2.js
Normal file
106
lib/OpenLayers/Style2.js
Normal file
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @requires OpenLayers/Rule.js
|
||||
* @requires OpenLayers/Symbolizer/Point.js
|
||||
* @requires OpenLayers/Symbolizer/Line.js
|
||||
* @requires OpenLayers/Symbolizer/Polygon.js
|
||||
* @requires OpenLayers/Symbolizer/Text.js
|
||||
* @requires OpenLayers/Symbolizer/Raster.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Style2
|
||||
* This class represents a collection of rules for rendering features.
|
||||
*/
|
||||
OpenLayers.Style2 = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* Property: id
|
||||
* {String} A unique id for this session.
|
||||
*/
|
||||
id: null,
|
||||
|
||||
/**
|
||||
* APIProperty: name
|
||||
* {String} Style identifier.
|
||||
*/
|
||||
name: null,
|
||||
|
||||
/**
|
||||
* APIProperty: title
|
||||
* {String} Title of this style.
|
||||
*/
|
||||
title: null,
|
||||
|
||||
/**
|
||||
* APIProperty: description
|
||||
* {String} Description of this style.
|
||||
*/
|
||||
description: null,
|
||||
|
||||
/**
|
||||
* APIProperty: layerName
|
||||
* {<String>} Name of the layer that this style belongs to, usually
|
||||
* according to the NamedLayer attribute of an SLD document.
|
||||
*/
|
||||
layerName: null,
|
||||
|
||||
/**
|
||||
* APIProperty: isDefault
|
||||
* {Boolean}
|
||||
*/
|
||||
isDefault: false,
|
||||
|
||||
/**
|
||||
* APIProperty: rules
|
||||
* {Array(<OpenLayers.Rule>)} Collection of rendering rules.
|
||||
*/
|
||||
rules: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Style2
|
||||
* Creates a style representing a collection of rendering rules.
|
||||
*
|
||||
* Parameters:
|
||||
* config - {Object} An object containing properties to be set on the
|
||||
* style. Any documented properties may be set at construction.
|
||||
*
|
||||
* Return:
|
||||
* {<OpenLayers.Style2>} A new style object.
|
||||
*/
|
||||
initialize: function(config) {
|
||||
OpenLayers.Util.extend(this, config);
|
||||
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
* nullify references to prevent circular references and memory leaks
|
||||
*/
|
||||
destroy: function() {
|
||||
for (var i=0, len=this.rules.length; i<len; i++) {
|
||||
this.rules[i].destroy();
|
||||
}
|
||||
delete this.rules;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: clone
|
||||
* Clones this style.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Style2>} Clone of this style.
|
||||
*/
|
||||
clone: function() {
|
||||
var config = OpenLayers.Util.extend({}, this);
|
||||
// clone rules
|
||||
if (this.rules) {
|
||||
config.rules = [];
|
||||
for (var i=0, len=this.rules.length; i<len; ++i) {
|
||||
config.rules.push(this.rules[i].clone());
|
||||
}
|
||||
}
|
||||
return new OpenLayers.Style2(config);
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Style2"
|
||||
});
|
||||
Reference in New Issue
Block a user