|
From: Nicolas P. <nic...@us...> - 2005-04-10 23:16:35
|
Update of /cvsroot/hipgmap/gmap/com/trileet/gmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28159/com/trileet/gmap Modified Files: ImageCache.java TileSet.java Log Message: Try to add request pausing when we are scrolling. Seems to work ok, but we still get slowed down by outstanding requests that come back. Index: ImageCache.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/ImageCache.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ImageCache.java 10 Apr 2005 20:45:33 -0000 1.13 --- ImageCache.java 10 Apr 2005 23:16:04 -0000 1.14 *************** *** 213,216 **** --- 213,223 ---- } + + // Whether we are paused from currently requesting images + private static boolean s_paused = false; + + public static void stopFetching(){ s_paused = true; } + public static void startFetching(){ s_paused = false; synchronized(s_pending){ s_pending.notifyAll(); } } + /** * Thread that takes care of requesting images *************** *** 232,235 **** --- 239,249 ---- } } + + // while we are paused, hang out + while(s_paused){ + synchronized(s_pending){ + s_pending.wait(10000); + } + } // while we have 4 or more pending requests, wait for one to be over Index: TileSet.java =================================================================== RCS file: /cvsroot/hipgmap/gmap/com/trileet/gmap/TileSet.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** TileSet.java 10 Apr 2005 20:45:33 -0000 1.25 --- TileSet.java 10 Apr 2005 23:16:05 -0000 1.26 *************** *** 316,319 **** --- 316,326 ---- // Checks our center, reordering our tile set accordingly if needed public void checkCenter() { + // called whenever we are moving + m_stopTimer.resetDelay(1000); + m_stopTimer.start(); + + // Turn off fetching + ImageCache.stopFetching(); + /** Fine-tuned for the 5x5 tileset. **/ if (m_offsetX < TILE_WIDTH || m_offsetX > TILE_WIDTH * 2 *************** *** 576,581 **** --- 583,590 ---- animateDeltaY = endY / numSteps; animateStepsLeft = numSteps; + // Do the first step now, so we don't have to wait 30 ms. animateStep(); + // Start up the repeating timer. animateTimer.start(); *************** *** 590,594 **** animateStepsLeft--; GMap.invalidateMap(); - } --- 599,602 ---- *************** *** 620,623 **** --- 628,637 ---- animateStep(); return true; + + } else if (e.data == STOP){ + // we stopped, trigger fetches again + m_stopTimer.stop(); + ImageCache.startFetching(); + return true; } else { return false; *************** *** 684,688 **** * When we convert the center of our map into a KH coordinate to * fetch the correct aerial photo tile, we will cut off the first ! * (18-zoom) characters and put them in the URL. The remaining * characters will tell us where, in the bitmap that gets * returned, is our point. --- 698,702 ---- * When we convert the center of our map into a KH coordinate to * fetch the correct aerial photo tile, we will cut off the first ! * (18-zoom) characters and put them in the URL. The remaing * characters will tell us where, in the bitmap that gets * returned, is our point. *************** *** 833,840 **** private boolean animateAlongPolyline; ! private danger.app.Timer animateTimer = new Timer(30, true, this, ANIMATE, ! null); public static final int ANIMATE = 1; public MapWindow parentMapWindow; --- 847,859 ---- private boolean animateAlongPolyline; ! private danger.app.Timer animateTimer = new Timer(30, true, this, ANIMATE, null); ! ! /** Stop timer, started everytime we start moving, when it ends then we know we can start ! * fetching tiles. ! */ ! private danger.app.Timer m_stopTimer = new Timer(500, true, this, STOP, null); public static final int ANIMATE = 1; + public static final int STOP = 2; public MapWindow parentMapWindow; |