Program: 51826
Project: 51826
Buggy source:
private void initActivities(){
  if (activitiesInitialized())   return;
  activities=new ArrayList<ActivityComponent>();
  decisionMap=new ArrayList<DecisionWrapper>();
  activityWidgets=new ArrayList<TimelineView.ActivityWidget>();
  decisionWidgets=new ArrayList<TimelineView.DecisionWidget>();
  addAllActivitiesAndDecisionsRecursively(getManifestedComponent());
  ActivityWrapper root=new ActivityWrapper(null);
  replicateActivityTree(getManifestedComponent(),root);
  assignLevel(root);
  activityMap=new ArrayList<List<ActivityWrapper>>();
  populateActivityMap(root);
  assignLevelsForDecisions();
  TreeMap<Date,Double> powerChanges=new TreeMap<Date,Double>();
  TreeMap<Date,Double> commBandwidthChanges=new TreeMap<Date,Double>();
  for (  ActivityComponent activityComponent : activities) {
    ActivityData data=activityComponent.getModel().getData();
    Date startTime=data.getStartTime();
    Date endTime=data.getEndTime();
    if (globalStartTime == null) {
      globalStartTime=startTime;
      globalEndTime=endTime;
    }
 else {
      if (startTime.before(globalStartTime))       globalStartTime=startTime;
      if (endTime.after(globalEndTime))       globalEndTime=endTime;
    }
    if (powerChanges.containsKey(data.getStartTime()))     powerChanges.put(data.getStartTime(),data.getPower() + powerChanges.get(data.getStartTime()));
 else     powerChanges.put(data.getStartTime(),data.getPower());
    if (powerChanges.containsKey(data.getEndTime()))     powerChanges.put(data.getEndTime(),powerChanges.get(data.getEndTime()) - data.getPower());
 else     powerChanges.put(data.getEndTime(),(-1) * data.getPower());
    if (commBandwidthChanges.containsKey(data.getStartTime()))     commBandwidthChanges.put(data.getStartTime(),data.getComm() + commBandwidthChanges.get(data.getStartTime()));
 else     commBandwidthChanges.put(data.getStartTime(),data.getComm());
    if (commBandwidthChanges.containsKey(data.getEndTime()))     commBandwidthChanges.put(data.getEndTime(),commBandwidthChanges.get(data.getEndTime()) - data.getComm());
 else     commBandwidthChanges.put(data.getEndTime(),(-1) * data.getComm());
  }
  pixelMillis=(globalEndTime.getTime() - globalStartTime.getTime()) / (xEnd - xStart);
  double currentValue=0;
  TreeMap<Date,Double> dataset=new TreeMap<Date,Double>();
  timeseries.add(dataset);
  for (  Date date : powerChanges.keySet()) {
    currentValue+=powerChanges.get(date);
    dataset.put(date,currentValue);
  }
  dataset=new TreeMap<Date,Double>();
  timeseries.add(dataset);
  for (  Date date : commBandwidthChanges.keySet()) {
    currentValue+=commBandwidthChanges.get(date);
    dataset.put(date,currentValue);
  }
}

Fixed version (ground truth):
private void initActivities(){
  if (activitiesInitialized())   return;
  activities=new ArrayList<ActivityComponent>();
  decisionMap=new ArrayList<DecisionWrapper>();
  activityWidgets=new ArrayList<TimelineView.ActivityWidget>();
  decisionWidgets=new ArrayList<TimelineView.DecisionWidget>();
  addAllActivitiesAndDecisionsRecursively(getManifestedComponent());
  ActivityWrapper root=new ActivityWrapper(null);
  replicateActivityTree(getManifestedComponent(),root);
  assignLevel(root);
  activityMap=new ArrayList<List<ActivityWrapper>>();
  populateActivityMap(root);
  assignLevelsForDecisions();
  TreeMap<Date,Double> powerChanges=new TreeMap<Date,Double>();
  TreeMap<Date,Double> commBandwidthChanges=new TreeMap<Date,Double>();
  for (  ActivityComponent activityComponent : activities) {
    ActivityData data=activityComponent.getModel().getData();
    Date startTime=data.getStartTime();
    Date endTime=data.getEndTime();
    if (globalStartTime == null) {
      globalStartTime=startTime;
      globalEndTime=endTime;
    }
 else {
      if (startTime.before(globalStartTime))       globalStartTime=startTime;
      if (endTime.after(globalEndTime))       globalEndTime=endTime;
    }
    if (data.getStartTime() == null || data.getEndTime() == null)     return;
    if (powerChanges.containsKey(data.getStartTime()))     powerChanges.put(data.getStartTime(),data.getPower() + powerChanges.get(data.getStartTime()));
 else     powerChanges.put(data.getStartTime(),data.getPower());
    if (powerChanges.containsKey(data.getEndTime()))     powerChanges.put(data.getEndTime(),powerChanges.get(data.getEndTime()) - data.getPower());
 else     powerChanges.put(data.getEndTime(),(-1) * data.getPower());
    if (commBandwidthChanges.containsKey(data.getStartTime()))     commBandwidthChanges.put(data.getStartTime(),data.getComm() + commBandwidthChanges.get(data.getStartTime()));
 else     commBandwidthChanges.put(data.getStartTime(),data.getComm());
    if (commBandwidthChanges.containsKey(data.getEndTime()))     commBandwidthChanges.put(data.getEndTime(),commBandwidthChanges.get(data.getEndTime()) - data.getComm());
 else     commBandwidthChanges.put(data.getEndTime(),(-1) * data.getComm());
  }
  if (globalStartTime == null || globalEndTime == null)   return;
  pixelMillis=(globalEndTime.getTime() - globalStartTime.getTime()) / (xEnd - xStart);
  double currentValue=0;
  TreeMap<Date,Double> dataset=new TreeMap<Date,Double>();
  timeseries.add(dataset);
  for (  Date date : powerChanges.keySet()) {
    currentValue+=powerChanges.get(date);
    dataset.put(date,currentValue);
  }
  dataset=new TreeMap<Date,Double>();
  timeseries.add(dataset);
  for (  Date date : commBandwidthChanges.keySet()) {
    currentValue+=commBandwidthChanges.get(date);
    dataset.put(date,currentValue);
  }
}