|
ImageScience 3.0.0 | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectimagescience.utility.Progressor
public class Progressor
Wrapper around ImageJ's progress bar. This class offers several advantages over ImageJ's native progress displaying methods. First, it allows to make sure the progress bar is always updated (repainting can be enforced) if displaying is enabled, even when it is used from within the event dispatching thread (in which case the bar - drawn within ImageJ using that same thread - would otherwise not be updated until the process using the bar is finished). Furthermore, it relieves the user of explicitly computing the progress percentage (all this class requires is the total number of steps before the start of a process and the same number of step calls during the process). Also, it allows to specify the number of progress updates (by default 20
from start to end), thereby limiting the number of repaint calls (which are relatively expensive), and thus reducing execution time for progress displaying. Finally, it allows specifying the progress range (the minimum / maximum displayed progress value for the start / end of the corresponding process), which facilitates progress displaying for subprocesses.
Constructor Summary | |
---|---|
Progressor()
Default constructor. |
Method Summary | |
---|---|
boolean |
display()
Indicates whether progress is displayed. |
void |
display(boolean enable)
Determines whether progress is displayed. |
boolean |
enforce()
Indicates whether repainting of the progress bar is enforced. |
void |
enforce(boolean enable)
Determines whether repainting of the progress bar is enforced. |
double |
max()
Returns the maximum displayed progress value. |
void |
max(double max)
Specifies the maximum displayed progress value. |
double |
min()
Returns the minimum displayed progress value. |
void |
min(double min)
Specifies the minimum displayed progress value. |
Progressor |
parent()
Returns the parent object for progress displaying. |
void |
parent(Progressor parent)
Sets the parent object for progress displaying. |
void |
range(double min,
double max)
Specifies the minimum and maximum displayed progress value. |
void |
set(long n)
Sets the internal step counter to the given value. |
void |
start()
Starts the progress displaying. |
java.lang.String |
status()
Returns the status message. |
void |
status(java.lang.String status)
Sets the status message. |
void |
step()
Increases the internal step counter. |
void |
step(long n)
Increases the internal step counter by the given amount. |
long |
steps()
Returns the number of steps in the process. |
void |
steps(long n)
Specifies the number of steps in the process. |
void |
stop()
Stops the progress displaying. |
long |
updates()
Returns the number of progress updates displayed by the progress bar. |
void |
updates(long n)
Specifies the number of progress updates displayed by the progress bar. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Progressor()
Method Detail |
---|
public void updates(long n)
20
.
n
- The number of progress updates displayed by the progress bar.
java.lang.IllegalArgumentException
- If n
is less than 0
.public long updates()
public void steps(long n)
n
- The number of steps in the process.
java.lang.IllegalArgumentException
- If n
is less than 0
.public long steps()
public void step()
public void step(long n)
n
- The number of steps to be added to the internal step counter.
java.lang.IllegalArgumentException
- If n
is less than 0
.public void set(long n)
n
- The value to set the internal step counter to.
java.lang.IllegalArgumentException
- If n
is less than 0
.public void min(double min)
0
.
min
- The minimum displayed progress value.
java.lang.IllegalArgumentException
- If min
is less than 0
or larger than the maximum displayed progress value.public double min()
parent(Progressor)
, the returned value is the minimum of the present object, mapped to the progress range of the parent. This recurses through all layers of parenthood.
public void max(double max)
1
.
max
- The maximum displayed progress value.
java.lang.IllegalArgumentException
- If max
is larger than 1
or less than the minimum displayed progress value.public double max()
parent(Progressor)
, the returned value is the maximum of the present object, mapped to the progress range of the parent. This recurses through all layers of parenthood.
public void range(double min, double max)
0
and the default maximum is 1
.
min
- The minimum displayed progress value.max
- The maximum displayed progress value.
java.lang.IllegalArgumentException
- If min
is less than 0
or larger than max
, or if max
is larger than 1
.min()
,
min(double)
,
max()
,
max(double)
public void start()
public void stop()
public boolean display()
parent(Progressor)
, that object instead determines whether progress is displayed. This recurses through all layers of parenthood, so that effectively the returned value is that of the highest parent in the hierarchy.
true
if progress is displayed, or false
if this is not the case.public void display(boolean enable)
enable
- If true
(or false
) progress is (or is not) displayed.public boolean enforce()
parent(Progressor)
, that object instead determines whether repainting is enforced. This recurses through all layers of parenthood, so that effectively the returned value is that of the highest parent in the hierarchy.
true
if repainting of the progress bar is displayed, or false
if this is not the case.public void enforce(boolean enable)
enable
- If true
(or false
) repainting of the progress bar is (or is not) enforced.public void parent(Progressor parent)
display(boolean)
and enforce(boolean)
, and the minimum and maximum displayed progress values set using min(double)
and max(double)
or range(double,double)
are mapped to the progress range of the parent.
parent
- The parent object for progress displaying. Parameter value null
means no parent object is set.public Progressor parent()
null
(indicating no parent has been set) or a valid Progressor
object.public void status(java.lang.String status)
status
- The status message. Parameter value null
means no status message is displayed.public java.lang.String status()
parent(Progressor)
, and its status message is not null
, the returned value is the status message of the parent. This recurses through all layers of parenthood, so that effectively the returned value is that of the highest parent in the hierarchy whose status message is not null
, and if no such parent exists the returned value is null
.
null
(indicating no status message has been set) or a valid String
object.
|
ImageScience 3.0.0 | ||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright (C) Erik Meijering. Permission to use this software and corresponding documentation for educational, research, and not-for-profit purposes, without a fee and without a signed licensing agreement, is granted, subject to the following terms and conditions.
IT IS NOT ALLOWED TO REDISTRIBUTE, SELL, OR LEASE THIS SOFTWARE, OR DERIVATIVE WORKS THEREOF, WITHOUT PERMISSION IN WRITING FROM THE COPYRIGHT HOLDER. THE COPYRIGHT HOLDER IS FREE TO MAKE VERSIONS OF THE SOFTWARE AVAILABLE FOR A FEE OR COMMERCIALLY ONLY.
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OF ANY KIND WHATSOEVER, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE EXPRESS OR IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND CORRESPONDING DOCUMENTATION IS PROVIDED "AS IS". THE COPYRIGHT HOLDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.