HiRISE

HiRISE.HiCat.Utilities
Class Progress_Monitor

java.lang.Object
  extended by HiRISE.HiCat.Utilities.Progress_Monitor

public class Progress_Monitor
extends Object

This class is a progress monitor that functions as the data model for the Progress_Dialog class. When this class is instantiated, a thread can call the the Current(String, int) method to update the status of the task. The monitor will then fire a change event which will cause any Progress_Monitor dialogs listening to the monitor to update themselves to reflect the updated status of the running task.

This class is based on some GPL code written by Santhosh Kumar T. The original code can be found at http://jroller.com/santhosh/entry/show_progress_in_modal_dialog.

Version:
1.1
Author:
Rodney Heyd UA/PIRL
See Also:
Progress_Dialog, Progress_Utility

Field Summary
static int DEFAULT_MILLISECONDS_TO_WAIT
          The default wait time before firing the first progress event.
static String DEFAULT_MONITOR_NAME
          The default monitor name;
static String ID
          Class Identifier
 
Constructor Summary
Progress_Monitor(int total, boolean indeterminate)
          Create a new Progress_Monitor given the total progress and indeterminate progress status, with a default wait time of 500 milliseconds.
Progress_Monitor(int total, boolean indeterminate, int milliSecondsToWait, String name)
          Create a new Progress_Monitor given the total progress, indeterminate progress status, and the time to wait before
 
Method Summary
 void addChangeListener(ChangeListener listener)
          Add an object that will listen to the monitor for status updates.
 int Current()
          Get the current progress value.
 void Current(String status, int current)
          This method should be called from within the task being monitored to indicate the progress of the task.
 boolean Indeterminate()
           
 int Milliseconds_To_Wait()
          Return the number of milliseconds the monitor will wait before firing the first change event that will cause a monitor dialog to be shown.
 String Name()
          Get the name of the monitor.
 void Name(String name)
          Set the name of the monitor.
 void removeChangeListener(ChangeListener listener)
          Remove an object from listening to the monitor
 void Start(String status)
          Begin monitoring the task.
 String Status()
          A status string indicating giving information about the task being monitored.
 void Status(String status)
           
 int Total()
          Get the total size of the task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final String ID
Class Identifier

See Also:
Constant Field Values

DEFAULT_MILLISECONDS_TO_WAIT

public static final int DEFAULT_MILLISECONDS_TO_WAIT
The default wait time before firing the first progress event.

See Also:
Constant Field Values

DEFAULT_MONITOR_NAME

public static final String DEFAULT_MONITOR_NAME
The default monitor name;

See Also:
Constant Field Values
Constructor Detail

Progress_Monitor

public Progress_Monitor(int total,
                        boolean indeterminate,
                        int milliSecondsToWait,
                        String name)
Create a new Progress_Monitor given the total progress, indeterminate progress status, and the time to wait before

Parameters:
total - An integer specifying the total scale of progress
indeterminate - A boolean specify if the amount of progress is indeterminate
milliSecondsToWait - The time to wait before firing the first change event.
name - An identifier for this dialog. The Progress_Dialog may use this name to identify the task being monitored.

Progress_Monitor

public Progress_Monitor(int total,
                        boolean indeterminate)
Create a new Progress_Monitor given the total progress and indeterminate progress status, with a default wait time of 500 milliseconds.

Parameters:
total -
indeterminate -
Method Detail

Name

public void Name(String name)
Set the name of the monitor.

Parameters:
name -

Name

public String Name()
Get the name of the monitor.

Returns:
A string containing the name of the monitor.

Total

public int Total()
Get the total size of the task. Usually this is the number of iterations through the loop of some thread.

Returns:
an integer containing the total size of the task being monitored

Start

public void Start(String status)
Begin monitoring the task. This method should be called at the start of a thread being monitored.

Parameters:
status - A String containing the initial status of the task being monitored.

Milliseconds_To_Wait

public int Milliseconds_To_Wait()
Return the number of milliseconds the monitor will wait before firing the first change event that will cause a monitor dialog to be shown. If a task completes prior to this length of time, the dialog will not be shown.

Returns:
an integer containing the number of seconds to wait before firing the first status change event.

Current

public int Current()
Get the current progress value.

Returns:
an integer that measures the current progress of the task being monitored.

Status

public String Status()
A status string indicating giving information about the task being monitored.

Returns:
the task status string

Status

public void Status(String status)

Indeterminate

public boolean Indeterminate()
Returns:
true if the task being monitored is of an indeterminate length, false otherwise.

Current

public void Current(String status,
                    int current)
This method should be called from within the task being monitored to indicate the progress of the task.

Parameters:
status - A string indicating the status of the task
current - An integer indicating the progress of the task.

addChangeListener

public void addChangeListener(ChangeListener listener)
Add an object that will listen to the monitor for status updates.

Parameters:
listener - the object that will listen to the monitor for changes

removeChangeListener

public void removeChangeListener(ChangeListener listener)
Remove an object from listening to the monitor

Parameters:
listener -

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona