Program: 143054
Project: 143054
Buggy source:
@Override public void paintComponent(Graphics g){
  super.paintComponent(g);
  int tmMarginTop=2;
  int tmMarginBottom=4;
  int width=getWidth();
  int height=getHeight();
  settings.update(width,height);
  Graphics2D g2d=(Graphics2D)g;
  g2d.setBackground(settings.background.top);
  g2d.setPaint(settings.background.paint);
  g2d.fillRect(0,tmMarginTop + 1,width,height - tmMarginBottom - 2);
  if (!this.isEnabled()) {
    return;
  }
  if (model == null) {
    return;
  }
  long min=(long)model.getMinValue();
  long max=(long)model.getMaxValue();
  if (max <= min && min < 0 && max <= 0) {
    return;
  }
  g2d.setRenderingHints(settings.renderingHints);
  int sf=(int)(model.getFromFloat() * (double)width);
  int st=(int)(model.getToFloat() * (double)width);
  int vhw=settings.selection.visibleHookWidth;
  int sw=st - sf;
  if (highlightedComponent != HighlightedComponent.NONE) {
    g2d.setPaint(settings.selection.mouseOverPaint);
switch (highlightedComponent) {
case LEFT_HOOK:
      g2d.fillRect(sf,tmMarginTop,vhw,height - tmMarginBottom - 1);
    g2d.setPaint(settings.selection.paint);
  g2d.fillRect(sf + vhw,tmMarginTop,sw - vhw,height - tmMarginBottom - 1);
break;
case CENTER_HOOK:
g2d.setPaint(settings.selection.paint);
g2d.fillRect(sf,tmMarginTop,vhw,height - tmMarginBottom - 1);
g2d.setPaint(settings.selection.mouseOverPaint);
g2d.fillRect(sf + vhw,tmMarginTop,sw - vhw * 2,height - tmMarginBottom - 1);
g2d.setPaint(settings.selection.paint);
g2d.fillRect(st - vhw,tmMarginTop,vhw,height - tmMarginBottom - 1);
break;
case RIGHT_HOOK:
g2d.setPaint(settings.selection.paint);
g2d.fillRect(sf,tmMarginTop,sw - vhw,height - tmMarginBottom - 1);
g2d.setPaint(settings.selection.mouseOverPaint);
g2d.fillRect(st - vhw,tmMarginTop,vhw,height - tmMarginBottom - 1);
break;
}
}
 else {
g2d.setPaint(settings.selection.paint);
g2d.fillRect(sf,tmMarginTop,sw,height - tmMarginBottom - 1);
}
paintUpperRulerForInterval(g2d,new DateTime(new Date(min)),new DateTime(new Date(max)));
g2d.setColor(settings.defaultStrokeColor);
g2d.drawRect(sf,tmMarginTop,sw,height - tmMarginBottom - 1);
double v=model.getValueFromFloat(currentMousePositionX * (1.0 / width));
if (v != Double.NEGATIVE_INFINITY && v != Double.POSITIVE_INFINITY) {
DateTime d=new DateTime(new Date((long)v));
if (d != null) {
DateTimeFormatter fmt=DateTimeFormat.forPattern("String_Node_Str");
String str=fmt.withLocale(LOCALE).print(d);
int strw=(int)(settings.tip.fontMetrics.getStringBounds(str,null)).getWidth() + 4;
int px=currentMousePositionX;
if (px + strw >= width) {
px=width - strw;
}
g2d.setPaint(settings.tip.backgroundColor);
g2d.fillRect(px,1,strw,18);
g2d.setPaint(settings.tip.fontColor);
g2d.drawRect(px,1,strw,18);
g2d.setColor(settings.tip.fontColor);
g2d.drawString(str,px + 2,16);
}
}
}

Fixed version (ground truth):
@Override public void paintComponent(Graphics g){
  super.paintComponent(g);
  int tmMarginTop=2;
  int tmMarginBottom=4;
  int width=getWidth();
  int height=getHeight();
  settings.update(width,height);
  Graphics2D g2d=(Graphics2D)g;
  g2d.setBackground(settings.background.top);
  g2d.setPaint(settings.background.paint);
  g2d.fillRect(0,tmMarginTop + 1,width,height - tmMarginBottom - 2);
  if (!this.isEnabled()) {
    return;
  }
  if (model == null) {
    return;
  }
  long min=(long)model.getMinValue();
  long max=(long)model.getMaxValue();
  if (max <= min && min < 0 && max <= 0) {
    return;
  }
  g2d.setRenderingHints(settings.renderingHints);
  int sf=(int)(model.getFromFloat() * (double)width);
  int st=(int)(model.getToFloat() * (double)width);
  int vhw=settings.selection.visibleHookWidth;
  int sw=st - sf;
  if (highlightedComponent != HighlightedComponent.NONE) {
    g2d.setPaint(settings.selection.mouseOverPaint);
switch (highlightedComponent) {
case LEFT_HOOK:
      g2d.fillRect(sf,tmMarginTop,vhw,height - tmMarginBottom - 1);
    g2d.setPaint(settings.selection.paint);
  g2d.fillRect(sf + vhw,tmMarginTop,sw - vhw,height - tmMarginBottom - 1);
break;
case CENTER_HOOK:
g2d.setPaint(settings.selection.paint);
g2d.fillRect(sf,tmMarginTop,vhw,height - tmMarginBottom - 1);
g2d.setPaint(settings.selection.mouseOverPaint);
g2d.fillRect(sf + vhw,tmMarginTop,sw - vhw * 2,height - tmMarginBottom - 1);
g2d.setPaint(settings.selection.paint);
g2d.fillRect(st - vhw,tmMarginTop,vhw,height - tmMarginBottom - 1);
break;
case RIGHT_HOOK:
g2d.setPaint(settings.selection.paint);
g2d.fillRect(sf,tmMarginTop,sw - vhw,height - tmMarginBottom - 1);
g2d.setPaint(settings.selection.mouseOverPaint);
g2d.fillRect(st - vhw,tmMarginTop,vhw,height - tmMarginBottom - 1);
break;
}
}
 else {
g2d.setPaint(settings.selection.paint);
g2d.fillRect(sf,tmMarginTop,sw,height - tmMarginBottom - 1);
}
paintUpperRulerForInterval(g2d,new DateTime(new Date(min)),new DateTime(new Date(max)));
g2d.setColor(settings.defaultStrokeColor);
g2d.drawRect(sf,tmMarginTop,sw,height - tmMarginBottom - 1);
double v=model.getValueFromFloat(currentMousePositionX * (1.0 / width));
v+=model.getMinValue();
if (v != Double.NEGATIVE_INFINITY && v != Double.POSITIVE_INFINITY) {
DateTime d=new DateTime(new Date((long)v));
if (d != null) {
DateTimeFormatter fmt=DateTimeFormat.forPattern("String_Node_Str");
String str=fmt.withLocale(LOCALE).print(d);
int strw=(int)(settings.tip.fontMetrics.getStringBounds(str,null)).getWidth() + 4;
int px=currentMousePositionX;
if (px + strw >= width) {
px=width - strw;
}
g2d.setPaint(settings.tip.backgroundColor);
g2d.fillRect(px,1,strw,18);
g2d.setPaint(settings.tip.fontColor);
g2d.drawRect(px,1,strw,18);
g2d.setColor(settings.tip.fontColor);
g2d.drawString(str,px + 2,16);
}
}
}