Treeviz 0.37 2010-10-17

ch.randelshofer.gui
Class ProgressTracker

java.lang.Object
  extended by ch.randelshofer.gui.ProgressTracker
All Implemented Interfaces:
ProgressObserver

public class ProgressTracker
extends java.lang.Object
implements ProgressObserver

ProgressTracker implements ProgressObserver without providing visual components for the user.

Version:
2.0 2009-03-23 Updated to new ProgressObserver interface.
1.0 2008-07-05 Created.
Author:
Werner Randelshofer

Constructor Summary
ProgressTracker(java.lang.String message, java.lang.String note)
          Creates new form ProgressTracker
ProgressTracker(java.lang.String message, java.lang.String note, int min, int max)
          Creates new form ProgressTracker
 
Method Summary
 void cancel()
          Cancels the operation.
 void close()
          Indicate that the operation is complete.
 void complete()
          Indicate that the operation is complete.
 java.lang.String getError()
          Specifies the error message that is displayed along with the progress message.
 int getMaximum()
          Returns the maximum value -- the higher end of the progress value.
 int getMinimum()
          Returns the minimum value -- the lower end of the progress value.
 javax.swing.BoundedRangeModel getModel()
           
 java.lang.String getNote()
          Specifies the additional note that is displayed along with the progress message.
 int getProgress()
          Returns the progress of the operation being monitored.
 java.lang.String getWarning()
          Specifies the warning message that is displayed along with the progress message.
 boolean isCanceled()
          Returns true if the user has hit the Cancel button in the progress dialog.
 boolean isClosed()
          Returns true if the ProgressTracker is closed.
 boolean isCompleted()
          Returns true if the operation is completed.
 boolean isIndeterminate()
          Returns true if the progress observer is set to indeterminate.
 void setCancelable(boolean b)
          Set cancelable to false if the operation can not be canceled.
 void setDoCancel(java.lang.Runnable doCancel)
          The specified Runnable is executed when the user presses the cancel button.
 void setError(java.lang.String message)
          Specifies the additional error message that is displayed along with the progress message.
 void setIndeterminate(boolean newValue)
          Sets the progress observer to indeterminate.
 void setMaximum(int m)
          Specifies the maximum value.
 void setMinimum(int m)
          Specifies the minimum value.
 void setModel(javax.swing.BoundedRangeModel brm)
           
 void setNote(java.lang.String note)
          Specifies the additional note that is displayed along with the progress message.
 void setProgress(int nv)
          Indicate the progress of the operation being monitored.
 void setWarning(java.lang.String message)
          Specifies the additional warning message that is displayed along with the progress message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgressTracker

public ProgressTracker(java.lang.String message,
                       java.lang.String note,
                       int min,
                       int max)
Creates new form ProgressTracker


ProgressTracker

public ProgressTracker(java.lang.String message,
                       java.lang.String note)
Creates new form ProgressTracker

Method Detail

setIndeterminate

public void setIndeterminate(boolean newValue)
Description copied from interface: ProgressObserver
Sets the progress observer to indeterminate.

Specified by:
setIndeterminate in interface ProgressObserver

setModel

public void setModel(javax.swing.BoundedRangeModel brm)
Specified by:
setModel in interface ProgressObserver

getModel

public javax.swing.BoundedRangeModel getModel()
Specified by:
getModel in interface ProgressObserver

setCancelable

public void setCancelable(boolean b)
Set cancelable to false if the operation can not be canceled.

Specified by:
setCancelable in interface ProgressObserver

setDoCancel

public void setDoCancel(java.lang.Runnable doCancel)
The specified Runnable is executed when the user presses the cancel button.

Specified by:
setDoCancel in interface ProgressObserver

setProgress

public void setProgress(int nv)
Indicate the progress of the operation being monitored. If the specified value is >= the maximum, the progress monitor is closed.

Specified by:
setProgress in interface ProgressObserver
Parameters:
nv - an int specifying the current value, between the maximum and minimum specified for this component
See Also:
setMinimum(int), setMaximum(int), close()

getProgress

