00001 package commandline.baseMeshGeneration.delaunaypackage; 00002 /* 00003 * TriangulationAlgorithm class. Absract. Superclass for 00004 * actual algorithms. Has several abstract function members - 00005 * including the triangulation member which actually computes 00006 * the triangulation. 00007 */ 00008 abstract class TriangulationAlgorithm { 00009 String algName; 00010 TriangulationCanvas triCanvas; 00011 // AnimateControl aniControl; 00012 AlgorithmUI algorithmUI; 00013 RealWindow w; 00014 RealWindowGraphics rWG; 00015 00016 // Variables and constants for animation state. 00017 final int nStates = 5; 00018 boolean state[] = new boolean[nStates]; 00019 static final int triangulationState = 0; 00020 static final int pointState = 1; 00021 static final int triangleState = 2; 00022 static final int insideState = 4; 00023 static final int edgeState = 5; 00024 00025 00026 public TriangulationAlgorithm(){ 00027 00028 } 00029 00030 public TriangulationAlgorithm(Triangulation t, RealWindow w, 00031 String name, int nPoints) { 00032 algName = name; 00033 // aniControl = new AnimateControl(this, nPoints); 00034 algorithmUI = new AlgorithmUI(this, name, nPoints /*, aniControl.getPause()*/); 00035 triCanvas = new TriangulationCanvas(t, w, this); 00036 00037 for (int s = 0; s < nStates; s++) 00038 state[s] = false; 00039 triCanvas.needToClear = true; 00040 } 00041 00042 public void setCanvas(TriangulationCanvas tc) { 00043 triCanvas = tc; 00044 } 00045 00046 // public AnimateControl control() { 00047 // return aniControl; 00048 // } 00049 00050 public AlgorithmUI algorithmUI() { 00051 return algorithmUI; 00052 } 00053 00054 public TriangulationCanvas canvas() { 00055 return triCanvas; 00056 } 00057 00058 public void setAlgorithmState(int stateVar, boolean value) { 00059 state[stateVar] = value; 00060 } 00061 00062 public void pause() { 00063 // if (aniControl.mode() == AnimateControl.automatic) 00064 // try { 00065 // wait(aniControl.getPause()); 00066 // } catch (InterruptedException e){} 00067 // else 00068 // try {wait();} catch (InterruptedException e){} 00069 } 00070 00071 // public void animate(int state) { 00072 // if ((aniControl.animate(AnimateControl.triangles) || 00073 // aniControl.animate(AnimateControl.circles)) && 00074 // state == triangulationState) 00075 // triCanvas.needToClear = true; 00076 // 00077 // setAlgorithmState(state, true); 00078 // 00079 // triCanvas.repaint(); 00080 // 00081 // pause(); 00082 // 00083 // setAlgorithmState(state, false); 00084 // } 00085 00086 public void reset() { 00087 for (int s = 0; s < nStates; s++) 00088 state[s] = false; 00089 triCanvas.needToClear = true; 00090 } 00091 00092 public synchronized void nextStep() { notify(); } 00093 public synchronized void triangulate(Triangulation t){} 00094 public synchronized void 00095 draw(RealWindowGraphics rWG, Triangulation t){} 00096 }
1.5.5