org.geotools.util
Interface ProgressListener

All Superinterfaces:
ProgressListener

Deprecated. Please use org.opengis.util.ProgressListener

public interface ProgressListener
extends ProgressListener

Monitor the progress of some lengthly operation. This interface makes no assumption about the output device. It may be the standard output stream (see ProgressPrinter implementation), a window (ProgressWindow) or mails automatically sent to some address (ProgressMailer). Additionnaly, this interface provides support for non-fatal warning and exception reports.

All ProgressListener implementations are multi-thread safe, even the Swing implemention. ProgressListener can be invoked from any thread, which never need to be the Swing's thread. This is usefull for performing lenghtly operation in a background thread. Example:

  ProgressListener p = new ProgressPrinter();
  p.setDecription("Loading data");
  p.start();
  for (int j=0; j<1000; j++) {
      // ... some process...
      if ((j & 255) == 0)
          p.progress(j/10f);
  }
  p.complete();
 
Note: The line if ((j & 255) == 0) is used for reducing the amount of calls to progress(float) (only once every 256 steps). This is not mandatory, but may speed up the process.

Here is another example showing how to cancel:


      Iterator iterator = null;
      try{
          float size = size();
          float position = 0;
          progress.started();
          for( iterator = iterator(); !progress.isCanceled() && iterator.hasNext(); progress.progress( (position++)/size )){
              try {
                  Feature feature = (Feature) iterator.next();
                  visitor.visit(feature);
              }
              catch( Exception erp ){
                  progress.exceptionOccurred( erp );
              }
          }
          progress.complete();
      }
      finally {
          close( iterator );
      }
 
Note the use of try and catch to report exceptions.

Since:
2.0
Author:
Martin Desruisseaux (PMO, IRD)
See Also:
ProgressPrinter, ProgressMailer, ProgressWindow, ProgressMonitor
Module:

Method Summary
 void complete()
          Deprecated. Notifies this listener that the operation has finished.
 void dispose()
          Deprecated. Release any resources used by this listener.
 void exceptionOccurred(Throwable exception)
          Deprecated. Reports an exception.
 String getDescription()
          Deprecated. Returns the description for the lengthly operation to be reported, or null if none.
 boolean isCanceled()
          Deprecated. Is this job canceled?
 void progress(float percent)
          Deprecated. Notifies this listener of progress in the lengthly operation.
 void setCanceled(boolean cancel)
          Deprecated. Indicate that progress should is canceled.
 void setDescription(String description)
          Deprecated. Set the description for the lenghtly operation to be reported.
 void started()
          Deprecated. Notifies this listener that the operation begins.
 void warningOccurred(String source, String margin, String warning)
          Deprecated. Reports a warning.
 
Methods inherited from interface ProgressListener
getProgress, getTask, setTask
 

Method Detail

getDescription

String getDescription()
Deprecated. 
Returns the description for the lengthly operation to be reported, or null if none.

Specified by:
getDescription in interface ProgressListener

setDescription

void setDescription(String description)
Deprecated. 
Set the description for the lenghtly operation to be reported. This method is usually invoked before any progress begins. However, it is legal to invoke this method at any time during the operation, in which case the description display is updated without any change to the percentage accomplished.

Specified by:
setDescription in interface ProgressListener
Parameters:
description - The new description, or null if none.

started

void started()
Deprecated. 
Notifies this listener that the operation begins.

Specified by:
started in interface ProgressListener

progress

void progress(float percent)
Deprecated. 
Notifies this listener of progress in the lengthly operation. Progress are reported as a value between 0 and 100 inclusive. Values out of bounds will be clamped.

Specified by:
progress in interface ProgressListener

complete

void complete()
Deprecated. 
Notifies this listener that the operation has finished. The progress indicator will shows 100% or disaspears, at implementor choice. If warning messages were pending, they will be displayed now.

Specified by:
complete in interface ProgressListener

dispose

void dispose()
Deprecated. 
Release any resources used by this listener. If the progress were reported in a window, this window may be disposed.

Specified by:
dispose in interface ProgressListener

isCanceled

boolean isCanceled()
Deprecated. 
Is this job canceled?

Specified by:
isCanceled in interface ProgressListener

setCanceled

void setCanceled(boolean cancel)
Deprecated. 
Indicate that progress should is canceled.

Specified by:
setCanceled in interface ProgressListener

warningOccurred

void warningOccurred(String source,
                     String margin,
                     String warning)
Deprecated. 
Reports a warning. This warning may be printed to the standard error stream, appears in a windows or be ignored, at implementor choice.

Specified by:
warningOccurred in interface ProgressListener
Parameters:
source - The source of the warning, or null if none. This is typically the filename in process of being parsed.
margin - Text to write on the left side of the warning message, or null if none. This is typically the line number where the error occured in the source file.
warning - The warning message.

exceptionOccurred

void exceptionOccurred(Throwable exception)
Deprecated. 
Reports an exception. This method may prints the stack trace to the standard error stream or display it in a dialog box, at implementor choice.

Specified by:
exceptionOccurred in interface ProgressListener


Copyright © 1996-2009 Geotools. All Rights Reserved.