+ synchronized (lock) {
+ double childrenProgress = relativeProgress - relativeLocalProgress;
+
+ relativeLocalProgress = ((double) progress) / (max - min);
+
+ setRelativeProgress(this, name, relativeLocalProgress
+ + childrenProgress);
+ }
+ }
+
+ /**
+ * 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() {
+ return relativeProgress;
+ }
+
+ /**
+ * Set the total progress value (including the optional children
+ * {@link Progress}), on a 0 to 1 scale.
+ *
+ * @param pg
+ * the {@link Progress} to report as the progression emitter
+ * @param name
+ * the current name (if it is NULL, the first non-null name in
+ * the hierarchy will overwrite it) of the {@link Progress} who
+ * emitted this change
+ * @param relativeProgress
+ * the progress to set
+ */
+ private void setRelativeProgress(Progress pg, String name,
+ double relativeProgress) {
+ synchronized (lock) {
+ relativeProgress = Math.max(0, relativeProgress);
+ relativeProgress = Math.min(1, relativeProgress);
+ this.relativeProgress = relativeProgress;
+
+ changed(pg, name);
+ }
+ }
+
+ /**
+ * Get the total progress value (including the optional children
+ * {@link Progress}) on a 0 to 1 scale.
+ *
+ * @return the progress the value
+ */
+ private int getLocalProgress() {
+ return (int) Math.round(relativeLocalProgress * (max - min));
+ }
+
+ /**
+ * Add some value to the current progression of this {@link Progress}.
+ *
+ * @param step
+ * the amount to add
+ */
+ public void add(int step) {
+ synchronized (lock) {
+ setProgress(getLocalProgress() + step);
+ }