Program: 92739
Project: 92739
Buggy source:
private void loadLineData(){
  if (fTopLineIndex < 0) {
    if (fLines.size() > 0 && fTrace.getLocationRatio(fLines.get(0).location) > 0) {
      double lastRatio=fTrace.getLocationRatio(fLines.get(fLines.size() - 1).location);
      double firstRatio=fTrace.getLocationRatio(fLines.get(0).location);
      double delta;
      boolean singleEvent=false;
      if (firstRatio != lastRatio) {
        delta=Math.max(20,fNumVisibleLines) * (lastRatio - firstRatio) / (fLines.size() - 1);
      }
 else {
        delta=Math.pow(10,-15);
        singleEvent=true;
      }
      while (fTopLineIndex < 0) {
        ITmfLocation<?> endLocation=fLines.get(0).location;
        firstRatio=Math.max(0,firstRatio - delta);
        TmfContext context=fTrace.seekLocation(firstRatio);
        ITmfLocation<?> location=context.getLocation();
        int index=0;
        long rank=0;
        while (!context.getLocation().equals(endLocation)) {
          location=context.getLocation();
          TmfEvent event=fTrace.getNextEvent(context);
          if (event == null) {
            break;
          }
          String[] lines=event.getRawText().split("String_Node_Str");
          for (int i=0; i < lines.length; i++) {
            String line=lines[i];
            LineData lineData=new LineData(rank,location,line);
            fLines.add(index++,lineData);
            fTopLineIndex++;
            fLastTopLineIndex++;
          }
          rank++;
        }
        long rankOffset=fLines.get(index).rank - rank;
        for (int i=0; i < index; i++) {
          fLines.get(i).rank+=rankOffset;
        }
        if (firstRatio == 0) {
          break;
        }
        if (singleEvent) {
          delta=Math.min(delta * 10,0.1);
        }
      }
    }
    if (fTopLineIndex < 0) {
      fTopLineIndex=0;
    }
  }
  while (fLines.size() - fTopLineIndex < fNumVisibleLines) {
    if (fBottomContext == null) {
      if (fLines.size() == 0) {
        fBottomContext=fTrace.seekEvent(0);
      }
 else {
        fBottomContext=fTrace.seekLocation(fLines.get(fLines.size() - 1).location);
        fTrace.getNextEvent(fBottomContext);
      }
      if (fBottomContext == null) {
        break;
      }
    }
    long rank=fBottomContext.getRank();
    ITmfLocation<?> location=fBottomContext.getLocation();
    TmfEvent event=fTrace.getNextEvent(fBottomContext);
    if (event == null) {
      break;
    }
    for (    String line : event.getRawText().split("String_Node_Str")) {
      int crPos;
      if ((crPos=line.indexOf('\r')) != -1) {
        line=line.substring(0,crPos);
      }
      LineData lineData=new LineData(rank,location,line);
      fLines.add(lineData);
    }
  }
  fTopLineIndex=Math.max(0,Math.min(fTopLineIndex,fLines.size() - 1));
  if (fLines.size() > MAX_LINE_DATA_SIZE) {
    if (fTopLineIndex < MAX_LINE_DATA_SIZE / 2) {
      long rank=fLines.get(MAX_LINE_DATA_SIZE - 1).rank;
      for (int i=MAX_LINE_DATA_SIZE; i < fLines.size(); i++) {
        if (fLines.get(i).rank > rank) {
          fLines.subList(i,fLines.size()).clear();
          fBottomContext=null;
          break;
        }
      }
    }
 else {
      long rank=fLines.get(fLines.size() - MAX_LINE_DATA_SIZE).rank;
      for (int i=fLines.size() - MAX_LINE_DATA_SIZE - 1; i >= 0; i--) {
        if (fLines.get(i).rank < rank) {
          fLines.subList(0,i + 1).clear();
          fTopLineIndex-=(i + 1);
          fLastTopLineIndex-=(i + 1);
          break;
        }
      }
    }
  }
}

