00001 package commandline.baseMeshGeneration.delaunaypackage; 00002 import java.awt.Checkbox; 00003 import java.awt.Event; 00004 import java.awt.GridLayout; 00005 import java.awt.Label; 00006 import java.awt.Panel; 00007 import java.awt.TextField; 00008 /* 00009 * AlgorithmUI class. Each algorithm has a set of user interface 00010 * controls. This class provides them. 00011 */ 00012 class AlgorithmUI extends Panel { 00013 TextField nPointsTextField; 00014 // Checkbox animateCheckBox[]; 00015 Checkbox runCheckBox; 00016 // TextField pauseTextField; 00017 TriangulationAlgorithm algorithm; // Algorithm which uses this UI. 00018 00019 public AlgorithmUI(TriangulationAlgorithm algorithm, 00020 String label, int nPoints /*, int pause*/) { 00021 00022 this.algorithm = algorithm; 00023 00024 // One set of controls per algorithm. 00025 setLayout(new GridLayout(0,7)); 00026 add(new Label(label, Label.LEFT)); 00027 add(runCheckBox = new Checkbox(null, null, true)); 00028 add(nPointsTextField = new TextField(String.valueOf(nPoints), 5)); 00029 // animateCheckBox = new Checkbox[AnimateControl.nEntities]; 00030 // animateCheckBox[AnimateControl.triangles] = new Checkbox(null, null, true); 00031 // add(animateCheckBox[AnimateControl.triangles]); 00032 // animateCheckBox[AnimateControl.circles] = new Checkbox(null, null, true); 00033 // add(animateCheckBox[AnimateControl.circles]); 00034 // animateCheckBox[AnimateControl.points] = new Checkbox(null, null, true); 00035 // add(animateCheckBox[AnimateControl.points]); 00036 // pauseTextField = new TextField(String.valueOf(pause), 5); 00037 // add(pauseTextField); 00038 } 00039 00040 public void setAlgorithm(TriangulationAlgorithm algorithm) { 00041 this.algorithm = algorithm; 00042 } 00043 00044 // Gets the current value in a text field. 00045 int getValue(TextField tF) { 00046 int i; 00047 try { 00048 i = Integer.valueOf(tF.getText()).intValue(); 00049 } catch (java.lang.NumberFormatException e) { 00050 i = 0; 00051 } 00052 return i; 00053 } 00054 00055 public boolean handleEvent(Event evt) { 00056 // if (evt.id == Event.ACTION_EVENT) { 00057 // if (evt.target == runCheckBox) { 00058 // algorithm.control().setRun(((Boolean)evt.arg).booleanValue()); 00059 // return true; 00060 // } else if (evt.target == animateCheckBox[AnimateControl.triangles]) { 00061 // algorithm.control().setAnimate(AnimateControl.triangles, 00062 // ((Boolean)evt.arg).booleanValue()); 00063 // return true; 00064 // } else if (evt.target == animateCheckBox[AnimateControl.circles]) { 00065 // algorithm.control().setAnimate(AnimateControl.circles, 00066 // ((Boolean)evt.arg).booleanValue()); 00067 // return true; 00068 // } else if (evt.target == animateCheckBox[AnimateControl.points]) { 00069 // algorithm.control().setAnimate(AnimateControl.points, 00070 // ((Boolean)evt.arg).booleanValue()); 00071 // return true; 00072 // } else if (evt.target == pauseTextField) { 00073 // algorithm.control().setPause(getValue(pauseTextField)); 00074 // return true; 00075 // } else if (evt.target == nPointsTextField) { 00076 // algorithm.control().nPoints = getValue(nPointsTextField); 00077 // return true; 00078 // } 00079 // } 00080 00081 return false; 00082 } 00083 }
1.5.5