jwo.landserf.process
Class LSThread

java.lang.Object
  extended byjava.lang.Thread
      extended byjwo.landserf.process.LSThread
All Implemented Interfaces:
JWInterruptionListener, Runnable
Direct Known Subclasses:
CombineThread, ContourThread, DeleteThread, DemToTinThread, DispThread, FracSurfaceThread, FuzzyFeatureThread, OpenThread, PeakClassificationThread, PitRemovalThread, PointDensityThread, PolySurfaceThread, ProjectionThread, RectifyThread, SaveThread, ScaleParamThread, SurfaceFeatureThread, SurfNetworkThread, SurfParamThread, TinPointsThread, TinToDemThread, TransRastThread, UpdateThread, VectorToRasterThread, View3dThread, VoidRemovalThread

public abstract class LSThread
extends Thread
implements JWInterruptionListener

Processing thread that times itself and allows messages to be logged. Any class that inherits this must place the body of the thread in the doProcessing method.

Version:
2.2, 5th December, 2004.
Author:
Jo Wood

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LSThread(String startMessage, GISFrame gisFrame)
          Creates thread and stores GISFrame to store output and report progress and any error/info messages generated by the process.
 
Method Summary
 boolean checkStoppedThread()
          Reports whether a request has been made to stop or pause this thread.
abstract  void doProcessing()
          Abstract method that will contain processing.
 void interruptionRequested()
          Responds to a request for an interruption to this process.
 void resetTimer()
          Resets the timer for threads that have GUI processes that shouldn't contribute to the time of the process.
 void run()
          Starts the thread's processing and reports on progress.
 void setErrorMessage(String m)
          Sets an error message to be displayed once the thread has completed.
 void setMessage(String m)
          Sets the final message once the processing has been completed.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LSThread

public LSThread(String startMessage,
                GISFrame gisFrame)
Creates thread and stores GISFrame to store output and report progress and any error/info messages generated by the process.

Parameters:
startMessage - Message to display when thread starts.
gisFrame - Frame that called the thread.
Method Detail

run

public void run()
Starts the thread's processing and reports on progress. Calls the doProcessing() method.

Specified by:
run in interface Runnable

resetTimer

public void resetTimer()
Resets the timer for threads that have GUI processes that shouldn't contribute to the time of the process.


doProcessing

public abstract void doProcessing()
Abstract method that will contain processing. This method is called automatically whenever a class that inherits this one is run as a threaded process.


setMessage

public void setMessage(String m)
Sets the final message once the processing has been completed.

Parameters:
m - Message to display when processing has been completed.

setErrorMessage

public void setErrorMessage(String m)
Sets an error message to be displayed once the thread has completed.

Parameters:
m - Error message to display.

interruptionRequested

public void interruptionRequested()
Responds to a request for an interruption to this process.

Specified by:
interruptionRequested in interface JWInterruptionListener

checkStoppedThread

public boolean checkStoppedThread()
Reports whether a request has been made to stop or pause this thread. If a pause request has been made, this method will sleep until the a request to resume or stop the thread has been made. If this process is not threaded, this method will alsway return false. This method should be called at regular intervals from within the doProcessing method loop to allow it to be stopped or paused externally with a graceful exit. This approach is used in preference to the inherantly unsafe (and deprecated) methods stop(), suspend() and resume().

Returns:
True if a request has been made to stop this (assuming it is a threaded process).


Copyright Jo Wood, 1996-2005, last modified, 11th March, 2005