00001
00002 package delaunaypackage;
00003 import java.awt.*;
00004 import java.applet.*;
00005
00006
00007
00008 public class TriangulationApplet extends Applet implements Runnable {
00009 Thread triangulateThread[];
00010 int nPoints = 10;
00011 Triangulation triangulation;
00012 TriangulationAlgorithm algorithm;
00013 RealWindow w;
00014 RealWindowGraphics rWG;
00015 AppletUI appUI;
00016 public static final int On2 = 0;
00017
00018 Panel canvases;
00019 static final int nAlgorithms = 1;
00020
00021 public void init() {
00022
00023 setBackground(Color.lightGray);
00024 resize(600,350);
00025
00026
00027 w = new RealWindow(0.0f, 0.0f, 1.0f, 1.0f);
00028
00029
00030 triangulation = new Triangulation(w,nPoints);
00031
00032
00033
00034
00035
00036 algorithm = new QuadraticAlgorithm(triangulation, w, nPoints);
00037
00038
00039
00040 Panel heading = new Panel();
00041 heading.setLayout(new BorderLayout());
00042 heading.add("Center", new Label("The Triangulator", Label.CENTER));
00043 Panel algHeadings = new Panel();
00044 algHeadings.setLayout(new GridLayout(0, nAlgorithms));
00045 heading.add("South", algHeadings);
00046 canvases = new Panel();
00047 canvases.setLayout(new GridLayout(0, nAlgorithms));
00048 for (int i = 0; i < nAlgorithms; i++)
00049 canvases.add(algorithm.canvas());
00050 setLayout(new BorderLayout());
00051 add("North", heading);
00052 add("Center", canvases);
00053 appUI = new AppletUI(new TriangulationAlgorithm[]{ algorithm});
00054 add("South", appUI);
00055 }
00056
00057
00058
00059
00060 public void run() {
00061
00062 }
00063
00064 public Insets insets() {
00065
00066 return new Insets(5,10,5,15);
00067 }
00068
00069
00070
00071
00072 private synchronized void startTriangulate() {
00073 algorithm.triangulate(triangulation);
00074
00075 }
00076
00077
00078 public synchronized void stop() {
00079
00080 }
00081
00082
00083
00084
00085
00086
00087 public boolean handleEvent(Event evt) {
00088 if (evt.id == Event.ACTION_EVENT) {
00089 if ("Start".equals(evt.arg)) {
00090 startTriangulate();
00091 return true;
00092 }
00093 }
00094 return false;
00095 }
00096 }