summaryrefslogtreecommitdiff
path: root/altosuilib
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-05-10 23:02:09 -0700
committerKeith Packard <keithp@keithp.com>2016-05-11 23:22:15 -0700
commitc5f49d0ac254047f13c6c1ecfb5520eff72109ac (patch)
treea87418e536609b31cff0dc2f9f38509fd2dac4b1 /altosuilib
parent2e551e7c5f82a7e35d39e8f73e8e526e5484cd5d (diff)
altoslib: Allow map preloading to be aborted
Close the map preload dialog and it would be nice to stop loading map bits. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosuilib')
-rw-r--r--altosuilib/AltosUIMapPreloadNew.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/altosuilib/AltosUIMapPreloadNew.java b/altosuilib/AltosUIMapPreloadNew.java
index d6c257e0..3e4a604f 100644
--- a/altosuilib/AltosUIMapPreloadNew.java
+++ b/altosuilib/AltosUIMapPreloadNew.java
@@ -131,7 +131,6 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener
JComboBox<AltosLaunchSite> site_list;
JToggleButton load_button;
- boolean loading;
JButton close_button;
JCheckBox[] maptypes = new JCheckBox[AltosMap.maptype_terrain - AltosMap.maptype_hybrid + 1];
@@ -147,6 +146,7 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener
Double[] radius_km = { 2.0, 5.0, 10.0, 20.0, 30.0 };
Double radius_def_km = 10.0;
+ AltosMapLoader loader;
static final String[] lat_hemi_names = { "N", "S" };
static final String[] lon_hemi_names = { "E", "W" };
@@ -187,12 +187,12 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener
}
public void loader_done(int max) {
+ loader = null;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
pbar.setValue(0);
pbar.setString("");
load_button.setSelected(false);
- loading = false;
}
});
}
@@ -227,11 +227,14 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener
public void actionPerformed(ActionEvent e) {
String cmd = e.getActionCommand();
- if (cmd.equals("close"))
+ if (cmd.equals("close")) {
+ if (loader != null)
+ loader.abort();
setVisible(false);
+ }
if (cmd.equals("load")) {
- if (!loading) {
+ if (loader == null) {
try {
latitude = lat.get_value();
longitude = lon.get_value();
@@ -245,11 +248,10 @@ public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener
r = AltosConvert.miles_to_meters(r);
else
r = r * 1000;
- loading = true;
- new AltosMapLoader(map.map, this,
- latitude, longitude,
- min_z, max_z, r, all_types());
+ loader = new AltosMapLoader(map.map, this,
+ latitude, longitude,
+ min_z, max_z, r, all_types());
} catch (ParseException pe) {
load_button.setSelected(false);