* added stroke, fill and graphic symbolizer properties (all boolean) to
control whether or not to render a stroke, fill and graphic. * added a defaultsPerSymbolizer property to OpenLayers.Style to allow for extending incomplete symbolizers with defaults for stroke, fill or graphic. This also makes Format.SLD read/write round trips possible without modifying empty or incomplete <Stroke/>, <Fill/> and <Graphic/> constructs. r=tschaub (closes #1876) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9278 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -244,21 +244,27 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
* style - {Object}
|
||||
*/
|
||||
drawPoint: function(geometry, style) {
|
||||
var pt = this.getLocalXY(geometry);
|
||||
|
||||
if (style.externalGraphic) {
|
||||
this.drawExternalGraphic(pt, style);
|
||||
} else {
|
||||
this.setCanvasStyle("fill", style);
|
||||
this.canvas.beginPath();
|
||||
this.canvas.arc(pt[0], pt[1], 6, 0, Math.PI*2, true);
|
||||
this.canvas.fill();
|
||||
if(style.graphic !== false) {
|
||||
var pt = this.getLocalXY(geometry);
|
||||
|
||||
this.setCanvasStyle("stroke", style);
|
||||
this.canvas.beginPath();
|
||||
this.canvas.arc(pt[0], pt[1], 6, 0, Math.PI*2, true);
|
||||
this.canvas.stroke();
|
||||
this.setCanvasStyle("reset");
|
||||
if (style.externalGraphic) {
|
||||
this.drawExternalGraphic(pt, style);
|
||||
} else {
|
||||
if(style.fill !== false) {
|
||||
this.setCanvasStyle("fill", style);
|
||||
this.canvas.beginPath();
|
||||
this.canvas.arc(pt[0], pt[1], 6, 0, Math.PI*2, true);
|
||||
this.canvas.fill();
|
||||
}
|
||||
|
||||
if(style.stroke !== false) {
|
||||
this.setCanvasStyle("stroke", style);
|
||||
this.canvas.beginPath();
|
||||
this.canvas.arc(pt[0], pt[1], 6, 0, Math.PI*2, true);
|
||||
this.canvas.stroke();
|
||||
this.setCanvasStyle("reset");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -271,15 +277,17 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
* style - {Object}
|
||||
*/
|
||||
drawLineString: function(geometry, style) {
|
||||
this.setCanvasStyle("stroke", style);
|
||||
this.canvas.beginPath();
|
||||
var start = this.getLocalXY(geometry.components[0]);
|
||||
this.canvas.moveTo(start[0], start[1]);
|
||||
for(var i = 1; i < geometry.components.length; i++) {
|
||||
var pt = this.getLocalXY(geometry.components[i]);
|
||||
this.canvas.lineTo(pt[0], pt[1]);
|
||||
if(style.stroke !== false) {
|
||||
this.setCanvasStyle("stroke", style);
|
||||
this.canvas.beginPath();
|
||||
var start = this.getLocalXY(geometry.components[0]);
|
||||
this.canvas.moveTo(start[0], start[1]);
|
||||
for(var i = 1; i < geometry.components.length; i++) {
|
||||
var pt = this.getLocalXY(geometry.components[i]);
|
||||
this.canvas.lineTo(pt[0], pt[1]);
|
||||
}
|
||||
this.canvas.stroke();
|
||||
}
|
||||
this.canvas.stroke();
|
||||
this.setCanvasStyle("reset");
|
||||
},
|
||||
|
||||
@@ -292,26 +300,30 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
* style - {Object}
|
||||
*/
|
||||
drawLinearRing: function(geometry, style) {
|
||||
this.setCanvasStyle("fill", style);
|
||||
this.canvas.beginPath();
|
||||
var start = this.getLocalXY(geometry.components[0]);
|
||||
this.canvas.moveTo(start[0], start[1]);
|
||||
for(var i = 1; i < geometry.components.length - 1 ; i++) {
|
||||
var pt = this.getLocalXY(geometry.components[i]);
|
||||
this.canvas.lineTo(pt[0], pt[1]);
|
||||
if(style.fill !== false) {
|
||||
this.setCanvasStyle("fill", style);
|
||||
this.canvas.beginPath();
|
||||
var start = this.getLocalXY(geometry.components[0]);
|
||||
this.canvas.moveTo(start[0], start[1]);
|
||||
for(var i = 1; i < geometry.components.length - 1 ; i++) {
|
||||
var pt = this.getLocalXY(geometry.components[i]);
|
||||
this.canvas.lineTo(pt[0], pt[1]);
|
||||
}
|
||||
this.canvas.fill();
|
||||
}
|
||||
this.canvas.fill();
|
||||
|
||||
var oldWidth = this.canvas.lineWidth;
|
||||
this.setCanvasStyle("stroke", style);
|
||||
this.canvas.beginPath();
|
||||
var start = this.getLocalXY(geometry.components[0]);
|
||||
this.canvas.moveTo(start[0], start[1]);
|
||||
for(var i = 1; i < geometry.components.length; i++) {
|
||||
var pt = this.getLocalXY(geometry.components[i]);
|
||||
this.canvas.lineTo(pt[0], pt[1]);
|
||||
if(style.stroke !== false) {
|
||||
var oldWidth = this.canvas.lineWidth;
|
||||
this.setCanvasStyle("stroke", style);
|
||||
this.canvas.beginPath();
|
||||
var start = this.getLocalXY(geometry.components[0]);
|
||||
this.canvas.moveTo(start[0], start[1]);
|
||||
for(var i = 1; i < geometry.components.length; i++) {
|
||||
var pt = this.getLocalXY(geometry.components[i]);
|
||||
this.canvas.lineTo(pt[0], pt[1]);
|
||||
}
|
||||
this.canvas.stroke();
|
||||
}
|
||||
this.canvas.stroke();
|
||||
this.setCanvasStyle("reset");
|
||||
},
|
||||
|
||||
@@ -345,6 +357,10 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
* style - {Object}
|
||||
*/
|
||||
drawText: function(location, style) {
|
||||
style = OpenLayers.Util.extend({
|
||||
fontColor: "#000000",
|
||||
labelAlign: "cm"
|
||||
}, style);
|
||||
var pt = this.getLocalXY(location);
|
||||
|
||||
this.setCanvasStyle("reset");
|
||||
|
||||
@@ -661,12 +661,20 @@ OpenLayers.Renderer.Elements = OpenLayers.Class(OpenLayers.Renderer, {
|
||||
OpenLayers.Util.applyDefaults(style, this.minimumSymbolizer);
|
||||
|
||||
var options = {
|
||||
'isFilled': true,
|
||||
'isStroked': !!style.strokeWidth
|
||||
'isFilled': style.fill === undefined ?
|
||||
true :
|
||||
style.fill,
|
||||
'isStroked': style.stroke === undefined ?
|
||||
!!style.strokeWidth :
|
||||
style.stroke
|
||||
};
|
||||
var drawn;
|
||||
switch (geometry.CLASS_NAME) {
|
||||
case "OpenLayers.Geometry.Point":
|
||||
if(style.graphic === false) {
|
||||
options.isFilled = false;
|
||||
options.isStroked = false;
|
||||
}
|
||||
drawn = this.drawPoint(node, geometry);
|
||||
break;
|
||||
case "OpenLayers.Geometry.LineString":
|
||||
|
||||
@@ -254,7 +254,10 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
|
||||
var widthFactor = 1;
|
||||
var pos;
|
||||
if (node._geometryClass == "OpenLayers.Geometry.Point" && r) {
|
||||
if (style.externalGraphic) {
|
||||
node.style.visibility = "";
|
||||
if (style.graphic === false) {
|
||||
node.style.visibility = "hidden";
|
||||
} else if (style.externalGraphic) {
|
||||
pos = this.getPosition(node);
|
||||
|
||||
if (style.graphicTitle) {
|
||||
|
||||
Reference in New Issue
Block a user