public class DefaultProgressReporter extends java.lang.Object implements ProgressReporter
ProgressReporter
interface. Can be used as a base class for
implementing ProgressReporter interface. Alternatively, it can be instantiated and used as a help
object to manage and notify listeners of a ProgressEvent.Constructor and Description |
---|
DefaultProgressReporter() |
Modifier and Type | Method and Description |
---|---|
void |
addProgressListener(ProgressListener l)
Add progress listener.
|
double |
currentProgress()
Report what fraction of the processing task was already completed.
|
protected void |
notifyProgressListeners()
Notify listeners of current value of progress.
|
protected void |
notifyProgressListeners(double progress)
Set new progress value and notify listeners.
|
protected void |
notifyProgressListeners(double progress,
java.lang.String message)
Set new progress value and notify listeners.
|
void |
removeAllProgressListener()
Remove all progress listener.
|
void |
removeProgressListener(ProgressListener l)
Remove progress listener.
|
protected void |
setCurrentProgress(double progress)
Update value of
currentProgress , value must be not less than 0 and not more than 1. |
public double currentProgress()
ProgressReporter
currentProgress
in interface ProgressReporter
public void addProgressListener(ProgressListener l)
ProgressReporter
addProgressListener
in interface ProgressReporter
l
- listener to add.public void removeProgressListener(ProgressListener l)
ProgressReporter
removeProgressListener
in interface ProgressReporter
l
- listener to remove.public void removeAllProgressListener()
ProgressReporter
removeAllProgressListener
in interface ProgressReporter
protected void setCurrentProgress(double progress)
currentProgress
, value must be not less than 0 and not more than 1.
This method is used when progress needs to be updated without notifying the listeners.
To update progress and update listeners use notifyProgressListeners(double)
.progress
- new value of currentProgress
. The value must be not less than 0 and not more than 1.notifyProgressListeners()
,
notifyProgressListeners(double)
,
notifyProgressListeners(double, String)
protected void notifyProgressListeners()
notifyProgressListeners(double)
protected void notifyProgressListeners(double progress)
setCurrentProgress(double)
and notifyProgressListeners()
.
Progress message is an empty string.progress
- new value of currentProgress
. The value must be not less than 0 and not more than 1.setCurrentProgress(double)
,
notifyProgressListeners()
protected void notifyProgressListeners(double progress, java.lang.String message)
progress
- new value of currentProgress
. The value must be not less than 0 and not more than 1.message
- message that will be send to listeners within {#link ProgressEvent}