Ticket #1126: 1126-r7654-A0.patch
| File 1126-r7654-A0.patch, 10.1 kB (added by ahocevar, 3 weeks ago) |
|---|
-
tests/Renderer/VML.html
old new 370 370 t.ok(r.symbolCache["-square"], "Symbol has been cached correctly."); 371 371 372 372 } 373 374 function test_vml_dashstyle(t) { 375 if (!OpenLayers.Renderer.VML.prototype.supported()) { 376 t.plan(0); 377 return; 378 } 373 379 380 t.plan(5); 381 382 var r = new OpenLayers.Renderer.VML(document.body); 383 384 t.eq(r.dashStyle({strokeDashstyle: "1 4"}), "dot", "dot pattern recognized correctly."); 385 t.eq(r.dashStyle({strokeDashstyle: "4 4"}), "dash", "dash pattern recognized correctly."); 386 t.eq(r.dashStyle({strokeDashstyle: "8 4"}), "longdash", "longdash pattern recognized correctly."); 387 t.eq(r.dashStyle({strokeDashstyle: "4 4 1 4"}), "dashdot", "dashdot pattern recognized correctly."); 388 t.eq(r.dashStyle({strokeDashstyle: "8 4 1 4"}), "longdashdot", "longdashdot pattern recognized correctly."); 389 } 390 374 391 </script> 375 392 </head> 376 393 <body> -
tests/Renderer/SVG.html
old new 405 405 t.ok(r.symbolSize["-square"], "Symbol size cached correctly."); 406 406 } 407 407 408 function test_svg_dashstyle(t) { 409 if (!OpenLayers.Renderer.SVG.prototype.supported()) { 410 t.plan(0); 411 return; 412 } 413 414 t.plan(5); 415 416 var r = new OpenLayers.Renderer.SVG(document.body); 417 418 t.eq(r.dashStyle({strokeWidth: 1, strokeDashstyle: "dot"}, 1), "1,4", "dot dasharray created correctly"); 419 t.eq(r.dashStyle({strokeWidth: 1, strokeDashstyle: "dash"}, 1), "4,4", "dash dasharray created correctly"); 420 t.eq(r.dashStyle({strokeWidth: 1, strokeDashstyle: "longdash"}, 1), "8,4", "longdash dasharray created correctly"); 421 t.eq(r.dashStyle({strokeWidth: 1, strokeDashstyle: "dashdot"}, 1), "4,4,1,4", "dashdot dasharray created correctly"); 422 t.eq(r.dashStyle({strokeWidth: 1, strokeDashstyle: "longdashdot"}, 1), "8,4,1,4", "dashdot dasharray created correctly"); 423 } 424 408 425 </script> 409 426 </head> 410 427 <body> -
lib/OpenLayers/Format/SLD/v1.js
old new 52 52 strokeColor: "#000000", 53 53 strokeOpacity: 1, 54 54 strokeWidth: 1, 55 strokeDashstyle: "solid", 55 56 pointRadius: 3, 56 57 graphicName: "square" 57 58 }, … … 293 294 "stroke-opacity": "strokeOpacity", 294 295 "stroke-width": "strokeWidth", 295 296 "stroke-linecap": "strokeLinecap", 297 "stroke-dasharray": "strokeDashstyle", 296 298 "fill": "fillColor", 297 299 "fill-opacity": "fillOpacity", 298 300 "font-family": "fontFamily", -
lib/OpenLayers/Feature/Vector.js
old new 308 308 * - strokeColor: "#ee9900", 309 309 * - strokeOpacity: 1, 310 310 * - strokeWidth: 1, 311 * - strokeLinecap: "round", 311 * - strokeLinecap: "round", [butt | round | square] 312 * - strokeDashstyle: "solid", [dot | dash | dashdot | longdash | longdashdot | solid] 312 313 * - hoverStrokeColor: "red", 313 314 * - hoverStrokeOpacity: 1, 314 315 * - hoverStrokeWidth: 0.2, … … 339 340 strokeOpacity: 1, 340 341 strokeWidth: 1, 341 342 strokeLinecap: "round", 343 strokeDashstyle: "solid", 342 344 hoverStrokeColor: "red", 343 345 hoverStrokeOpacity: 1, 344 346 hoverStrokeWidth: 0.2, … … 357 359 strokeOpacity: 1, 358 360 strokeWidth: 2, 359 361 strokeLinecap: "round", 362 strokeDashstyle: "solid", 360 363 hoverStrokeColor: "red", 361 364 hoverStrokeOpacity: 1, 362 365 hoverStrokeWidth: 0.2, … … 375 378 strokeOpacity: 1, 376 379 strokeLinecap: "round", 377 380 strokeWidth: 4, 381 strokeDashstyle: "solid", 378 382 hoverStrokeColor: "red", 379 383 hoverStrokeOpacity: 1, 380 384 hoverStrokeWidth: 0.2, -
lib/OpenLayers/Renderer/Elements.js
old new 347 347 minimumSymbolizer: { 348 348 strokeLinecap: "round", 349 349 strokeOpacity: 1, 350 strokeDashstyle: "solid", 350 351 fillOpacity: 1, 351 352 pointRadius: 0 352 353 }, -
lib/OpenLayers/Renderer/VML.js
old new 286 286 } 287 287 stroke.setAttribute("opacity", style.strokeOpacity); 288 288 stroke.setAttribute("endcap", !style.strokeLinecap || style.strokeLinecap == 'butt' ? 'flat' : style.strokeLinecap); 289 stroke.setAttribute("dashstyle", this.dashStyle(style)); 289 290 } 290 291 291 292 if (style.cursor != "inherit" && style.cursor != null) { … … 455 456 node.coordsize = scaledBox.getWidth()+ " " + scaledBox.getHeight(); 456 457 } 457 458 }, 459 460 /** 461 * Method: dashStyle 462 * 463 * Parameters: 464 * style - {Object} 465 * 466 * Returns: 467 * {String} A VML compliant 'stroke-dasharray' value 468 */ 469 dashStyle: function(style) { 470 var dash = style.strokeDashstyle; 471 switch (dash) { 472 case 'solid': 473 return dash; 474 case 'dot': 475 case 'dash': 476 case 'dashdot': 477 case 'longdash': 478 case 'longdashdot': 479 default: 480 // very basic guessing of dash style patterns 481 var parts = dash.split(/[ ,]/); 482 if (parts.length == 2) { 483 if (1*parts[0] >= 2*parts[1]) { 484 return "longdash"; 485 } 486 return (parts[0] == 1 || parts[1] == 1) ? "dot" : "dash"; 487 } else if (parts.length == 4) { 488 return (1*parts[0] >= 2*parts[1]) ? "longdashdot" : 489 "dashdot" 490 } 491 return "solid"; 492 } 493 }, 458 494 459 495 /** 460 496 * Method: createNode -
lib/OpenLayers/Renderer/SVG.js
old new 273 273 node.setAttributeNS(null, "stroke-opacity", style.strokeOpacity); 274 274 node.setAttributeNS(null, "stroke-width", style.strokeWidth * widthFactor); 275 275 node.setAttributeNS(null, "stroke-linecap", style.strokeLinecap); 276 // Hard-coded linejoin for now, to make it look the same as in VML. 277 // There is no strokeLinejoin property yet for symbolizers. 278 node.setAttributeNS(null, "stroke-linejoin", "round"); 279 node.setAttributeNS(null, "stroke-dasharray", this.dashStyle(style, 280 widthFactor)); 276 281 } else { 277 282 node.setAttributeNS(null, "stroke", "none"); 278 283 } … … 288 293 }, 289 294 290 295 /** 296 * Method: dashStyle 297 * 298 * Parameters: 299 * style - {Object} 300 * widthFactor - {Number} 301 * 302 * Returns: 303 * {String} A SVG compliant 'stroke-dasharray' value 304 */ 305 dashStyle: function(style, widthFactor) { 306 var w = style.strokeWidth * widthFactor; 307 308 switch (style.strokeDashstyle) { 309 case 'solid': 310 return 'none'; 311 case 'dot': 312 return [1, 4 * w].join(); 313 case 'dash': 314 return [4 * w, 4 * w].join(); 315 case 'dashdot': 316 return [4 * w, 4 * w, 1, 4 * w].join(); 317 case 'longdash': 318 return [8 * w, 4 * w].join(); 319 case 'longdashdot': 320 return [8 * w, 4 * w, 1, 4 * w].join(); 321 default: 322 return style.strokeDashstyle.replace(/ /g, ","); 323 } 324 }, 325 326 /** 291 327 * Method: createNode 292 328 * 293 329 * Parameters: … … 619 655 } 620 656 621 657 node.setAttributeNS(null, "points", points); 622 // Hard-coded linejoin for now, to make it look the same as in VML.623 // There is no strokeLinejoin property yet for symbolizers.624 node.setAttributeNS(null, "stroke-linejoin", "round");625 658 626 659 var width = symbolExtent.getWidth(); 627 660 var height = symbolExtent.getHeight(); -
examples/vector-features.html
old new 38 38 var style_green = { 39 39 strokeColor: "#00FF00", 40 40 strokeWidth: 3, 41 strokeDashstyle: "dashdot", 41 42 pointRadius: 6, 42 43 pointerEvents: "visiblePainted" 43 44 }; … … 74 75 // create a line feature from a list of points 75 76 var pointList = []; 76 77 var newPoint = point; 77 for(var p=0; p< 5; ++p) {78 for(var p=0; p<15; ++p) { 78 79 newPoint = new OpenLayers.Geometry.Point(newPoint.x + Math.random(1), 79 80 newPoint.y + Math.random(1)); 80 81 pointList.push(newPoint); -
examples/tasmania/sld-tasmania.xml
old new 581 581 <sld:CssParameter name="stroke-width"> 582 582 <ogc:Literal>1</ogc:Literal> 583 583 </sld:CssParameter> 584 <sld:CssParameter name="stroke-dasharray"> 585 <ogc:Literal>3 5 1 5</ogc:Literal> 586 </sld:CssParameter> 584 587 </sld:Stroke> 585 588 </sld:PolygonSymbolizer> 586 589 </sld:Rule>
