git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
VERSION 2.1.0: new options on IOUtils
[fanfix.git]
/
src
/
be
/
nikiroo
/
utils
/
Progress.java
diff --git
a/src/be/nikiroo/utils/Progress.java
b/src/be/nikiroo/utils/Progress.java
index b6137f18bf6144d72f186b8e93b6bd70768846b5..2872530b68542585783467e3241835072e75570a 100644
(file)
--- a/
src/be/nikiroo/utils/Progress.java
+++ b/
src/be/nikiroo/utils/Progress.java
@@
-227,6
+227,18
@@
public class Progress {
}
}
}
}
+ /**
+ * 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).
/**
* Check if the action corresponding to this {@link Progress} is done (i.e.,
* if its progress value == its max value).
@@
-237,6
+249,13
@@
public class Progress {
return progress >= max;
}
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.
/**
* Get the total progress value (including the optional children
* {@link Progress}) on a 0.0 to 1.0 scale.
@@
-244,6
+263,10
@@
public class Progress {
* @return the progress
*/
public double getRelativeProgress() {
* @return the progress
*/
public double getRelativeProgress() {
+ if (max == min) {
+ return 1;
+ }
+
return (((double) progress) / (max - min));
}
return (((double) progress) / (max - min));
}
@@
-271,6
+294,7
@@
public class Progress {
* the progress to set
*/
private void setTotalProgress(Progress pg, String name, int progress) {
* 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);
synchronized (getLock()) {
progress = Math.max(min, progress);
progress = Math.min(max, progress);
@@
-356,6
+380,7
@@
public class Progress {
}
progress.addProgressListener(new ProgressListener() {
}
progress.addProgressListener(new ProgressListener() {
+ @Override
public void progress(Progress pg, String name) {
synchronized (getLock()) {
double total = ((double) localProgress) / (max - min);
public void progress(Progress pg, String name) {
synchronized (getLock()) {
double total = ((double) localProgress) / (max - min);