Program: 31194
Project: 31194
Buggy source:
public void DrawSparkline(int x,int y,ITrace2D trace,boolean isHovering){
  if (trace.getSize() < 2) {
    return;
  }
  Graphics2D g2=(Graphics2D)g;
  Iterator<ITracePoint2D> iter=trace.iterator();
  final int circleSize=3;
  final int height=textheight;
  double numSecondsDisplayed=5.0;
  final double width=sparklineWidth;
  if (trace.getMaxX() == trace.getMinX()) {
    return;
  }
  Color pointColor=Color.RED;
  Color lineColor=Color.BLACK;
  if (isHovering) {
    Color temp=pointColor;
    pointColor=lineColor;
    lineColor=temp;
  }
  if (trace.getMaxY() == trace.getMinY()) {
    g2.setColor(lineColor);
    g2.drawLine(x,y - (int)((double)height / (double)2),x + (int)width,y - (int)((double)height / (double)2));
    g2.setColor(pointColor);
    g2.fillOval(x + (int)width - 1,y - (int)((double)height / (double)2) - 1,circleSize,circleSize);
    return;
  }
  double xscale=(double)width / (double)(numSecondsDisplayed);
  double yscale=height / (trace.getMaxY() - trace.getMinY());
  double earliestTimeDisplayed=((double)utime / (double)1000000.0 - numSecondsDisplayed);
  g2.setColor(lineColor);
  boolean first=true;
  double lastX=0, lastY=0, thisX, thisY;
  while (iter.hasNext()) {
    ITracePoint2D point=iter.next();
    if (first) {
      first=false;
      lastX=(point.getX() - earliestTimeDisplayed) * xscale + x;
      lastY=y - (point.getY() - trace.getMinY()) * yscale;
    }
 else {
      thisX=(point.getX() - earliestTimeDisplayed) * xscale + x;
      thisY=y - (point.getY() - trace.getMinY()) * yscale;
      if (thisX >= x && lastX >= x) {
        g2.drawLine((int)lastX,(int)lastY,(int)thisX,(int)thisY);
      }
      lastX=thisX;
      lastY=thisY;
    }
    if (!iter.hasNext()) {
      g2.setColor(pointColor);
      g2.fillOval((int)lastX - 1,(int)lastY - 1,3,3);
      g2.setColor(lineColor);
    }
  }
}

Fixed version (ground truth):
public void DrawSparkline(int x,int y,ITrace2D trace,boolean isHovering){
  if (trace.getSize() < 2) {
    return;
  }
  Graphics2D g2=(Graphics2D)g;
  Iterator<ITracePoint2D> iter=trace.iterator();
  final int circleSize=3;
  final int height=textheight;
  double numSecondsDisplayed=5.0;
  final double width=sparklineWidth;
  if (trace.getMaxX() == trace.getMinX()) {
    return;
  }
  Color pointColor=Color.RED;
  Color lineColor=Color.BLACK;
  if (isHovering) {
    Color temp=pointColor;
    pointColor=lineColor;
    lineColor=temp;
  }
  double earliestTimeDisplayed=((double)utime / (double)1000000.0 - numSecondsDisplayed);
  double xscale=(double)width / (double)(numSecondsDisplayed);
  if (trace.getMaxY() == trace.getMinY()) {
    g2.setColor(lineColor);
    ITracePoint2D firstPoint=iter.next();
    int leftLineX=(int)((firstPoint.getX() - earliestTimeDisplayed) * xscale) + x;
    if (leftLineX < x) {
      leftLineX=x;
    }
    g2.drawLine(leftLineX,y - (int)((double)height / (double)2),x + (int)width,y - (int)((double)height / (double)2));
    g2.setColor(pointColor);
    g2.fillOval(x + (int)width - 1,y - (int)((double)height / (double)2) - 1,circleSize,circleSize);
    return;
  }
  double yscale=height / (trace.getMaxY() - trace.getMinY());
  g2.setColor(lineColor);
  boolean first=true;
  double lastX=0, lastY=0, thisX, thisY;
  while (iter.hasNext()) {
    ITracePoint2D point=iter.next();
    if (first) {
      first=false;
      lastX=(point.getX() - earliestTimeDisplayed) * xscale + x;
      lastY=y - (point.getY() - trace.getMinY()) * yscale;
    }
 else {
      thisX=(point.getX() - earliestTimeDisplayed) * xscale + x;
      thisY=y - (point.getY() - trace.getMinY()) * yscale;
      if (thisX >= x && lastX >= x) {
        g2.drawLine((int)lastX,(int)lastY,(int)thisX,(int)thisY);
      }
      lastX=thisX;
      lastY=thisY;
    }
    if (!iter.hasNext()) {
      g2.setColor(pointColor);
      g2.fillOval((int)lastX - 1,(int)lastY - 1,3,3);
      g2.setColor(lineColor);
    }
  }
}