|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface 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 org.geotools.gui.headless.ProgressPrinter
implementation),
a window (org.geotools.gui.swing.ProgressWindow
) or mails automatically
sent to some address (org.geotools.gui.headless.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:
Note: The lineProgressListener p = neworg.geotools.gui.headless.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();
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.
org.geotools.gui.headless.ProgressPrinter
,
org.geotools.gui.headless.ProgressMailer
,
org.geotools.gui.swing.ProgressWindow
,
ProgressMonitor
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 |
---|
String getDescription()
null
if none.
getDescription
in interface ProgressListener
void setDescription(String description)
setDescription
in interface ProgressListener
description
- The new description, or null
if none.void started()
started
in interface ProgressListener
void progress(float percent)
progress
in interface ProgressListener
percent
- The progress as a value between 0 and 100 inclusive.void complete()
complete
in interface ProgressListener
void dispose()
dispose
in interface ProgressListener
boolean isCanceled()
isCanceled
in interface ProgressListener
true
if this job is cancelled.void setCanceled(boolean cancel)
setCanceled
in interface ProgressListener
cancel
- true
for cancelling the task.void warningOccurred(String source, String margin, String warning)
warningOccurred
in interface ProgressListener
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.void exceptionOccurred(Throwable exception)
exceptionOccurred
in interface ProgressListener
exception
- The exception to report.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |