public synchronized float computeCompletePortion() { if (isComplete()) { return 1; } // if (totalStepCount < 0) { // return -1; // } float realSteps = computeCompleteSteps(); if (realSteps < 0) { return -1; } if (realSteps == 0) { return 0; } if (totalStepCount < 0) { return -1; } else if (totalStepCount > 0) { return realSteps / ((float) totalStepCount); } else { return 1; } }
public synchronized float computeCompletePortion() { if (isComplete()) { return 1; } // if (totalStepCount < 0) { // return -1; // } float realSteps = computeCompleteSteps(); if (realSteps < 0) { return -1; } if (realSteps == 0) { return 0; } if (totalStepCount < 0) { return -1; } else if (totalStepCount > 0) { return realSteps / ((float) totalStepCount); } else { return 1; } }
protected synchronized float computeCompleteSteps() { if (isComplete()) { return totalStepCount; } float realStepCount = currentStepCount; for (ChildProgressStatus child : children) { float childPortion = child.progressStatus.computeCompletePortion(); if (childPortion < 0) { return -1; } realStepCount += ((float) child.getAllocatedSteps()) * childPortion; } return realStepCount; }
protected synchronized float computeCompleteSteps() { if (isComplete()) { return totalStepCount; } float realStepCount = currentStepCount; for (ChildProgressStatus child : children) { float childPortion = child.progressStatus.computeCompletePortion(); if (childPortion < 0) { return -1; } realStepCount += ((float) child.getAllocatedSteps()) * childPortion; } return realStepCount; }
private void mirror(ProgressStatusBase source, ProgressStatus stat) { stat.setTotalStepCount(source.getTotalStepCount()); stat.setCurrentStepCount(source.getCurrentStepCount()); if (source.isComplete()) { stat.complete(); } for (ProgressStatusBase.ChildProgressStatus chld : source.getChildProgressStatuses()) { ProgressStatus dst = map.get(chld.getProgressStatus().getId()); if (dst == null) { dst = stat.createChild(chld.getProgressStatus().getName(), chld.getAllocatedSteps()); map.put(chld.getProgressStatus().getId(), dst); } mirror(chld.getProgressStatus(), dst); } }