summaryrefslogtreecommitdiff
path: root/altosuilib
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-05-05 02:25:52 -0700
committerKeith Packard <keithp@keithp.com>2016-05-05 02:25:52 -0700
commite0081f7ba6fc9f1e4484d3e291fd30065ad5b620 (patch)
treefabb5b36eb80705e75b83a8ef148e27e9e7fdd8d /altosuilib
parent13179f614a99cad3016832ac1b365eaa4208c10f (diff)
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 <keithp@keithp.com>
Diffstat (limited to 'altosuilib')
-rw-r--r--altosuilib/AltosUIMapNew.java18
-rw-r--r--altosuilib/AltosUIMapPreloadNew.java9
2 files changed, 12 insertions, 15 deletions
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<AltosLaunchSite> 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;