Ticket #1126: strokeDash.01.patch
| File strokeDash.01.patch, 7.3 kB (added by fredj, 10 months ago) |
|---|
-
lib/OpenLayers/Feature/Vector.js
old new 248 248 * - strokeColor: "#ee9900", 249 249 * - strokeOpacity: 1, 250 250 * - strokeWidth: 1, 251 * - strokeLinecap: "round", 251 * - strokeLinecap: "round", [butt | round | square] 252 * - strokeDashstyle: "solid", [dot | dash | dashdot | longdash | longdashdot | solid] 252 253 * - hoverStrokeColor: "red", 253 254 * - hoverStrokeOpacity: 1, 254 255 * - hoverStrokeWidth: 0.2, … … 276 277 strokeOpacity: 1, 277 278 strokeWidth: 1, 278 279 strokeLinecap: "round", 280 strokeDashstyle: "solid", 279 281 hoverStrokeColor: "red", 280 282 hoverStrokeOpacity: 1, 281 283 hoverStrokeWidth: 0.2, … … 293 295 strokeOpacity: 1, 294 296 strokeWidth: 2, 295 297 strokeLinecap: "round", 298 strokeDashstyle: "solid", 296 299 hoverStrokeColor: "red", 297 300 hoverStrokeOpacity: 1, 298 301 hoverStrokeWidth: 0.2, … … 311 314 strokeOpacity: 1, 312 315 strokeLinecap: "round", 313 316 strokeWidth: 4, 317 strokeDashstyle: "solid", 314 318 hoverStrokeColor: "red", 315 319 hoverStrokeOpacity: 1, 316 320 hoverStrokeWidth: 0.2, -
lib/OpenLayers/Renderer/VML.js
old new 248 248 } 249 249 stroke.setAttribute("opacity", style.strokeOpacity); 250 250 stroke.setAttribute("endcap", !style.strokeLinecap || style.strokeLinecap == 'butt' ? 'flat' : style.strokeLinecap); 251 stroke.setAttribute("dashstyle", style.strokeDashstyle); 251 252 } 252 253 253 254 if (style.cursor) { -
lib/OpenLayers/Renderer/SVG.js
old new 248 248 node.setAttributeNS(null, "stroke-opacity", style.strokeOpacity); 249 249 node.setAttributeNS(null, "stroke-width", style.strokeWidth); 250 250 node.setAttributeNS(null, "stroke-linecap", style.strokeLinecap); 251 node.setAttributeNS(null, "stroke-dasharray", this.dashStyle(style)); 251 252 } else { 252 253 node.setAttributeNS(null, "stroke", "none"); 253 254 } … … 263 264 }, 264 265 265 266 /** 267 * Method: dashStyle 268 * 269 * Parameters: 270 * style - {Object} 271 * 272 * Returns: 273 * {String} A SVG compliant 'stroke-dasharray' value 274 */ 275 dashStyle: function(style) { 276 var w = style.strokeWidth; 277 278 switch (style.strokeDashstyle) { 279 case 'dot': 280 return [w, 2 * w].join(); 281 case 'dash': 282 return [4 * w, 4 * w].join(); 283 case 'dashdot': 284 return [5 * w, 5 * w, w, 5 * w].join(); 285 case 'longdash': 286 return [8 * w, 5 * w].join(); 287 case 'longdashdot': 288 return [8 * w, 5 * w, w, 5 * w].join(); 289 case 'solid': 290 default: 291 return 'none'; 292 } 293 }, 294 295 /** 266 296 * Method: createNode 267 297 * 268 298 * Parameters: -
examples/vector-features.html
old new 21 21 * Layer style 22 22 */ 23 23 // we want opaque external graphics and non-opaque internal graphics 24 var layer_style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']); 25 layer_style.fillOpacity = 0.2; 26 layer_style.graphicOpacity = 1; 24 var layer_style = OpenLayers.Util.applyDefaults({ 25 fillOpacity: 0.2, 26 graphicOpacity: 1 27 }, OpenLayers.Feature.Vector.style['default']); 27 28 28 29 /* 29 30 * Blue style 30 31 */ 31 var style_blue = OpenLayers.Util.extend({}, layer_style); 32 style_blue.strokeColor = "blue"; 33 style_blue.fillColor = "blue"; 32 var style_blue = OpenLayers.Util.applyDefaults({ 33 strokeColor: "blue", 34 fillColor: "blue" 35 }, layer_style); 34 36 35 37 /* 36 38 * Green style 37 39 */ 38 var style_green = {40 var style_green = OpenLayers.Util.applyDefaults({ 39 41 strokeColor: "#00FF00", 40 42 strokeOpacity: 1, 43 strokeDashstyle: "dot", 41 44 strokeWidth: 3, 42 45 pointRadius: 6, 43 pointerEvents: "visiblePainted"44 } ;46 fillColor: "red" 47 }, OpenLayers.Feature.Vector.style['default']); 45 48 49 var marker_size = new OpenLayers.Size(24, 20); 50 46 51 /* 47 52 * Mark style 48 53 */ 49 var style_mark = OpenLayers.Util.extend({ }, OpenLayers.Feature.Vector.style['default']);50 // each of the three lines below means the same, if only one of51 // them is active: the image will have a size of 24px, and the52 // aspect ratio will be kept53 // style_mark.pointRadius = 12;54 // style_mark.graphicHeight = 24;55 // style_mark.graphicWidth = 24;54 var style_mark = OpenLayers.Util.extend({ 55 // each of the three lines below means the same, if only one of 56 // them is active: the image will have a size of 24px, and the 57 // aspect ratio will be kept 58 // pointRadius: (marker_size.w / 2), 59 // graphicHeight: marker_size.h, 60 // graphicWidth: marker_size.w, 56 61 57 // if graphicWidth and graphicHeight are both set, the aspect ratio 58 // of the image will be ignored 59 style_mark.graphicWidth = 24; 60 style_mark.graphicHeight = 20; 61 style_mark.graphicXOffset = -(style_mark.graphicWidth/2); // this is the default value 62 style_mark.graphicYOffset = -style_mark.graphicHeight; 63 style_mark.externalGraphic = "../img/marker.png"; 62 // if graphicWidth and graphicHeight are both set, the aspect ratio 63 // of the image will be ignored 64 graphicWidth: marker_size.w, 65 graphicHeight: marker_size.h, 66 graphicXOffset: - (marker_size.w / 2), // this is the default value 67 graphicYOffset: - marker_size.h, 68 externalGraphic: "../img/marker.png" 69 }, OpenLayers.Feature.Vector.style['default']); 70 64 71 65 72 var vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry", {style: layer_style}); 66 73 … … 75 82 // create a line feature from a list of points 76 83 var pointList = []; 77 84 var newPoint = point; 78 for(var p=0; p< 5; ++p) {85 for(var p=0; p<15; ++p) { 79 86 newPoint = new OpenLayers.Geometry.Point(newPoint.x + Math.random(1), 80 87 newPoint.y + Math.random(1)); 81 88 pointList.push(newPoint);
