Changeset 5312
- Timestamp:
- 12/01/07 06:04:26 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/ahocevar/styles/lib/OpenLayers/Renderer/Elements.js
r5273 r5312 85 85 * Method: getNodeType 86 86 * This function is in charge of asking the specific renderer which type 87 * of node to create for the given geometry and style. All geometries88 * in an Elements-based renderer consist of one node and some89 * attributes. We have the nodeFactory() function which creates a node90 * for us, but it takes a 'type' as input, and that is precisely what91 * t his function tells us.87 * of node to create for the given geometry. All geometries in an 88 * Elements-based renderer consist of one node and some attributes. We 89 * have the nodeFactory() function which creates a node for us, but it 90 * takes a 'type' as input, and that is precisely what this function 91 * tells us. 92 92 * 93 93 * Parameters: 94 94 * geometry - {<OpenLayers.Geometry>} 95 * style - {Object}96 95 * 97 96 * Returns: 98 97 * {String} The corresponding node type for the specified geometry 99 98 */ 100 getNodeType: function(geometry , style) { },99 getNodeType: function(geometry) { }, 101 100 102 101 /** … … 125 124 if (style.display != "none") { 126 125 //first we create the basic node and add it to the root 127 var nodeType = this.getNodeType(geometry , style);126 var nodeType = this.getNodeType(geometry); 128 127 var node = this.nodeFactory(geometry.id, nodeType); 129 128 node._featureId = featureId; … … 134 133 node = this.drawGeometryNode(node, geometry); 135 134 this.root.appendChild(node); 136 this.postDraw(node);137 135 } else { 138 136 node = OpenLayers.Util.getElement(geometry.id); … … 192 190 return this.setStyle(node, style, options, geometry); 193 191 }, 194 195 /**196 * Method: postDraw197 * Things that have do be done after the geometry node is appended198 * to its parent node. To be overridden by subclasses.199 *200 * Parameters:201 * node - {DOMElement}202 */203 postDraw: function(node) {},204 192 205 193 /** sandbox/ahocevar/styles/lib/OpenLayers/Renderer/SVG.js
r5272 r5312 148 148 * Parameters: 149 149 * geometry - {<OpenLayers.Geometry>} 150 * style - {Object}151 150 * 152 151 * Returns: 153 152 * {String} The corresponding node type for the specified geometry 154 153 */ 155 getNodeType: function(geometry , style) {154 getNodeType: function(geometry) { 156 155 var nodeType = null; 157 156 switch (geometry.CLASS_NAME) { 158 157 case "OpenLayers.Geometry.Point": 159 nodeType = style.externalGraphic ? "image" :"circle";158 nodeType = "circle"; 160 159 break; 161 160 case "OpenLayers.Geometry.Rectangle": … … 198 197 if (node._geometryClass == "OpenLayers.Geometry.Point") { 199 198 if (style.externalGraphic) { 199 // remove old node 200 var id = node.getAttributeNS(null, "id"); 200 201 var x = parseFloat(node.getAttributeNS(null, "cx")); 201 202 var y = parseFloat(node.getAttributeNS(null, "cy")); 203 var _featureId = node._featureId; 204 var _geometryClass = node._geometryClass; 205 var _style = node._style; 202 206 207 // create new image node 208 node = this.createNode("image", id); 209 node._featureId = _featureId; 210 node._geometryClass = _geometryClass; 211 node._style = _style; 212 213 // now style the new node 203 214 if (style.graphicWidth && style.graphicHeight) { 204 215 node.setAttributeNS(null, "preserveAspectRatio", "none"); … … 212 223 var yOffset = (style.graphicYOffset != undefined) ? 213 224 style.graphicYOffset : -(0.5 * height); 214 215 225 var opacity = style.graphicOpacity || style.fillOpacity; 216 226 sandbox/ahocevar/styles/lib/OpenLayers/Renderer/VML.js
r5278 r5312 106 106 /** 107 107 * Method: getNodeType 108 * Get the noode type for a geometry and style 109 * 110 * Parameters: 111 * geometry - {<OpenLayers.Geometry>} 112 * style - {Object} 108 * Get the noode type for a geometry 109 * 110 * Parameters: 111 * geometry - {<OpenLayers.Geometry>} 113 112 * 114 113 * Returns: 115 114 * {String} The corresponding node type for the specified geometry 116 115 */ 117 getNodeType: function(geometry , style) {116 getNodeType: function(geometry) { 118 117 var nodeType = null; 119 118 switch (geometry.CLASS_NAME) { 120 119 case "OpenLayers.Geometry.Point": 121 nodeType = style.externalGraphic ? "v:rect" :"v:oval";120 nodeType = "v:oval"; 122 121 break; 123 122 case "OpenLayers.Geometry.Rectangle": … … 155 154 if (node._geometryClass == "OpenLayers.Geometry.Point") { 156 155 if (style.externalGraphic) { 156 // remove old node 157 var id = node.id; 158 var _featureId = node._featureId; 159 var _geometryClass = node._geometryClass; 160 var _style = node._style; 161 162 // create new image node 163 node = this.createNode("v:rect", id); 164 var fill = this.createNode("v:fill", id+"_image"); 165 node.appendChild(fill); 166 node._featureId = _featureId; 167 node._geometryClass = _geometryClass; 168 node._style = _style; 169 170 fill.src = style.externalGraphic; 171 fill.type = "frame"; 172 node.style.flip = "y"; 173 174 if (!(style.graphicWidth && style.graphicHeight)) { 175 fill.aspect = "atmost"; 176 } 177 178 // now style the new node 157 179 var width = style.graphicWidth || style.graphicHeight; 158 180 var height = style.graphicHeight || style.graphicWidth; … … 171 193 node.style.height = height; 172 194 173 // modify style/options for fill and strokestyling below195 // modify fill style for rect styling below 174 196 style.fillColor = "none"; 175 options.isStroked = false;197 style.strokeColor = "none"; 176 198 177 199 } else { … … 195 217 if (!fill) { 196 218 fill = this.createNode('v:fill', node.id + "_fill"); 197 198 if (style.fillOpacity) {199 fill.setAttribute("opacity", style.fillOpacity);200 }201 202 if (node._geometryClass == "OpenLayers.Geometry.Point" &&203 style.externalGraphic) {204 205 // override fillOpacity206 if (style.graphicOpacity) {207 fill.setAttribute("opacity", style.graphicOpacity);208 }209 210 fill.setAttribute("src", style.externalGraphic);211 fill.setAttribute("type", "frame");212 node.style.flip = "y";213 214 if (!(style.graphicWidth && style.graphicHeight)) {215 fill.aspect = "atmost";216 }217 }218 219 node.appendChild(fill); 220 } 221 // if graphicOpacity is set use it in priority for external graphic 222 if (node._geometryClass == "OpenLayers.Geometry.Point" && 223 style.externalGraphic && 224 style.graphicOpacity) { 225 fill.setAttribute("opacity", style.graphicOpacity); 226 } else if (style.fillOpacity) { 227 fill.setAttribute("opacity", style.fillOpacity); 219 228 } 220 229 } … … 248 257 return node; 249 258 }, 250 251 /**252 * Method: postDraw253 * Some versions of Internet Explorer seem to be unable to set fillcolor254 * and strokecolor to "none" correctly before the fill node is appended to255 * a visible vml node. This method takes care of that and sets fillcolor256 * and strokecolor again if needed.257 *258 * Parameters:259 * node - {DOMElement}260 */261 postDraw: function(node) {262 var fillColor = node._style.fillColor;263 var strokeColor = node._style.strokeColor;264 if (fillColor == "none" && node.getAttribute("fillcolor") != "none") {265 node.setAttribute("fillcolor", fillColor);266 }267 if (strokeColor == "none" &&268 node.getAttribute("strokecolor") != "none") {269 node.setAttribute("strokecolor", strokeColor)270 }271 },272 273 259 274 260 /**
