[OpenLayers-Commits] r4735 - in sandbox/pagameba/transition/lib/OpenLayers: . Tile

commits at openlayers.org commits at openlayers.org
Mon Oct 1 11:38:15 EDT 2007


Author: pagameba
Date: 2007-10-01 11:38:14 -0400 (Mon, 01 Oct 2007)
New Revision: 4735

Modified:
   sandbox/pagameba/transition/lib/OpenLayers/Tile.js
   sandbox/pagameba/transition/lib/OpenLayers/Tile/Image.js
Log:
modify sequence of events for backBufferTile by synchronizing it's position after its tile moves rather than just before so that it is in the correct position for the next event.

Modified: sandbox/pagameba/transition/lib/OpenLayers/Tile/Image.js
===================================================================
--- sandbox/pagameba/transition/lib/OpenLayers/Tile/Image.js	2007-10-01 13:56:59 UTC (rev 4734)
+++ sandbox/pagameba/transition/lib/OpenLayers/Tile/Image.js	2007-10-01 15:38:14 UTC (rev 4735)
@@ -80,15 +80,15 @@
         OpenLayers.Tile.prototype.destroy.apply(this, arguments);
     },
 
-   /**
-    * Method: clone
-    *
-    * Parameters:
-    * obj - {<OpenLayers.Tile.Image>} The tile to be cloned
-    *
-    * Returns:
-    * {<OpenLayers.Tile.Image>} An exact clone of this <OpenLayers.Tile.Image>
-    */
+    /**
+     * Method: clone
+     *
+     * Parameters:
+     * obj - {<OpenLayers.Tile.Image>} The tile to be cloned
+     *
+     * Returns:
+     * {<OpenLayers.Tile.Image>} An exact clone of this <OpenLayers.Tile.Image>
+     */
     clone: function (obj) {
         
         if (obj == null) {
@@ -108,7 +108,8 @@
         
         return obj;
     },    
-
+    
+    
     /**
      * Method: draw
      * Check that a tile should be drawn, and draw it.
@@ -136,7 +137,7 @@
         
         return true;
     },
-
+    
     /**
      * Method: renderTile
      *
@@ -147,13 +148,13 @@
         if (this.imgDiv == null) {
             this.initImgDiv();
         }
+
         this.imgDiv.viewRequestID = this.layer.map.viewRequestID;
-        
-        this.url = this.layer.getURL(this.bounds);
         // position the frame 
         OpenLayers.Util.modifyDOMElement(this.frame, 
                                          null, this.position, this.size);   
-
+                                         
+        this.url = this.layer.getURL(this.bounds);
         var imageSize = this.layer.getImageSize(); 
         if (this.layer.alpha) {
             OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,
@@ -163,11 +164,8 @@
             OpenLayers.Util.modifyDOMElement(this.imgDiv,
                     null, null, imageSize) ;
         }
-
-        //Somehow this.imgDiv is being made visible without calling this
-        //OpenLayers.Element.show(this.imgDiv);
     },
-    
+
     /** 
      * Method: clear
      *  Clear the tile of any bounds/position-related data so that it can 
@@ -184,6 +182,7 @@
      * Creates the imgDiv property on the tile.
      */
     initImgDiv: function() {
+        
         var offset = this.layer.imageOffset; 
         var size = this.layer.getImageSize(); 
      
@@ -244,9 +243,10 @@
                 this.isLoading = false; 
                 this.events.triggerEvent("loadend"); 
             }
-        };
+        }
         OpenLayers.Event.observe(this.imgDiv, 'load',
                                  OpenLayers.Function.bind(onload, this));
+
     },
 
     /**
@@ -272,22 +272,12 @@
         if (this.layer) {
             var loaded = this.layer.alpha ? this.imgDiv.firstChild.src : this.imgDiv.src;
             if (!OpenLayers.Util.isEquivalentUrl(loaded, this.url)) {
-                OpenLayers.Element.hide(this.imgDiv);
+                this.imgDiv.style.display = "none";
             }
         }
     },
-
-    /**
-     * Method: startTransition
-     *
-     * start a transition effect defined at the layer level to this back
-     * buffer tile as the new tile loads.  Valid effects are:
-     * 
-     * Parameters:
-     * gridTile - {<OpenLayers.Tile>} The actual tile in the grid that this 
-     *     backBufferTile is backBuffering.
-     */
-    startTransition: function(gridTile) {
+    
+    startTransition: function() {
         switch (this.layer.transitionEffect) {
             case "resize": 
                 break;
@@ -299,21 +289,19 @@
                 // there was no change in resolution.  Otherwise we
                 // don't bother to show the backBufferTile at all
                 if (this.layer.singleTile /* && some resolution test */) {
-                    this.backBufferTile.renderTile();                    
+                    if (this.backBufferTile && this.backBufferTile.imgDiv) {
+                        OpenLayers.Element.show(this.backBufferTile.imgDiv);
+                    }
                 }
         }
     },
     
-    /**
-     * Method: endTransition
-     *
-     * finalize the transition by clearing the back buffer tile
-     */
     endTransition: function() {
-        this.backBufferTile.clear();
+        if (this.backBufferTile && this.backBufferTile.imgDiv) {
+            OpenLayers.Element.hide(this.backBufferTile.imgDiv);
+        }
     },
 
-
     /** @final @type String */
     CLASS_NAME: "OpenLayers.Tile.Image"
   }

