X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosuilib%2FAltosUIMapPreload.java;h=6d0d8b70576e881cae6ec9473eccad5627acd424;hp=326900372638515ad53b47415d4ca268fa7ae02f;hb=HEAD;hpb=f982248573c1b646ac53fde980a60ada5404f6aa diff --git a/altosuilib/AltosUIMapPreload.java b/altosuilib/AltosUIMapPreload.java index 32690037..6d0d8b70 100644 --- a/altosuilib/AltosUIMapPreload.java +++ b/altosuilib/AltosUIMapPreload.java @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,7 +16,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_11; +package org.altusmetrum.altosuilib_14; import java.awt.*; import java.awt.event.*; @@ -26,7 +27,7 @@ import java.text.*; import java.lang.Math; import java.net.URL; import java.net.URLConnection; -import org.altusmetrum.altoslib_11.*; +import org.altusmetrum.altoslib_14.*; class AltosUIMapPos extends Box implements ActionListener { AltosUIMapPreload preload; @@ -138,12 +139,15 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I JProgressBar pbar; JLabel site_list_label; + java.util.List sites; JComboBox site_list; JToggleButton load_button; JButton close_button; +/* JCheckBox[] maptypes = new JCheckBox[AltosMap.maptype_terrain - AltosMap.maptype_hybrid + 1]; +*/ JComboBox min_zoom; JComboBox max_zoom; @@ -214,17 +218,39 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I private int all_types() { +/* int all_types = 0; for (int t = AltosMap.maptype_hybrid; t <= AltosMap.maptype_terrain; t++) if (maptypes[t].isSelected()) all_types |= (1 << t); return all_types; +*/ + return 1 << AltosMap.maptype_hybrid; + } + + void add_mark(double lat, double lon, int state, String label) { + map.add_mark(lat, lon, state, label); + } + + void reset_marks() { + map.clear_marks(); + AltosLatLon centre = null; + String centre_name = null; + if (map != null && map.map != null) + centre = map.map.centre; + for (AltosLaunchSite site : sites) { + if (centre != null && centre.lat == site.latitude && centre.lon == site.longitude) + centre_name = site.name; + else + add_mark(site.latitude, site.longitude, AltosLib.ao_flight_main, site.name); + } + if (centre != null) + add_mark(centre.lat, centre.lon, AltosLib.ao_flight_boost, centre_name); } void center_map(double latitude, double longitude) { map.map.centre(new AltosLatLon(latitude, longitude)); - map.clear_marks(); - map.add_mark(latitude, longitude, AltosLib.ao_flight_boost); + reset_marks(); } void center_map() { @@ -288,6 +314,7 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I } public void notify_launch_sites(final java.util.List sites) { + this.sites = sites; SwingUtilities.invokeLater(new Runnable() { public void run() { int i = 1; @@ -295,6 +322,7 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I site_list.insertItemAt(site, i); i++; } + reset_marks(); } }); } @@ -330,7 +358,7 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I public AltosUIMapPreload(AltosUIFrame in_owner) { owner = in_owner; - Container pane = getContentPane(); + Container pane = getScrollablePane(); GridBagConstraints c = new GridBagConstraints(); Insets i = new Insets(4,4,4,4); @@ -484,6 +512,7 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I pane.add(close_button, c); +/* JLabel types_label = new JLabel("Map Types"); c.gridx = 2; c.gridwidth = 2; @@ -500,6 +529,7 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I c.gridy = (type & 1) + 3; pane.add(maptypes[type], c); } +*/ JLabel min_zoom_label = new JLabel("Minimum Zoom"); c.gridx = 4;