use of edu.cmu.cs.hcii.cogtool.uimodel.PERTChartOperatorBar.PERTStepDependency in project cogtool by cogtool.
the class PERTPanel method setResultSteps.
public void setResultSteps(List<ResultStep> steps, List<String> resourceLabels) {
// First remove seleciton halos
Iterator<SelectionHalo> haloIterator = selectionBoxes.iterator();
SelectionHalo deadHalo = null;
while (haloIterator.hasNext()) {
deadHalo = haloIterator.next();
contents.remove(deadHalo);
deadHalo.dispose();
}
selectionBoxes.clear();
// Then remove existing operator bars
Iterator<PERTChartOperatorBar> barIt = bars.iterator();
PERTChartOperatorBar deadBar = null;
while (barIt.hasNext()) {
deadBar = barIt.next();
Iterator<PERTStepDependency> depIt = deadBar.getDependencies().iterator();
while (depIt.hasNext()) {
PERTStepDependency deadDependency = depIt.next();
contents.remove(deadDependency);
}
contents.remove(deadBar);
//deadBar.dispose();
}
bars.clear();
Iterator<ResultStep> stepIterator = steps.iterator();
ResultStep step;
PERTChartOperatorBar bar;
// create a map so that we can copy the dependency structure from the
// ResultSteps to the PERTChartOperatorBars
// TODO: save this state, and use this instead of bars
Map<ResultStep, PERTChartOperatorBar> barMap = new HashMap<ResultStep, PERTChartOperatorBar>();
List<PERTChartOperatorBar> operators = new ArrayList<PERTChartOperatorBar>();
// iterate through once and create operator bars
while (stepIterator.hasNext()) {
step = stepIterator.next();
bar = new PERTChartOperatorBar(step, resourceLabels, barHeight);
bar.setColorWithMap(colorMap);
barMap.put(step, bar);
bars.add(bar);
if (bar.isCascade()) {
contents.add(bar);
} else {
operators.add(bar);
}
// coompare to find the total time
totalTime = Math.max(totalTime, step.startTime + step.duration);
}
// iterator through operators, and add them now:
Iterator<PERTChartOperatorBar> opIter = operators.iterator();
while (opIter.hasNext()) {
contents.add(opIter.next());
}
// iterate through again setting dependencies on each bar object
// based on the dependencies in each ResultStep object
ResultStep.ResultStepDependency rStepDep;
Iterator<ResultStep.ResultStepDependency> depStepIter;
stepIterator = steps.iterator();
double ntvTotalTime = 0.0d;
while (stepIterator.hasNext()) {
step = stepIterator.next();
bar = barMap.get(step);
depStepIter = step.getDependencies().iterator();
ntvTotalTime = Math.max(ntvTotalTime, step.startTime + step.duration);
while (depStepIter.hasNext()) {
rStepDep = depStepIter.next();
PERTChartOperatorBar otherBar = barMap.get(rStepDep.dependency);
PERTStepDependency dep = bar.addDependency(otherBar, rStepDep);
contents.add(dep);
connections.add(dep);
}
}
nativeTotalTime = ntvTotalTime;
totalTime = nativeTotalTime;
numRows = resourceLabels.size();
resizeVisualization(null);
}
Aggregations