import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.Vector; public class drawmap extends Canvas implements MouseListener { protected Vector cities, roads; protected double minla, maxla, minlo, maxlo; protected int mousex, mousey; protected Font fo; 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 drawmap() throws Exception { 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; FileReader fr=new FileReader("cities.txt"); 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(); fr=new FileReader("roads.txt"); 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