Stroke style of features can now be specified. Both SVG's

stroke-dasharray and VML's dashstyle properties are allowed in the new 
strokeDashstyle symbolizer property. For VML, which does not support 
custom dash styles, one of the 5 matching pre-defined dash styles will 
be guessed. The patch also adds support for the stroke-dasharray 
property in SLD. r=crschmidt (closes #1126)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@7673 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2008-08-01 21:56:17 +00:00
parent 7148b10123
commit 9588f25ce5
9 changed files with 119 additions and 5 deletions
+36 -3
View File
@@ -286,6 +286,11 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
node.setAttributeNS(null, "stroke-opacity", style.strokeOpacity);
node.setAttributeNS(null, "stroke-width", style.strokeWidth * widthFactor);
node.setAttributeNS(null, "stroke-linecap", style.strokeLinecap);
// Hard-coded linejoin for now, to make it look the same as in VML.
// There is no strokeLinejoin property yet for symbolizers.
node.setAttributeNS(null, "stroke-linejoin", "round");
node.setAttributeNS(null, "stroke-dasharray", this.dashStyle(style,
widthFactor));
} else {
node.setAttributeNS(null, "stroke", "none");
}
@@ -300,6 +305,37 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
return node;
},
/**
* Method: dashStyle
*
* Parameters:
* style - {Object}
* widthFactor - {Number}
*
* Returns:
* {String} A SVG compliant 'stroke-dasharray' value
*/
dashStyle: function(style, widthFactor) {
var w = style.strokeWidth * widthFactor;
switch (style.strokeDashstyle) {
case 'solid':
return 'none';
case 'dot':
return [1, 4 * w].join();
case 'dash':
return [4 * w, 4 * w].join();
case 'dashdot':
return [4 * w, 4 * w, 1, 4 * w].join();
case 'longdash':
return [8 * w, 4 * w].join();
case 'longdashdot':
return [8 * w, 4 * w, 1, 4 * w].join();
default:
return style.strokeDashstyle.replace(/ /g, ",");
}
},
/**
* Method: createNode
*
@@ -632,9 +668,6 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
}
node.setAttributeNS(null, "points", points);
// Hard-coded linejoin for now, to make it look the same as in VML.
// There is no strokeLinejoin property yet for symbolizers.
node.setAttributeNS(null, "stroke-linejoin", "round");
var width = symbolExtent.getWidth();
var height = symbolExtent.getHeight();