Modified: sandbox/pagameba/transition/lib/OpenLayers/Tile.js
===================================================================
--- sandbox/pagameba/transition/lib/OpenLayers/Tile.js	2007-10-01 13:56:59 UTC (rev 4734)
+++ sandbox/pagameba/transition/lib/OpenLayers/Tile.js	2007-10-01 15:38:14 UTC (rev 4735)
@@ -118,15 +118,16 @@
         this.events = null;
     },
     
-   /**
-    * Method: clone
-    *
-    * Parameters:
-    * obj - {<OpenLayers.Tile>} The tile to be cloned
-    *
-    * Returns:
-    * {<OpenLayers.Tile>} An exact clone of this <OpenLayers.Tile>
-    */
+     
+    /**
+     * Method: clone
+     *
+     * Parameters:
+     * obj - {<OpenLayers.Tile>} The tile to be cloned
+     *
+     * Returns:
+     * {<OpenLayers.Tile>} An exact clone of this <OpenLayers.Tile>
+     */
     clone: function (obj) {
         
         if (obj == null) {
@@ -141,7 +142,7 @@
         OpenLayers.Util.applyDefaults(obj, this);
         
         return obj;
-    },    
+    },
 
     /**
      * Method: draw
@@ -163,7 +164,7 @@
         // The only case where we *wouldn't* want to draw the tile is if the 
         // tile is outside its layer's maxExtent.
         var drawTile = (withinMaxExtent || this.layer.displayOutsideMaxExtent);
-
+        
         if (drawTile) {
             //we use a clone of this tile to create a double buffer for visual
             //continuity.  The backBufferTile is used to create transition
@@ -173,16 +174,17 @@
                 // clear transition back buffer tile only after all tiles in this
                 // layer have loaded to avoid visual glitches
                 this.layer.events.register("loadend", this, this.endTransition);
+                this.events.register("loadend", this, this.syncBackBufferTile);
             }
-
+            
             //allow for custom buffering as we transition the tile to its
             // new location
             this.transition();
         }
-            
+        
         //clear tile's contents and mark as not drawn
         this.clear();
-    
+        
         return drawTile;
     },
     
@@ -200,15 +202,6 @@
         if (redraw == null) {
             redraw = true;
         }
-        
-        // if this tile has a back buffer, we need to update its
-        // size, bounds and position before we move the tile
-        // in the grid.
-        if (this.backBufferTile) {
-            this.backBufferTile.size = this.size.clone();
-            this.backBufferTile.bounds = this.bounds.clone();
-            this.backBufferTile.position = this.position.clone();
-        }
 
         this.bounds = bounds.clone();
         this.position = position.clone();
@@ -266,38 +259,20 @@
                                        topLeft.lat);  
         return bounds;
     },        
-
-    /**
-     * Method: transition
-     *
-     * allow subclasses to implement transition effects in
-     * their startTransition method.
-     */
+    
+    syncBackBufferTile: function() {
+        this.backBufferTile.position = this.position.clone();
+        this.backBufferTile.bounds = this.bounds.clone();
+        this.backBufferTile.size = this.size.clone();
+        this.backBufferTile.renderTile();
+    },
+    
     transition: function() {
-        // calculate new position/size for bufferTile
-        // based on the change in resolution from the
-        // for this transition.  Subclasses can use this
-        // to implement specific transition effects.
-        // this.backBufferTile.newPX = blah;
-        // this.backBufferTile.newSize = blah;
-        this.startTransition(this);
+        this.startTransition();
     },
     
-    /***
-     * Method: startTransition
-     *
-     * called at the beginning of a transition, implementation
-     * to be provided by subclasses
-     */
     startTransition: function() {},
-
-    /***
-     * Method: endTransition
-     *
-     * called at the end of a transition when the back buffer is 
-     * covered up by new tiles, implementation to be provided by
-     * subclasses
-     */
+    
     endTransition: function() {},
     
     CLASS_NAME: "OpenLayers.Tile"



More information about the Commits mailing list