import java.awt.*;
import java.util.*;
import java.io.*;

public class GPSView extends Canvas implements Runnable {
  Vector recentLocations = new Vector();
  GPSView gpsv;
  private Image offScreenImage;
  private Graphics offScreenGraphics;
  private Dimension offScreenSize;


  public static void main(String arg[]){
    new GPSView();
  }

  GPSView (){
    Frame f = new Frame();
    f.setBounds(0,0,500,500);
    f.add(this);
    f.pack();
    f.show();
    (new Thread(this)).start();
  }

  public void run() {
    BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    while (true){
      String coords = new String("");
      double lat, lon;
      try { coords = in.readLine(); } catch (Exception e) { } 
      if(coords == null){
	continue;
      }
      st = new StringTokenizer(coords); 
      lat = 2000*((Double.valueOf(st.nextToken())).doubleValue()-37.7);
      lon = 2000*((Double.valueOf(st.nextToken())).doubleValue()-122.3);
      recentLocations.addElement(new GPSLocation(lat, lon));
      //      if(recentLocations.size() > 500){
      //	recentLocations.removeElementAt(0);
      //      }
      repaint();
      try { Thread.sleep(100); } catch (Exception e) { }
    }
  }

  public final synchronized void update (Graphics theG)
    {
      Dimension d = size();
      if((offScreenImage == null) || (d.width != offScreenSize.width) ||
         (d.height != offScreenSize.height)) 
        {
          offScreenImage = createImage(d.width, d.height);
          offScreenSize = d;
          offScreenGraphics = offScreenImage.getGraphics();
          offScreenGraphics.setFont(getFont());
        }
      offScreenGraphics.fillRect(0,0,d.width, d.height);
      paint(offScreenGraphics);
      theG.drawImage(offScreenImage, 0, 0, null);
    }

  public void paint (Graphics g){
    int ct=0;
    g.setColor(Color.black);
    for(Enumeration e = recentLocations.elements(); e.hasMoreElements(); ){
      GPSLocation gl;
      ct++;
      if(ct > (recentLocations.size()-20)){
	g.setColor(Color.red);
      }
      gl = ((GPSLocation) e.nextElement());
      gl.draw(g);
    }
    g.setColor(Color.gray);
  }
}

class GPSLocation {
  double lat, lon;

  GPSLocation(double l1, double l2){
    lat = l1;
    lon = l2;
  }

  public void draw(Graphics g){
    g.drawArc((int) (500-lon), (int) (500-lat), 2, 2, 0, 360);
  }
}
