import java.awt.*; import java.awt.event.*; import java.io.*; import java.applet.*; import java.net.*; import java.util.Vector; import javax.swing.ImageIcon; public class drawmapapp extends Applet implements MouseListener { protected Vector cities, roads; protected double minla, maxla, minlo, maxlo; protected int mousex, mousey; protected Font fo; protected Image background; protected int xoff, yoff; public class city { public String nm; public double la, lo; public city(String a, double b, double c) { nm=a; la=b; lo=c; } } public class road { public String nm; public double len; public city a, b; public road(String n, double l, city x, city y) { nm=n; len=l; a=x; b=y; } } public drawmapapp() {try { xoff=123; yoff=5; addMouseListener(this); fo=new Font("Monospaced",Font.PLAIN,12); mousex=0; mousey=0; cities=new Vector(); roads=new Vector(); minla=999.9; minlo=999.9; maxla=-999.9; maxlo=-999.9; background=new ImageIcon(new URL("http://rabbit.eng.miami.edu/class/een511/background.gif")).getImage(); URL citiesurl=new URL("http://rabbit.eng.miami.edu/class/een511/cities.txt"); InputStream is=citiesurl.openStream(); InputStreamReader fr=new InputStreamReader(is); BufferedReader in=new BufferedReader(fr); while (true) { String s=in.readLine(); String o=s; if (s==null) break; s=s.trim(); if (s.equals("")) continue; int p=s.indexOf(' '); if (p<0) { System.out.println("Ignoring "+o); continue; } String nm=s.substring(0,p); s=s.substring(p).trim(); p=s.indexOf(' '); if (p<0) { System.out.println("Ignoring "+o); continue; } double la=new Double(s.substring(0,p)).doubleValue(); s=s.substring(p).trim(); p=s.indexOf(' '); if (p>=0) s=s.substring(0,p); double lo=new Double(s).doubleValue(); if (la<0 || lo<0) { System.out.println("Ignoring "+o); continue; } if (lamaxla) maxla=la; if (lomaxlo) maxlo=lo; cities.add(new city(nm,la,lo)); } in.close(); fr.close(); is.close(); URL roadsurl=new URL("http://rabbit.eng.miami.edu/class/een511/roads.txt"); is=roadsurl.openStream(); fr=new InputStreamReader(is); in=new BufferedReader(fr); while (true) { String s=in.readLine(); String o=s; if (s==null) break; s=s.trim(); if (s.equals("")) continue; int p=s.indexOf(' '); if (p<0) { System.out.println("Ignoring "+o); continue; } String nm=s.substring(0,p), ca="", cb=""; s=s.substring(p).trim(); p=s.indexOf(' '); if (p<0) { System.out.println("Ignoring "+o); continue; } double le=new Double(s.substring(0,p)).doubleValue(); s=s.substring(p).trim(); p=s.indexOf(' '); if (p>=0) { ca=s.substring(0,p); s=s.substring(p).trim(); p=s.indexOf(' '); if (p>=0) cb=s.substring(0,p); else cb=s; } if (ca.equals("") || cb.equals("")) { System.out.println("Ignoring "+o); continue; } city a=null, b=null; int n=cities.size(); for (int i=0; iMath.PI) dirdif=2.0*Math.PI-dirdif; if (dirdif