bodhidharma.utilities
Class ProgressBarTaskMonitor

java.lang.Object
  extended by bodhidharma.utilities.ProgressBarTaskMonitor
Direct Known Subclasses:
ProgressBarTaskFeatureExtractionMonitor

public abstract class ProgressBarTaskMonitor
extends java.lang.Object

An abstract class that is used by ProgressBarDialog windows in order to perform the processing that is measured by the window as well as keep the window updated.

All parts of this class are implemented here except for the go method. This method shoulud use a SwingWorker object to start and perform the task to be performed. It should also keep the current_amount_completed, time_started, task_completed, task_completed, task_canceled, progress_message and error_message fields updated so that they can be queried by the calling ProgressBarDialog.

The part of the class implemented here essentially provides an interface for the calling ProgressBarDialog and calculates the time elapsed and the estimated processing time remaining. The get and is methods can be called to get updates on how the process is progressing. The stop method can be called in order to stop processing if the process is to be cancelled.

See Also:
ProgressBarDialog, SwingWorker
Author:
Cory McKay

Field Summary
protected  int current_amount_completed
           
protected  java.lang.String error_message
           
protected  int length_of_task
           
protected  java.lang.String progress_message
           
protected  boolean task_canceled
           
protected  boolean task_completed
           
protected  long time_started
           
 
Constructor Summary
ProgressBarTaskMonitor(int number_of_sub_tasks)
          Basic constructor that sets the overall task to complete as well as the total number of sub-tasks to be completed in the overall task.
 
Method Summary
 int getCurrentAmountCompleted()
          Called from a ProgressBarDialog to find out how many sub-tasks have been done.
 java.lang.String getErrorMessage()
          Returns the most recent error message(s), or null if there is no current error message.
 int getLengthOfTask()
          Called from a ProgressBarDialog to find out how many sub-tasks remain to be done.
 java.lang.String getProgressMessage()
          Returns the most recent progress message(s), or null if there is no current progress message.
 java.lang.String getTimeMessage()
          Returns a String indicating how much time has already passed and the estimated time remaining.
abstract  void go()
          Called from ProgressBarDialog to start the overall task.
 boolean isCancelled()
          Called from a ProgressBarDialog to find out if the overall task has been cancelled.
 boolean isDone()
          Called from a ProgressBarDialog to find out if the overall task has completed.
 void stop()
          Called if the overall task is cancelled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

length_of_task

protected int length_of_task

current_amount_completed

protected int current_amount_completed

time_started

protected long time_started

task_completed

protected boolean task_completed

task_canceled

protected boolean task_canceled

progress_message

protected java.lang.String progress_message

error_message

protected java.lang.String error_message
Constructor Detail

ProgressBarTaskMonitor

public ProgressBarTaskMonitor(int number_of_sub_tasks)
Basic constructor that sets the overall task to complete as well as the total number of sub-tasks to be completed in the overall task. Also sets other private fields to defaluts.

NOTE: All sub-tasks are assumed to be of equal length in terms of processing duration.

Parameters:
number_of_sub_tasks - Number of sub-tasks that will need to be completed in all.
Method Detail

go

public abstract void go()
Called from ProgressBarDialog to start the overall task. Sets up a SwingWorker object to carry out the thread and sets time_started. Keeps the appropriate fields updated (see above).


getLengthOfTask

public int getLengthOfTask()
Called from a ProgressBarDialog to find out how many sub-tasks remain to be done.


getCurrentAmountCompleted

public int getCurrentAmountCompleted()
Called from a ProgressBarDialog to find out how many sub-tasks have been done.


isDone

public boolean isDone()
Called from a ProgressBarDialog to find out if the overall task has completed.


isCancelled

public boolean isCancelled()
Called from a ProgressBarDialog to find out if the overall task has been cancelled.


getTimeMessage

public java.lang.String getTimeMessage()
Returns a String indicating how much time has already passed and the estimated time remaining.


getProgressMessage

public java.lang.String getProgressMessage()
Returns the most recent progress message(s), or null if there is no current progress message. Sets progress_message to null if it is not already.


getErrorMessage

public java.lang.String getErrorMessage()
Returns the most recent error message(s), or null if there is no current error message. Sets error_message to null if it is not already.


stop

public void stop()
Called if the overall task is cancelled. Stops processing.