Fixed version (ground truth):
private void loadLineData(){
  if (fTopLineIndex < 0) {
    if (fLines.size() > 0 && fTrace.getLocationRatio(fLines.get(0).location) > 0) {
      double lastRatio=fTrace.getLocationRatio(fLines.get(fLines.size() - 1).location);
      double firstRatio=fTrace.getLocationRatio(fLines.get(0).location);
      double delta;
      boolean singleEvent=false;
      if (firstRatio != lastRatio) {
        delta=Math.max(20,fNumVisibleLines) * (lastRatio - firstRatio) / (fLines.size() - 1);
      }
 else {
        delta=Math.pow(10,-15);
        singleEvent=true;
      }
      while (fTopLineIndex < 0) {
        ITmfLocation<?> endLocation=fLines.get(0).location;
        firstRatio=Math.max(0,firstRatio - delta);
        TmfContext context=fTrace.seekLocation(firstRatio);
        ITmfLocation<?> location;
        int index=0;
        long rank=0;
        while (!context.getLocation().equals(endLocation)) {
          location=context.getLocation().clone();
          TmfEvent event=fTrace.getNextEvent(context);
          if (event == null) {
            break;
          }
          String[] lines=event.getRawText().split("String_Node_Str");
          for (int i=0; i < lines.length; i++) {
            String line=lines[i];
            LineData lineData=new LineData(rank,location,line);
            fLines.add(index++,lineData);
            fTopLineIndex++;
            fLastTopLineIndex++;
          }
          rank++;
        }
        long rankOffset=fLines.get(index).rank - rank;
        for (int i=0; i < index; i++) {
          fLines.get(i).rank+=rankOffset;
        }
        if (firstRatio == 0) {
          break;
        }
        if (singleEvent) {
          delta=Math.min(delta * 10,0.1);
        }
      }
    }
    if (fTopLineIndex < 0) {
      fTopLineIndex=0;
    }
  }
  while (fLines.size() - fTopLineIndex < fNumVisibleLines) {
    if (fBottomContext == null) {
      if (fLines.size() == 0) {
        fBottomContext=fTrace.seekEvent(0);
      }
 else {
        fBottomContext=fTrace.seekLocation(fLines.get(fLines.size() - 1).location);
        fTrace.getNextEvent(fBottomContext);
      }
      if (fBottomContext == null) {
        break;
      }
    }
    long rank=fBottomContext.getRank();
    ITmfLocation<?> location=fBottomContext.getLocation() != null ? fBottomContext.getLocation().clone() : null;
    TmfEvent event=fTrace.getNextEvent(fBottomContext);
    if (event == null) {
      break;
    }
    for (    String line : event.getRawText().split("String_Node_Str")) {
      int crPos;
      if ((crPos=line.indexOf('\r')) != -1) {
        line=line.substring(0,crPos);
      }
      LineData lineData=new LineData(rank,location,line);
      fLines.add(lineData);
    }
  }
  fTopLineIndex=Math.max(0,Math.min(fTopLineIndex,fLines.size() - 1));
  if (fLines.size() > MAX_LINE_DATA_SIZE) {
    if (fTopLineIndex < MAX_LINE_DATA_SIZE / 2) {
      long rank=fLines.get(MAX_LINE_DATA_SIZE - 1).rank;
      for (int i=MAX_LINE_DATA_SIZE; i < fLines.size(); i++) {
        if (fLines.get(i).rank > rank) {
          fLines.subList(i,fLines.size()).clear();
          fBottomContext=null;
          break;
        }
      }
    }
 else {
      long rank=fLines.get(fLines.size() - MAX_LINE_DATA_SIZE).rank;
      for (int i=fLines.size() - MAX_LINE_DATA_SIZE - 1; i >= 0; i--) {
        if (fLines.get(i).rank < rank) {
          fLines.subList(0,i + 1).clear();
          fTopLineIndex-=(i + 1);
          fLastTopLineIndex-=(i + 1);
          break;
        }
      }
    }
  }
}