jwo.landserf.process
Class LSThread

java.lang.Object
  extended by java.lang.Thread
      extended by jwo.landserf.process.LSThread
All Implemented Interfaces:
Runnable, JWInterruptionListener
Direct Known Subclasses:
BasinThread, BasinThread2, CentroidThread, CombinePointsWithRasterThread, CombineThread, ContourThread, DeleteThread, DemToTinThread, DispThread, FlowThread, FracSurfaceThread, FuzzyFeatureThread, JoinVectorThread, OpenThread, PeakClassificationThread, PitRemovalThread, PointDensityThread, PolySurfaceThread, ProjectionThread, RectifyThread, SaveThread, ScaleParamThread, SelectVectorThread, SimplifyThread, 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.3, 4th August, 2006.
Author:
Jo Wood

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
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 setFinalMessage(String m)
          Sets the final message once the processing has been completed.
 void setMessage(String m)
          Deprecated. This method has been deprecated in favour of setFinalMessage(). To send messages before the completion of a process, use setMessage() in GISFrame instead.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, 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
Overrides:
run in class Thread

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)
Deprecated. This method has been deprecated in favour of setFinalMessage(). To send messages before the completion of a process, use setMessage() in GISFrame instead.

Sets the final message once the processing has been completed.

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

setFinalMessage

public void setFinalMessage(String m)
Sets the final message once the processing has been completed. To send messages before the completion of a process, use setMessage() in GISFrame instead.

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 always 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 inherently 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-2009, last modified, 17th April, 2009