public synchronized void mousePressed(MouseEvent mouseevent) {
   MyPoint mypoint = new MyPoint(mouseevent.getPoint());
   if (mypoint.x > (double) XPos) {
     Voronoi.addElement(mypoint);
     Voronoi.checkDegenerate();
     Events.insert(new EventPoint(mypoint));
     repaint();
   }
 }
 public synchronized void init() {
   offScreenImage = createImage(getBounds().width, getBounds().height);
   offScreenGraphics = offScreenImage.getGraphics();
   XPos = 0;
   Arcs = new ArcTree();
   Events = new EventQueue();
   Voronoi.clear();
   Delaunay = new DelaunayClass();
   for (int i = 0; i < Voronoi.size(); i++) {
     Events.insert(new EventPoint((MyPoint) Voronoi.elementAt(i)));
   }
 }
 public synchronized void step() {
   EventPoint eventpoint = Events.pop();
   if (eventpoint != null) {
     XPos = Math.max(XPos, (int) eventpoint.x);
     eventpoint.action(this);
   } else if (XPos < getBounds().width) {
     XPos = getBounds().width;
   } else {
     init();
   }
   Arcs.checkBounds(this, XPos);
   repaint();
 }
  public synchronized boolean singlestep() {
    if (Events.Events == null || (double) XPos < Events.Events.x) XPos++;

    while (Events.Events != null && (double) XPos >= Events.Events.x) {
      EventPoint eventpoint = Events.pop();
      XPos = Math.max(XPos, (int) eventpoint.x);
      eventpoint.action(this);
      Arcs.checkBounds(this, XPos);
    }

    if (XPos > getBounds().width && Events.Events == null) Arcs.checkBounds(this, XPos);

    repaint();
    return Events.Events != null || XPos < 1000 + getBounds().width;
  }
 public synchronized void paint(Graphics g) {
   g.setColor(Color.white);
   g.fillRect(0, 0, getBounds().width, getBounds().height);
   g.setColor(Color.blue);
   Voronoi.paint(g, drawVoronoiLines);
   g.setColor(Color.red);
   g.drawLine(XPos, 0, XPos, getBounds().height);
   if (Events != null && Arcs != null) {
     g.setColor(Color.black);
     Events.paint(g, drawCircles);
     Arcs.paint(g, XPos, drawVoronoiLines, drawBeach);
   }
   if (drawDelaunay) {
     g.setColor(Color.gray);
     Delaunay.paint(g);
   }
 }