Package org.geotools.api.util
Interface ProgressListener
- All Known Implementing Classes:
DefaultProgressListener,DelegateProgressListener,DummyProgressListener,JProgressWindow,NullProgressListener,SubProgressListener
public interface ProgressListener
Monitor the progress of some lengthly operation, and allows cancelation. This interface makes no assumption about the
output device. Additionnaly, this interface provides support for non-fatal warning and exception reports.
All implementations should be multi-thread safe, even the ones that provide feedback to a user interface thread.
Usage example:
float scale = 100f / maximumCount;
listener.started();
for (int counter=0; counter<maximumCount; counter++) {
if (listener.isCanceled()) {
break;
}
listener.progress(scale * counter);
try {
// Do some work...
} catch (NonFatalException e) {
listener.exceptionOccurred(e);
}
}
listener.complete();
- Since:
- GeoAPI 2.1
- Author:
- Martin Desruisseaux, Jody Garnet
-
Method Summary
Modifier and TypeMethodDescriptionvoidcomplete()Notifies this listener that the operation has finished.voiddispose()Releases any resources used by this listener.voidexceptionOccurred(Throwable exception) Reports an exception.floatReturns the current progress as a percent completed.getTask()Returns the description of the current task being performed, ornullif none.booleanReturnstrueif this job is cancelled.voidprogress(float percent) Notifies this listener of progress in the lengthly operation.voidsetCanceled(boolean cancel) Indicates that task should be cancelled.voidsetTask(InternationalString task) Sets the description of the current task being performed.voidstarted()Notifies this listener that the operation begins.voidwarningOccurred(String source, String location, String warning) Reports a warning.
-
Method Details
-
getTask
InternationalString getTask()Returns the description of the current task being performed, ornullif none. It is assumed that if the task isnullapplications may simply report that the process is "in progress" or "working" as represented in the current locale.- Returns:
- Description of the task being performed, or
nullif none.
-
setTask
Sets the description of the current task being performed. 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.- Parameters:
task- Description of the task being performed, ornullif none.
-
started
void started()Notifies this listener that the operation begins. -
progress
void progress(float percent) 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.- Parameters:
percent- The progress as a value between 0 and 100 inclusive.
-
getProgress
float getProgress()Returns the current progress as a percent completed.- Returns:
- Percent completed between 0 and 100 inclusive.
- Since:
- GeoAPI 2.2
-
complete
void complete()Notifies this listener that the operation has finished. The progress indicator will shows 100% or disappears, at implementor choice. If warning messages were pending, they will be displayed now. -
dispose
void dispose()Releases any resources used by this listener. If the progress were reported in a window, this window may be disposed. -
isCanceled
boolean isCanceled()Returnstrueif this job is cancelled.- Returns:
trueif this job is cancelled.
-
setCanceled
void setCanceled(boolean cancel) Indicates that task should be cancelled.- Parameters:
cancel-truefor cancelling the task.
-
warningOccurred
Reports a warning. This warning may be logged, printed to the standard error stream, appears in a windows or be ignored, at implementor choice.- Parameters:
source- Name of the warning source, ornullif none. This is typically the filename in process of being parsed or the URL of the data being processedlocation- Text to write on the left side of the warning message, ornullif none. This is typically the line number where the error occured in thesourcefile or the feature ID of the feature that produced the messagewarning- The warning message.
-
exceptionOccurred
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.- Parameters:
exception- The exception to report.
-