Package org.geotools.swing
Class JProgressWindow
- Object
-
- JProgressWindow
-
- All Implemented Interfaces:
ProgressListener
public class JProgressWindow extends Object implements ProgressListener
Reports progress of a lengthly operation in a window. This implementation can also format warnings. Its method can be invoked from any thread (it doesn't need to be the Swing thread), which make it easier to use it from some background thread. Such background thread should have a low priority in order to avoid delaying Swing repaint events.- Since:
- 2.0
- Author:
- Martin Desruisseaux
-
-
Constructor Summary
Constructors Constructor Description JProgressWindow(Component parent)Creates a window for reporting progress.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomplete()Notifies that the operation has finished.voiddispose()Releases any resource holds by this window.voidexceptionOccurred(Throwable exception)Display an exception stack trace.floatgetProgress()Returns the current progress as a percent completed.InternationalStringgetTask()Returns the description of the current task being performed, ornullif none.StringgetTitle()Returns the window title.booleanisCanceled()Returnstrueif this job is cancelled.voidprogress(float percent)Notifies this listener of progress in the lengthly operation.voidsetCanceled(boolean stop)Indicates that task should be cancelled.voidsetTask(InternationalString task)Sets the description of the current task being performed.voidsetTitle(String title)Set the window title.voidstarted()Notifies that the operation begins.voidwarningOccurred(String source, String margin, String warning)Display a warning message under the progress bar.
-
-
-
Method Detail
-
getTitle
public String getTitle()
Returns the window title. The default title is "Progress" localized in current locale.- Returns:
- the window title
-
setTitle
public void setTitle(String title)
Set the window title. Anullvalue reset the default title.- Parameters:
title- the window title
-
setTask
public void setTask(InternationalString task)
Description copied from interface:ProgressListenerSets 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.- Specified by:
setTaskin interfaceProgressListener- Parameters:
task- Description of the task being performed, ornullif none.
-
started
public void started()
Notifies that the operation begins. This method display the windows if it was not already visible.- Specified by:
startedin interfaceProgressListener
-
progress
public 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.- Specified by:
progressin interfaceProgressListener- Parameters:
percent- The progress as a value between 0 and 100 inclusive.
-
getProgress
public float getProgress()
Description copied from interface:ProgressListenerReturns the current progress as a percent completed.- Specified by:
getProgressin interfaceProgressListener- Returns:
- Percent completed between 0 and 100 inclusive.
-
complete
public void complete()
Notifies that the operation has finished. The window will disaspears, except if it contains warning or exception stack traces.- Specified by:
completein interfaceProgressListener
-
dispose
public void dispose()
Releases any resource holds by this window. Invoking this method destroy the window.- Specified by:
disposein interfaceProgressListener
-
isCanceled
public boolean isCanceled()
Returnstrueif this job is cancelled.- Specified by:
isCanceledin interfaceProgressListener- Returns:
trueif this job is cancelled.
-
setCanceled
public void setCanceled(boolean stop)
Indicates that task should be cancelled.- Specified by:
setCanceledin interfaceProgressListener- Parameters:
stop- true to stop; false otherwise
-
warningOccurred
public void warningOccurred(String source, String margin, String warning)
Display a warning message under the progress bar. The text area for warning messages appears only the first time this method is invoked.- Specified by:
warningOccurredin interfaceProgressListener- Parameters:
source- DOCUMENT MEmargin- DOCUMENT MEwarning- DOCUMENT ME
-
exceptionOccurred
public void exceptionOccurred(Throwable exception)
Display an exception stack trace.- Specified by:
exceptionOccurredin interfaceProgressListener- Parameters:
exception- the exception to display
-
getTask
public InternationalString getTask()
Description copied from interface:ProgressListenerReturns 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.- Specified by:
getTaskin interfaceProgressListener- Returns:
- Description of the task being performed, or
nullif none.
-
-