}
}
-class AltosUISite {
- String name;
- double latitude;
- double longitude;
-
- public String toString() {
- return name;
- }
-
- public AltosUISite(String in_name, double in_latitude, double in_longitude) {
- name = in_name;
- latitude = in_latitude;
- longitude = in_longitude;
- }
-
- public AltosUISite(String line) throws ParseException {
- String[] elements = line.split(":");
-
- if (elements.length < 3)
- throw new ParseException(String.format("Invalid site line %s", line), 0);
-
- name = elements[0];
-
- try {
- latitude = AltosParse.parse_double_net(elements[1]);
- longitude = AltosParse.parse_double_net(elements[2]);
- } catch (ParseException pe) {
- throw new ParseException(String.format("Invalid site line %s", line), 0);
- }
- }
-}
-
-class AltosUISites extends Thread {
- AltosUIMapPreloadNew preload;
- URL url;
- LinkedList<AltosUISite> sites;
-
- void notify_complete() {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- preload.set_sites();
- }
- });
- }
-
- void add(AltosUISite site) {
- sites.add(site);
- }
-
- void add(String line) {
- try {
- add(new AltosUISite(line));
- } catch (ParseException pe) {
- System.out.printf("parse exception %s\n", pe.toString());
- }
- }
-
- public void run() {
- try {
- URLConnection uc = url.openConnection();
- //int length = uc.getContentLength();
-
- InputStreamReader in_stream = new InputStreamReader(uc.getInputStream(), AltosLib.unicode_set);
- BufferedReader in = new BufferedReader(in_stream);
-
- for (;;) {
- String line = in.readLine();
- if (line == null)
- break;
- add(line);
- }
- } catch (IOException e) {
- } finally {
- notify_complete();
- }
- }
-
- public AltosUISites(AltosUIMapPreloadNew in_preload) {
- sites = new LinkedList<AltosUISite>();
- preload = in_preload;
- try {
- url = new URL(AltosLib.launch_sites_url);
- } catch (java.net.MalformedURLException e) {
- notify_complete();
- }
- start();
- }
-}
-
-public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener, ItemListener, AltosMapTileListener {
+public class AltosUIMapPreloadNew extends AltosUIFrame implements ActionListener, ItemListener, AltosMapTileListener, AltosLaunchSiteListener {
AltosUIFrame owner;
AltosUIMapNew map;
AltosMapCache cache;
int pbar_max;
int pbar_cur;
- AltosUISites sites;
JLabel site_list_label;
- JComboBox<AltosUISite> site_list;
+ JComboBox<AltosLaunchSite> site_list;
JToggleButton load_button;
boolean loading;
JButton close_button;
- JCheckBox[] maptypes = new JCheckBox[AltosUIMap.maptype_terrain - AltosUIMap.maptype_hybrid + 1];
+ JCheckBox[] maptypes = new JCheckBox[AltosMap.maptype_terrain - AltosMap.maptype_hybrid + 1];
JComboBox<Integer> min_zoom;
JComboBox<Integer> max_zoom;
private void do_load() {
tiles_loaded = 0;
- map.set_zoom(cur_z + AltosUIMapView.default_zoom);
+ map.set_zoom(cur_z + AltosMap.default_zoom);
map.set_maptype(cur_type);
map.set_load_params(latitude, longitude, r, this);
}
private int next_type(int start) {
int next_type;
for (next_type = start;
- next_type <= AltosUIMap.maptype_terrain && (all_types & (1 << next_type)) == 0;
+ next_type <= AltosMap.maptype_terrain && (all_types & (1 << next_type)) == 0;
next_type++)
;
return next_type;
private void next_load() {
int next_type = next_type(cur_type + 1);
- if (next_type > AltosUIMap.maptype_terrain) {
+ if (next_type > AltosMap.maptype_terrain) {
if (cur_z == max_z) {
return;
} else {
cur_z = min_z;
int ntype = 0;
all_types = 0;
- for (int t = AltosUIMap.maptype_hybrid; t <= AltosUIMap.maptype_terrain; t++)
+ for (int t = AltosMap.maptype_hybrid; t <= AltosMap.maptype_terrain; t++)
if (maptypes[t].isSelected()) {
all_types |= (1 << t);
ntype++;
}
if (ntype == 0) {
- all_types |= (1 << AltosUIMap.maptype_hybrid);
+ all_types |= (1 << AltosMap.maptype_hybrid);
ntype = 1;
}
public AltosMapCache cache() { return cache; }
- public void set_sites() {
- int i = 1;
- for (AltosUISite site : sites.sites) {
- site_list.insertItemAt(site, i);
- i++;
- }
- }
-
public void itemStateChanged(ItemEvent e) {
int state = e.getStateChange();
if (state == ItemEvent.SELECTED) {
Object o = e.getItem();
- if (o instanceof AltosUISite) {
- AltosUISite site = (AltosUISite) o;
+ if (o instanceof AltosLaunchSite) {
+ AltosLaunchSite site = (AltosLaunchSite) o;
lat.set_value(site.latitude);
lon.set_value(site.longitude);
}
}
}
+ public void notify_launch_sites(final java.util.List<AltosLaunchSite> sites) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ int i = 1;
+ for (AltosLaunchSite site : sites) {
+ site_list.insertItemAt(site, i);
+ i++;
+ }
+ }
+ });
+ }
+
public AltosUIMapPreloadNew(AltosUIFrame in_owner) {
owner = in_owner;
pane.add(site_list_label, c);
- site_list = new JComboBox<AltosUISite>(new AltosUISite[] { new AltosUISite("Site List", 0, 0) });
+ site_list = new JComboBox<AltosLaunchSite>(new AltosLaunchSite[] { new AltosLaunchSite("Site List", 0, 0) });
site_list.addItemListener(this);
- sites = new AltosUISites(this);
+ new AltosLaunchSites(this);
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.CENTER;
c.gridwidth = 1;
- for (int type = AltosUIMap.maptype_hybrid; type <= AltosUIMap.maptype_terrain; type++) {
- maptypes[type] = new JCheckBox(AltosUIMap.maptype_labels[type],
- type == AltosUIMap.maptype_hybrid);
+ for (int type = AltosMap.maptype_hybrid; type <= AltosMap.maptype_terrain; type++) {
+ maptypes[type] = new JCheckBox(AltosMap.maptype_labels[type],
+ type == AltosMap.maptype_hybrid);
c.gridx = 2 + (type >> 1);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridy = (type & 1) + 3;