public int getProgress()
Returns the progress of the operation being monitored.

Specified by:
getProgress in interface ProgressObserver

close

public void close()
Indicate that the operation is complete. This happens automatically when the value set by setProgress is >= max, but it may be called earlier if the operation ends early.

Specified by:
close in interface ProgressObserver

getMinimum

public int getMinimum()
Returns the minimum value -- the lower end of the progress value.

Specified by:
getMinimum in interface ProgressObserver
Returns:
an int representing the minimum value
See Also:
setMinimum(int)

setMinimum

public void setMinimum(int m)
Specifies the minimum value.

Specified by:
setMinimum in interface ProgressObserver
Parameters:
m - an int specifying the minimum value
See Also:
getMinimum()

getMaximum

public int getMaximum()
Returns the maximum value -- the higher end of the progress value.

Specified by:
getMaximum in interface ProgressObserver
Returns:
an int representing the maximum value
See Also:
setMaximum(int)

setMaximum

public void setMaximum(int m)
Specifies the maximum value.

Specified by:
setMaximum in interface ProgressObserver
Parameters:
m - an int specifying the maximum value
See Also:
getMaximum()

isCanceled

public boolean isCanceled()
Returns true if the user has hit the Cancel button in the progress dialog.

Specified by:
isCanceled in interface ProgressObserver

isClosed

public boolean isClosed()
Returns true if the ProgressTracker is closed.

Specified by:
isClosed in interface ProgressObserver

cancel

public void cancel()
Cancels the operation. This method must be invoked from the user event dispatch thread.

Specified by:
cancel in interface ProgressObserver

setNote

public void setNote(java.lang.String note)
Specifies the additional note that is displayed along with the progress message. Used, for example, to show which file the is currently being copied during a multiple-file copy.

Specified by:
setNote in interface ProgressObserver
Parameters:
note - a String specifying the note to display
See Also:
getNote()

getNote

public java.lang.String getNote()
Specifies the additional note that is displayed along with the progress message.

Specified by:
getNote in interface ProgressObserver
Returns:
a String specifying the note to display
See Also:
setNote(java.lang.String)

isIndeterminate

public boolean isIndeterminate()
Description copied from interface: ProgressObserver
Returns true if the progress observer is set to indeterminate.

Specified by:
isIndeterminate in interface ProgressObserver

complete

public void complete()
Description copied from interface: ProgressObserver
Indicate that the operation is complete. This happens automatically when the value set by setProgress is >= max, but it may be called earlier if the operation ends early.

Specified by:
complete in interface ProgressObserver

isCompleted

public boolean isCompleted()
Description copied from interface: ProgressObserver
Returns true if the operation is completed.

Specified by:
isCompleted in interface ProgressObserver

setWarning

public void setWarning(java.lang.String message)
Description copied from interface: ProgressObserver
Specifies the additional warning message that is displayed along with the progress message. Used, for example, to show which files couldn't be copied during a multiple-file copy..

Specified by:
setWarning in interface ProgressObserver
Parameters:
message - a String specifying the message to display, or null if there is no warning.
See Also:
ProgressObserver.getWarning()

getWarning

public java.lang.String getWarning()
Description copied from interface: ProgressObserver
Specifies the warning message that is displayed along with the progress message.

Specified by:
getWarning in interface ProgressObserver
Returns:
a String specifying the message to display, or null if there is no warning.

setError

public void setError(java.lang.String message)
Description copied from interface: ProgressObserver
Specifies the additional error message that is displayed along with the progress message. Used, for example, to show which files couldn't be copied during a multiple-file copy..

Specified by:
setError in interface ProgressObserver
Parameters:
message - a String specifying the message to display, or null if there is no error.
See Also:
ProgressObserver.getWarning()

getError

public java.lang.String getError()
Description copied from interface: ProgressObserver
Specifies the error message that is displayed along with the progress message.

Specified by:
getError in interface ProgressObserver
Returns:
a String specifying the message to display, or null if there is no error.

Copyright 2007-2008 (c) Werner Randelshofer.
All rights reserved.