00001 package commandline; 00002 00003 import java.io.File; 00004 import java.io.FileNotFoundException; 00005 import java.io.IOException; 00006 import java.util.ArrayList; 00007 00008 import commandline.Encoder.Mesh_Save_Type_Enumeration; 00009 import commandline.Encoder.ProgressEvent; 00010 import commandline.Encoder.ProgressListener; 00011 import commandline.Encoder.RecodingListener; 00012 import commandline.Encoder.Iterators.RefinementListener; 00013 import commandline.NormalMeshAlgorithm.Configuration; 00014 import commandline.debuggingCode.Debug; 00015 00021 public abstract class Program implements ProgramControlListener{ 00022 00023 private ArrayList<ProgressListener> progressListenerList; 00024 protected RecodingListener recodingListener; 00025 volatile boolean stopRequested; 00026 public Program() { 00027 stopRequested=false; 00028 this.progressListenerList=new ArrayList<ProgressListener>(); 00029 this.recodingListener=null; 00030 } 00031 00035 public void registerRecodingListener(RecodingListener recodingListener ){ 00036 this.recodingListener=recodingListener; 00037 } 00038 00039 00040 public void unRegisterRecodingsListener(){ 00041 this.recodingListener=null; 00042 } 00043 00044 00051 public abstract Program getNewProgram(Configuration configuration) throws FileNotFoundException; 00052 00058 public abstract void save(Mesh_Save_Type_Enumeration INSTRUCTION, File f) throws IOException; 00059 00060 00061 public abstract Mesh_Save_Type_Enumeration[] getSaveEnumeration(); 00062 00063 public void perform(){} 00064 00066 public void addProgressListener(ProgressListener progressListener){ 00067 this.progressListenerList.add(progressListener); 00068 } 00069 00075 public void removeProgressListener(){ 00076 this.progressListenerList.clear(); 00077 } 00078 00079 public void updateProgressListeners(ProgressEvent progressEvent){ 00080 for(ProgressListener progressListener:progressListenerList){ 00081 progressListener.updateProgress(progressEvent); 00082 } 00083 } 00084 00086 public void requestStop(){ 00087 stopRequested=true; 00088 Debug.print(this.getClass().getSimpleName() + " received a requested to stop. showStop="+ stopRequested); 00089 } 00090 00091 public boolean isStopRequested(){ 00092 return stopRequested; 00093 } 00094 00096 protected ArrayList<RefinementListener> refinementListenerList=new ArrayList<RefinementListener>(); 00097 public void registerRefinementEventListenerToMeshIterator(RefinementListener listener){ 00098 00099 00100 } 00101 00105 public void unregisterRefinementEventListeners(){ 00106 this.refinementListenerList.clear(); 00107 } 00108 00109 00110 00111 }
1.5.5