Changeset 7781
- Timestamp:
- 08/18/08 08:53:06 (4 months ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Layer/Vector.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Renderer.js (modified) (1 diff)
- trunk/openlayers/lib/OpenLayers/Renderer/Elements.js (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Layer/Vector.js
r7708 r7781 155 155 156 156 /** 157 * APIProperty: yOrdering158 * { String} Whether or not externalGraphic y-ordering is enabled on this159 * layer. Default is false.160 */ 161 yOrdering: false,162 157 * APIProperty: rendererOptions 158 * {Object} Options for the renderer. See {<OpenLayers.Renderer>} for 159 * supported options. 160 */ 161 rendererOptions: null, 162 163 163 /** 164 164 * APIProperty: geometryType … … 266 266 var rendererClass = OpenLayers.Renderer[this.renderers[i]]; 267 267 if (rendererClass && rendererClass.prototype.supported()) { 268 this.renderer = new rendererClass(this.div, this.yOrdering); 268 this.renderer = new rendererClass(this.div, 269 this.rendererOptions); 269 270 break; 270 271 } trunk/openlayers/lib/OpenLayers/Renderer.js
r7627 r7781 57 57 * Parameters: 58 58 * containerID - {<String>} 59 */ 60 initialize: function(containerID) { 59 * options - {Object} options for this renderer. See sublcasses for 60 * supported options. 61 */ 62 initialize: function(containerID, options) { 61 63 this.container = OpenLayers.Util.getElement(containerID); 62 64 }, trunk/openlayers/lib/OpenLayers/Renderer/Elements.js
r7712 r7781 71 71 * Parameters: 72 72 * newNode - {DOMElement} The new node to be inserted. 73 * root - {DOMElement} The root node from which to insert the new node. 74 */ 75 insert: function(newNode, root) { 73 * 74 * Returns 75 * {DOMElement} the node before which we should insert our newNode, or 76 * null if newNode can just be appended. 77 */ 78 insert: function(newNode) { 79 // If the node is known to the indexer, remove it so we can 80 // recalculate where it should go. 81 if (this.exists(newNode)) { 82 this.remove(newNode); 83 } 84 76 85 var nodeId = newNode.id; 77 86 … … 85 94 middle = parseInt((leftIndex + rightIndex) / 2); 86 95 87 var nextId = this.order[middle]; 88 var nextNode = OpenLayers.Util.getElement(nextId); 89 90 var placement = this.compare(this, newNode, nextNode); 96 var placement = this.compare(this, newNode, 97 OpenLayers.Util.getElement(this.order[middle])); 91 98 92 99 if (placement > 0) { … … 101 108 102 109 // If the new node should be before another in the index 103 // order, insert the new node before the next; else, lets just104 // append the new one on the end, making it the highest in the index order.110 // order, return the node before which we have to insert the new one; 111 // else, return null to indicate that the new node can be appended. 105 112 var nextIndex = rightIndex + 1; 106 if (nextIndex < this.order.length) { 107 var nextNode = OpenLayers.Util.getElement(this.order[nextIndex]); 108 root.insertBefore(newNode, nextNode); 109 } else { 110 root.appendChild(newNode); 111 } 113 return nextIndex < this.order.length ? 114 OpenLayers.Util.getElement(this.order[nextIndex]) : null; 112 115 }, 113 116 … … 344 347 * Property: Indexer 345 348 * {<OpenLayers.ElementIndexer>} An instance of OpenLayers.ElementsIndexer 346 * created upon initialization. 349 * created upon initialization if the zIndexing or yOrdering options 350 * passed to this renderer's constructor are set to true. 347 351 */ 348 352 indexer: null, … … 371 375 * Parameters: 372 376 * containerID - {String} 373 * yOrdering - {Boolean} Whether or not y-ordering is enabled. 374 */ 375 initialize: function(containerID, yOrdering) { 377 * options - {Object} options for this renderer. Supported options are: 378 * * yOrdering - {Boolean} Whether to use y-ordering 379 * * zIndexing - {Boolean} Whether to use z-indexing. Will be ignored 380 * if yOrdering is set to true. 381 */ 382 initialize: function(containerID, options) { 376 383 OpenLayers.Renderer.prototype.initialize.apply(this, arguments); 377 384 … … 382 389 this.container.appendChild(this.rendererRoot); 383 390 384 this.indexer = new OpenLayers.ElementsIndexer(yOrdering); 391 if(options && (options.zIndexing || options.yOrdering)) { 392 this.indexer = new OpenLayers.ElementsIndexer(options.yOrdering); 393 } 385 394 }, 386 395 … … 409 418 } 410 419 } 411 this.indexer.clear(); 420 if (this.indexer) { 421 this.indexer.clear(); 422 } 412 423 }, 413 424 … … 498 509 newNode = this.drawGeometryNode(newNode, geometry, style); 499 510 500 // I f the node is known to the indexer, remove it so we can501 // recalculate where it should go.502 if (this.indexer.exists(newNode)) {503 this.indexer.remove(newNode);504 }505 506 // Insert the node into the indexer so it can show us where to place it.507 // Note that this operation is O(log(n)). If there's a performance508 // problem (when dragging, for instance) this is likely where it509 // would be.510 this.indexer.insert(newNode, this.root);511 // Insert the node into the indexer so it can show us where to 512 // place it. Note that this operation is O(log(n)). If there's a 513 // performance problem (when dragging, for instance) this is 514 // likely where it would be. 515 var insert = this.indexer ? this.indexer.insert(newNode) : null; 516 517 if(insert) { 518 this.root.insertBefore(newNode, insert); 519 } else { 520 this.root.appendChild(newNode); 521 } 511 522 512 523 this.postDraw(newNode); … … 742 753 element.parentNode.removeChild(element); 743 754 744 this.indexer.remove(element); 745 746 var backgroundId = geometry.id + this.BACKGROUND_ID_SUFFIX; 747 var bElem = OpenLayers.Util.getElement(backgroundId); 748 if (bElem && bElem.parentNode) { 749 // No need to destroy the geometry since the element and the background 750 // node share the same geometry. 751 bElem.parentNode.removeChild(bElem); 755 if (this.indexer) { 756 this.indexer.remove(element); 757 758 var backgroundId = geometry.id + this.BACKGROUND_ID_SUFFIX; 759 var bElem = OpenLayers.Util.getElement(backgroundId); 760 if (bElem && bElem.parentNode) { 761 // No need to destroy the geometry since the element and the background 762 // node share the same geometry. 763 bElem.parentNode.removeChild(bElem); 764 } 752 765 } 753 766 }
