}
}
+ /**
+ * Add some value to the current progression of this {@link Progress}.
+ *
+ * @param step
+ * the amount to add
+ */
+ public void add(int step) {
+ synchronized (getLock()) {
+ setProgress(localProgress + step);
+ }
+ }
+
/**
* Check if the action corresponding to this {@link Progress} is done (i.e.,
* if its progress value == its max value).
return progress >= max;
}
+ /**
+ * Mark the {@link Progress} as done by setting its value to max.
+ */
+ public void done() {
+ setProgress(getMax());
+ }
+
/**
* Get the total progress value (including the optional children
* {@link Progress}) on a 0.0 to 1.0 scale.
* @return the progress
*/
public double getRelativeProgress() {
+ if (max == min) {
+ return 1;
+ }
+
return (((double) progress) / (max - min));
}
* the progress to set
*/
private void setTotalProgress(Progress pg, String name, int progress) {
+ // TODO: name is not used... and this is probably a bug in this case
synchronized (getLock()) {
progress = Math.max(min, progress);
progress = Math.min(max, progress);
}
progress.addProgressListener(new ProgressListener() {
+ @Override
public void progress(Progress pg, String name) {
synchronized (getLock()) {
double total = ((double) localProgress) / (max - min);