From e0081f7ba6fc9f1e4484d3e291fd30065ad5b620 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 5 May 2016 02:25:52 -0700 Subject: [PATCH] altoslib: Fix map preloading callbacks, run in separate thread The map storage and tile callbacks were muddled together. Create clearly separate states for map data and have status updates be delivered when registering for new status events so that registration is sufficient to track the state without an explicit call to get the current state. Run the map tile creation in a separate thread so that even checking status of files on disk runs out of the UI thread. These fixes serve to make the pacifier update more smoothly, and also not over/under count tile loading so that the loading actually completes when all of the tiles are loaded. Signed-off-by: Keith Packard --- .../AltosDroid/AltosMapOffline.java | 14 ++-- .../AltosDroid/PreloadMapActivity.java | 13 ++-- altoslib/AltosMap.java | 8 +- altoslib/AltosMapCache.java | 78 ++++++------------- altoslib/AltosMapInterface.java | 2 +- altoslib/AltosMapLoader.java | 72 ++++++++--------- altoslib/AltosMapStore.java | 47 +++++------ altoslib/AltosMapTile.java | 64 +++++++++------ altoslib/AltosMapTileListener.java | 2 - altosuilib/AltosUIMapNew.java | 18 ++--- altosuilib/AltosUIMapPreloadNew.java | 9 +-- 11 files changed, 146 insertions(+), 181 deletions(-) diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosMapOffline.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosMapOffline.java index bde80cfc..ab142b17 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosMapOffline.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosMapOffline.java @@ -133,7 +133,7 @@ public class AltosMapOffline extends View implements ScaleGestureDetector.OnScal if (canvas.quickReject(pt.x, pt.y, pt.x + px_size, pt.y + px_size, Canvas.EdgeType.AA)) return; - AltosImage altos_image = cache.get(this, store, px_size, px_size); + AltosImage altos_image = this.get_image(); MapImage map_image = (MapImage) altos_image; @@ -150,8 +150,8 @@ public class AltosMapOffline extends View implements ScaleGestureDetector.OnScal if (t.has_location()) { String message = null; switch (status) { - case AltosMapTile.loading: - message = "Loading..."; + case AltosMapTile.fetching: + message = "Fetching..."; break; case AltosMapTile.bad_request: message = "Internal error"; @@ -181,14 +181,14 @@ public class AltosMapOffline extends View implements ScaleGestureDetector.OnScal } } - public MapTile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { - super(listener, upper_left, center, zoom, maptype, px_size, 2); + public MapTile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { + super(cache, upper_left, center, zoom, maptype, px_size, 2); } } - public AltosMapTile new_tile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { - return new MapTile(listener, upper_left, center, zoom, maptype, px_size); + public AltosMapTile new_tile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { + return new MapTile(cache, upper_left, center, zoom, maptype, px_size); } public AltosMapPath new_path() { diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/PreloadMapActivity.java b/altosdroid/src/org/altusmetrum/AltosDroid/PreloadMapActivity.java index 87f03a92..13a44e1f 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/PreloadMapActivity.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/PreloadMapActivity.java @@ -107,7 +107,6 @@ public class PreloadMapActivity extends Activity implements AltosLaunchSiteListe } AltosMap map; - AltosMapLoader loader; class PreloadMapImage implements AltosImage { public void flush() { @@ -137,14 +136,14 @@ public class PreloadMapActivity extends Activity implements AltosLaunchSiteListe public void paint(AltosMapTransform t) { } - public PreloadMapTile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { - super(listener, upper_left, center, zoom, maptype, px_size, 2); + public PreloadMapTile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { + super(cache, upper_left, center, zoom, maptype, px_size, 2); } } - public AltosMapTile new_tile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { - return new PreloadMapTile(listener, upper_left, center, zoom, maptype, px_size); + public AltosMapTile new_tile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { + return new PreloadMapTile(cache, upper_left, center, zoom, maptype, px_size); } public int width() { @@ -265,7 +264,7 @@ public class PreloadMapActivity extends Activity implements AltosLaunchSiteListe AltosDebug.debug("PreloadMap load %f %f %d %d %f %d\n", lat, lon, min, max, r, t); - loader.load(lat, lon, min, max, r, t); + new AltosMapLoader(map, this, lat, lon, min, max, r, t); } catch (ParseException e) { AltosDebug.debug("PreloadMap load raised exception %s", e.toString()); } @@ -398,8 +397,6 @@ public class PreloadMapActivity extends Activity implements AltosLaunchSiteListe map = new AltosMap(this); - loader = new AltosMapLoader(map, this); - // Listen for GPS and Network position updates LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java index 26851e96..1841277f 100644 --- a/altoslib/AltosMap.java +++ b/altoslib/AltosMap.java @@ -328,7 +328,8 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { if (!tiles.containsKey(point)) { AltosLatLon ul = transform.lat_lon(point); AltosLatLon center = transform.lat_lon(new AltosPointDouble(x + AltosMap.px_size/2, y + AltosMap.px_size/2)); - AltosMapTile tile = map_interface.new_tile(this, ul, center, zoom, maptype, px_size); + AltosMapTile tile = map_interface.new_tile(cache, ul, center, zoom, maptype, px_size); + tile.add_listener(this); tiles.put(point, tile); } } @@ -345,11 +346,6 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { centre(lat, lon); tiles.clear(); make_tiles(); - for (AltosMapTile tile : tiles.values()) { - tile.add_store_listener(this); - if (tile.store_status() != AltosMapTile.loading) - listener.notify_tile(tile, tile.store_status()); - } repaint(); } diff --git a/altoslib/AltosMapCache.java b/altoslib/AltosMapCache.java index 17a36ff3..38e0f769 100644 --- a/altoslib/AltosMapCache.java +++ b/altoslib/AltosMapCache.java @@ -23,25 +23,20 @@ import java.net.*; public class AltosMapCache implements AltosMapCacheListener { /* An entry in the MapCache */ - class MapCacheElement implements AltosMapStoreListener { + class MapCacheElement implements AltosMapTileListener { AltosMapTile tile; /* Notify when image has been loaded */ AltosImage image; - AltosMapStore store; long used; class loader implements Runnable { public void run() { - if (image != null) - tile.notify_image(image); - try { - image = map_interface.load_image(store.file); - } catch (Exception ex) { + if (image == null) { + try { + image = map_interface.load_image(tile.store.file); + } catch (Exception ex) { + } } - if (image == null) - tile.set_status(AltosMapTile.failed); - else - tile.set_status(AltosMapTile.success); tile.notify_image(image); } } @@ -60,41 +55,21 @@ public class AltosMapCache implements AltosMapCacheListener { } public boolean has_map() { - return store.status() == AltosMapTile.success; + return tile.status == AltosMapTile.loaded; } - public synchronized void notify_store(AltosMapStore store, int status) { - switch (status) { - case AltosMapTile.loading: - break; - case AltosMapTile.success: + public synchronized void notify_tile(AltosMapTile tile, int status) { + if (status == AltosMapTile.fetched) { + System.out.printf("tile fetched, loading image\n"); load(); - break; - default: - tile.set_status(status); - tile.notify_image(null); } } - public MapCacheElement(AltosMapTile tile, AltosMapStore store) throws IOException { + public MapCacheElement(AltosMapTile tile) { this.tile = tile; this.image = null; - this.store = store; this.used = 0; - - int status = store.status(); - switch (status) { - case AltosMapTile.loading: - store.add_listener(this); - break; - case AltosMapTile.success: - load(); - break; - default: - tile.set_status(status); - tile.notify_image(null); - break; - } + tile.add_listener(this); } } @@ -135,7 +110,7 @@ public class AltosMapCache implements AltosMapCacheListener { } } - public AltosImage get(AltosMapTile tile, AltosMapStore store, int width, int height) { + public AltosImage get(AltosMapTile tile) { int oldest = -1; long age = used; @@ -148,7 +123,7 @@ public class AltosMapCache implements AltosMapCacheListener { oldest = i; break; } - if (store.equals(element.store)) { + if (tile.store.equals(element.tile.store)) { element.used = used++; return element.image; } @@ -158,24 +133,15 @@ public class AltosMapCache implements AltosMapCacheListener { } } - try { - element = new MapCacheElement(tile, store); - element.used = used++; - if (elements[oldest] != null) - elements[oldest].flush(); + element = new MapCacheElement(tile); + element.used = used++; + if (elements[oldest] != null) + elements[oldest].flush(); - elements[oldest] = element; - - if (element.image == null) - tile.set_status(AltosMapTile.loading); - else - tile.set_status(AltosMapTile.success); - - return element.image; - } catch (IOException e) { - tile.set_status(AltosMapTile.failed); - return null; - } + elements[oldest] = element; + System.out.printf("AltosMapCache.get image ? %s\n", + element.image == null ? "false" : "true"); + return element.image; } } diff --git a/altoslib/AltosMapInterface.java b/altoslib/AltosMapInterface.java index 71936ad2..756a78f2 100644 --- a/altoslib/AltosMapInterface.java +++ b/altoslib/AltosMapInterface.java @@ -29,7 +29,7 @@ public interface AltosMapInterface { public abstract AltosMapMark new_mark(double lat, double lon, int state); - public abstract AltosMapTile new_tile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size); + public abstract AltosMapTile new_tile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size); public abstract int width(); diff --git a/altoslib/AltosMapLoader.java b/altoslib/AltosMapLoader.java index 15fd756e..7112a1c4 100644 --- a/altoslib/AltosMapLoader.java +++ b/altoslib/AltosMapLoader.java @@ -24,7 +24,7 @@ import java.lang.Math; import java.net.URL; import java.net.URLConnection; -public class AltosMapLoader implements AltosMapTileListener, AltosMapStoreListener { +public class AltosMapLoader extends Thread implements AltosMapTileListener { AltosMapLoaderListener listener; double latitude, longitude; @@ -91,10 +91,8 @@ public class AltosMapLoader implements AltosMapTileListener, AltosMapStoreListen AltosPointInt point = new AltosPointInt(x, y); AltosLatLon ul = transform.lat_lon(point); AltosLatLon center = transform.lat_lon(new AltosPointDouble(x + AltosMap.px_size/2, y + AltosMap.px_size/2)); - AltosMapTile tile = map.map_interface.new_tile(this, ul, center, zoom, maptype, AltosMap.px_size); - tile.add_store_listener(this); - if (tile.store_status() != AltosMapTile.loading) - notify_tile(tile, tile.store_status()); + AltosMapTile tile = map.map_interface.new_tile(null, ul, center, zoom, maptype, AltosMap.px_size); + tile.add_listener(this); } } } @@ -123,7 +121,7 @@ public class AltosMapLoader implements AltosMapTileListener, AltosMapStoreListen do_load(); } - private void start_load() { + public void run() { cur_z = min_z; int ntype = 0; @@ -138,66 +136,64 @@ public class AltosMapLoader implements AltosMapTileListener, AltosMapStoreListen cur_type = next_type(0); + tiles_total = 0; for (int z = min_z; z <= max_z; z++) - tiles_total += tiles_per_layer(z); + tiles_total += tiles_per_layer(z) * ntype; layers_total = (max_z - min_z + 1) * ntype; layers_loaded = 0; tiles_loaded_total = 0; - listener.debug("total tiles %d\n", tiles_total); + listener.debug("total tiles %d layers %d\n", tiles_total, layers_total); listener.loader_start(tiles_total); do_load(); } - public void load(double latitude, double longitude, int min_z, int max_z, double radius, int all_types) { - listener.debug("lat %f lon %f min_z %d max_z %d radius %f all_types %d\n", - latitude, longitude, min_z, max_z, radius, all_types); - this.latitude = latitude; - this.longitude = longitude; - this.min_z = min_z; - this.max_z = max_z; - this.radius = radius; - this.all_types = all_types; - start_load(); - } - - public synchronized void notify_store(AltosMapStore store, int status) { + public synchronized void notify_tile(AltosMapTile tile, int status) { boolean do_next = false; - if (status == AltosMapTile.loading) + if (status == AltosMapTile.fetching) return; + tile.remove_listener(this); + if (layers_loaded >= layers_total) return; ++tiles_loaded_total; ++tiles_loaded_layer; + listener.debug("AltosMapLoader.notify_tile status %d total %d of %d layer %d of %d\n", + status, tiles_loaded_total, tiles_total, tiles_loaded_layer, tiles_this_layer); + if (tiles_loaded_layer == tiles_this_layer) { ++layers_loaded; listener.debug("%d layers loaded\n", layers_loaded); - if (layers_loaded == layers_total) { - listener.loader_done(tiles_total); - return; - } else { - do_next = true; - } + do_next = true; } - listener.loader_notify(tiles_loaded_total, - tiles_total, store.file.toString()); - if (do_next) - next_load(); - } - public synchronized void notify_tile(AltosMapTile tile, int status) { - notify_store(tile.store, status); + if (tiles_loaded_total == tiles_total) + listener.loader_done(tiles_total); + else { + listener.loader_notify(tiles_loaded_total, + tiles_total, tile.store.file.toString()); + if (do_next) + next_load(); + } } - public AltosMapCache cache() { return map.cache(); } - - public AltosMapLoader(AltosMap map, AltosMapLoaderListener listener) { + public AltosMapLoader(AltosMap map, AltosMapLoaderListener listener, + double latitude, double longitude, int min_z, int max_z, double radius, int all_types) { + listener.debug("lat %f lon %f min_z %d max_z %d radius %f all_types %d\n", + latitude, longitude, min_z, max_z, radius, all_types); this.map = map; this.listener = listener; + this.latitude = latitude; + this.longitude = longitude; + this.min_z = min_z; + this.max_z = max_z; + this.radius = radius; + this.all_types = all_types; + start(); } } diff --git a/altoslib/AltosMapStore.java b/altoslib/AltosMapStore.java index eebef310..aed365ca 100644 --- a/altoslib/AltosMapStore.java +++ b/altoslib/AltosMapStore.java @@ -35,6 +35,7 @@ public class AltosMapStore { public synchronized void add_listener(AltosMapStoreListener listener) { if (!listeners.contains(listener)) listeners.add(listener); + listener.notify_store(this, status); } public synchronized void remove_listener(AltosMapStoreListener listener) { @@ -110,7 +111,7 @@ public class AltosMapStore { file.delete(); return AltosMapTile.bad_request; } - return AltosMapTile.success; + return AltosMapTile.fetched; } static Object fetch_lock = new Object(); @@ -118,42 +119,42 @@ public class AltosMapStore { static final long forbidden_interval = 60l * 1000l * 1000l * 1000l; static final long google_maps_ratelimit_ms = 1200; - static Object loader_lock = new Object(); + static Object fetcher_lock = new Object(); static LinkedList waiting = new LinkedList(); static LinkedList running = new LinkedList(); - static final int concurrent_loaders = 128; + static final int concurrent_fetchers = 128; - static void start_loaders() { - while (!waiting.isEmpty() && running.size() < concurrent_loaders) { + static void start_fetchers() { + while (!waiting.isEmpty() && running.size() < concurrent_fetchers) { AltosMapStore s = waiting.remove(); running.add(s); - Thread lt = s.make_loader_thread(); + Thread lt = s.make_fetcher_thread(); lt.start(); } } - void finish_loader() { - synchronized(loader_lock) { + void finish_fetcher() { + synchronized(fetcher_lock) { running.remove(this); - start_loaders(); + start_fetchers(); } } - void add_loader() { - synchronized(loader_lock) { + void add_fetcher() { + synchronized(fetcher_lock) { waiting.add(this); - start_loaders(); + start_fetchers(); } } - class loader implements Runnable { + class fetcher implements Runnable { public void run() { try { if (file.exists()) { - notify_listeners(AltosMapTile.success); + notify_listeners(AltosMapTile.fetched); return; } @@ -170,7 +171,7 @@ public class AltosMapStore { synchronized (fetch_lock) { long startTime = System.nanoTime(); new_status = fetch_url(); - if (new_status == AltosMapTile.success) { + if (new_status == AltosMapTile.fetched) { long duration_ms = (System.nanoTime() - startTime) / 1000000; if (duration_ms < google_maps_ratelimit_ms) { try { @@ -186,17 +187,17 @@ public class AltosMapStore { } notify_listeners(new_status); } finally { - finish_loader(); + finish_fetcher(); } } } - private Thread make_loader_thread() { - return new Thread(new loader()); + private Thread make_fetcher_thread() { + return new Thread(new fetcher()); } - private void load() { - add_loader(); + private void fetch() { + add_fetcher(); } private AltosMapStore (String url, File file) { @@ -204,10 +205,10 @@ public class AltosMapStore { this.file = file; if (file.exists()) - status = AltosMapTile.success; + status = AltosMapTile.fetched; else { - status = AltosMapTile.loading; - load(); + status = AltosMapTile.fetching; + fetch(); } } diff --git a/altoslib/AltosMapTile.java b/altoslib/AltosMapTile.java index 076c5937..fdc8ff65 100644 --- a/altoslib/AltosMapTile.java +++ b/altoslib/AltosMapTile.java @@ -20,22 +20,23 @@ package org.altusmetrum.altoslib_10; import java.io.*; import java.util.*; -public abstract class AltosMapTile implements AltosFontListener { - AltosMapTileListener listener; +public abstract class AltosMapTile implements AltosFontListener, AltosMapStoreListener { + LinkedList listeners = new LinkedList(); public AltosLatLon upper_left, center; public int px_size; int zoom; int maptype; int scale; + private AltosMapCache cache; public AltosMapStore store; - public AltosMapCache cache; public int status; - static public final int success = 0; - static public final int loading = 1; - static public final int failed = 2; - static public final int bad_request = 3; - static public final int forbidden = 4; + static public final int loaded = 0; /* loaded from file */ + static public final int fetched = 1; /* downloaded to file */ + static public final int fetching = 2; /* downloading from net */ + static public final int failed = 3; /* loading from file failed */ + static public final int bad_request = 4;/* downloading failed */ + static public final int forbidden = 5; /* downloading failed */ private File map_file() { double lat = center.lat; @@ -79,33 +80,46 @@ public abstract class AltosMapTile implements AltosFontListener { public void font_size_changed(int font_size) { } - public void set_status(int status) { + private synchronized void notify_listeners(int status) { this.status = status; - listener.notify_tile(this, status); + for (AltosMapTileListener listener : listeners) + listener.notify_tile(this, status); } - public void notify_image(AltosImage image) { - listener.notify_tile(this, status); + public void notify_store(AltosMapStore store, int status) { +// System.out.printf("AltosMapTile.notify_store %d\n", status); + notify_listeners(status); } - public int store_status() { - return store.status(); + public void notify_image(AltosImage image) { + if (image == null) + status = failed; + else + status = loaded; + notify_listeners(status); } - public void add_store_listener(AltosMapStoreListener listener) { - store.add_listener(listener); + public abstract void paint(AltosMapTransform t); + + public AltosImage get_image() { + if (cache == null) + return null; + return cache.get(this); } - public void remove_store_listener(AltosMapStoreListener listener) { - store.remove_listener(listener); + public synchronized void add_listener(AltosMapTileListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + listener.notify_tile(this, status); } - public abstract void paint(AltosMapTransform t); + public synchronized void remove_listener(AltosMapTileListener listener) { + listeners.remove(listener); + } - public AltosMapTile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size, int scale) { - this.listener = listener; + public AltosMapTile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size, int scale) { + this.cache = cache; this.upper_left = upper_left; - this.cache = listener.cache(); while (center.lon < -180.0) center.lon += 360.0; @@ -118,11 +132,11 @@ public abstract class AltosMapTile implements AltosFontListener { this.px_size = px_size; this.scale = scale; - status = AltosMapTile.loading; store = AltosMapStore.get(map_url(), map_file()); + store.add_listener(this); } - public AltosMapTile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { - this(listener, upper_left, center, zoom, maptype, px_size, 1); + public AltosMapTile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { + this(cache, upper_left, center, zoom, maptype, px_size, 1); } } diff --git a/altoslib/AltosMapTileListener.java b/altoslib/AltosMapTileListener.java index 6ab03638..6d78b205 100644 --- a/altoslib/AltosMapTileListener.java +++ b/altoslib/AltosMapTileListener.java @@ -19,6 +19,4 @@ package org.altusmetrum.altoslib_10; public interface AltosMapTileListener { abstract public void notify_tile(AltosMapTile tile, int status); - - abstract public AltosMapCache cache(); } diff --git a/altosuilib/AltosUIMapNew.java b/altosuilib/AltosUIMapNew.java index c867bf2e..a90e8c91 100644 --- a/altosuilib/AltosUIMapNew.java +++ b/altosuilib/AltosUIMapNew.java @@ -241,8 +241,8 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt } class MapTile extends AltosMapTile { - public MapTile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { - super(listener, upper_left, center, zoom, maptype, px_size); + public MapTile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { + super(cache, upper_left, center, zoom, maptype, px_size); } public void paint(AltosMapTransform t) { @@ -254,11 +254,9 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt if (!g.hitClip(point.x, point.y, px_size, px_size)) return; - AltosImage altos_image = cache.get(this, store, px_size, px_size); - + AltosImage altos_image = get_image(); AltosUIImage ui_image = (AltosUIImage) altos_image; - - Image image = null; + Image image = null; if (ui_image != null) image = ui_image.image; @@ -272,8 +270,8 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt if (t.has_location()) { String message = null; switch (status) { - case AltosMapTile.loading: - message = "Loading..."; + case AltosMapTile.fetching: + message = "Fetching..."; break; case AltosMapTile.bad_request: message = "Internal error"; @@ -334,8 +332,8 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt return new MapMark(lat, lon, state); } - public AltosMapTile new_tile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { - return new MapTile(listener, upper_left, center, zoom, maptype, px_size); + public AltosMapTile new_tile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { + return new MapTile(cache, upper_left, center, zoom, maptype, px_size); } public int width() { diff --git a/altosuilib/AltosUIMapPreloadNew.java b/altosuilib/AltosUIMapPreloadNew.java index b5f4dbf8..3269bbdd 100644 --- a/altosuilib/AltosUIMapPreloadNew.java +++ b/altosuilib/AltosUIMapPreloadNew.java @@ -127,8 +127,6 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener JProgressBar pbar; - AltosMapLoader loader; - JLabel site_list_label; JComboBox site_list; @@ -238,7 +236,10 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener r = r * 1000; loading = true; - loader.load(latitude, longitude, min_z, max_z, r, all_types()); + new AltosMapLoader(map.map, this, + latitude, longitude, + min_z, max_z, r, all_types()); + } catch (ParseException pe) { load_button.setSelected(false); } @@ -271,8 +272,6 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener map = new AltosUIMapNew(); - loader = new AltosMapLoader(map.map, this); - c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.CENTER; c.insets = i; -- 2.30.2