Package ca.cgjennings.algo
Class ProgressRangeAdapter
- java.lang.Object
-
- ca.cgjennings.algo.ProgressRangeAdapter
-
- All Implemented Interfaces:
ProgressListener,java.util.EventListener
public class ProgressRangeAdapter extends java.lang.Object implements ProgressListener
An adapter that can be wrapped around a progress listener to scale the update messages it receives to a certain range.- Author:
- Chris Jennings
-
-
Constructor Summary
Constructors Constructor Description ProgressRangeAdapter(float rangeLow, float rangeHigh, ProgressListener adaptee)Creates a new range adapter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanprogressUpdate(java.lang.Object source, float progress)Called to indicate that an algorithm has made progress towards completion.
-
-
-
Constructor Detail
-
ProgressRangeAdapter
public ProgressRangeAdapter(float rangeLow, float rangeHigh, ProgressListener adaptee)Creates a new range adapter. The input progress range of 0..1 will be mapped to the rangerangeLow..rangeHighbefore passing the progress message on to the adaptee.- Parameters:
rangeLow- the progress value to report when the input progress is 0rangeHigh- the progress value to report when the input progress is 1adaptee- the listener that the adapted range will be forwarded to- Throws:
java.lang.IllegalArgumentException- if the range values are out of the allowed range of progress values (0 to 1), or ifrangeLow > rangeHighjava.lang.NullPointerException- if the adaptee isnull
-
-
Method Detail
-
progressUpdate
public boolean progressUpdate(java.lang.Object source, float progress)Description copied from interface:ProgressListenerCalled to indicate that an algorithm has made progress towards completion. If the listener returnstrue, it is a hint that the operation should be cancelled if possible.- Specified by:
progressUpdatein interfaceProgressListener- Parameters:
source- the source of the progress eventprogress- a value between 0 (none) and 1 (algorithm complete)- Returns:
trueif the callee wishes to hint that the algorithm be cancelled
-
-