-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 {