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