Program: 69344
Project: 69344
Buggy source:
protected void paintFigure(Graphics graphics){
  setIntervalForPaint();
  double dotsPerUnit=getDPU();
  Rectangle clip=transposer.t(graphics.getClip(Rectangle.SINGLETON));
  Rectangle figClientArea=transposer.t(getClientArea());
  Rectangle clippedBounds=clip;
  clippedBounds.x=figClientArea.x;
  clippedBounds.width=figClientArea.width - BORDER_WIDTH;
  if (isOpaque()) {
    graphics.fillRectangle(transposer.t(clippedBounds));
  }
  int unitsPerMajorMark=(int)(minPixelsBetweenMajorMarks / dotsPerUnit);
  if (minPixelsBetweenMajorMarks % dotsPerUnit != 0.0) {
    unitsPerMajorMark++;
  }
  if (interval > 0) {
    int intervalMultiple=interval;
    while (intervalMultiple < unitsPerMajorMark) {
      intervalMultiple+=interval;
    }
    unitsPerMajorMark=intervalMultiple;
  }
 else   if (unitsPerMajorMark != 1 && unitsPerMajorMark % 2 != 0) {
    unitsPerMajorMark++;
  }
  int divsPerMajorMark;
  if (divisions > 0 && dotsPerUnit * unitsPerMajorMark / divisions >= minPixelsBetweenMarks) {
    divsPerMajorMark=divisions;
  }
 else {
    divsPerMajorMark=2;
    if (getUnit() == RulerProvider.UNIT_CENTIMETERS) {
      divsPerMajorMark=10;
    }
 else     if (getUnit() == RulerProvider.UNIT_INCHES) {
      divsPerMajorMark=8;
    }
    while (dotsPerUnit * unitsPerMajorMark / divsPerMajorMark < minPixelsBetweenMarks) {
      divsPerMajorMark/=2;
      if (divsPerMajorMark == 0) {
        break;
      }
    }
    if (divsPerMajorMark == 0) {
      divsPerMajorMark=1;
    }
  }
  int mediumMarkerDivNum=1;
switch (divsPerMajorMark) {
case 20:
case 10:
case 5:
    mediumMarkerDivNum=5;
  break;
case 16:
case 8:
mediumMarkerDivNum=4;
break;
case 4:
mediumMarkerDivNum=2;
break;
case 2:
mediumMarkerDivNum=1;
}
Rectangle leftRect=transposer.t(getScaleLeftSpace());
int leftMargin=leftRect.y;
double dotsPerDivision=dotsPerUnit * unitsPerMajorMark / divsPerMajorMark;
int startMark=(int)((clippedBounds.y - leftMargin) / (dotsPerUnit * unitsPerMajorMark)) * divsPerMajorMark;
if (clippedBounds.y < 0) {
startMark-=divsPerMajorMark;
}
int endMark=(int)(((clippedBounds.y + clippedBounds.height - leftMargin) / dotsPerDivision)) + 1;
int leading=FigureUtilities.getFontMetrics(getFont()).getLeading();
Rectangle forbiddenZone=new Rectangle();
for (int div=startMark; div <= endMark; div++) {
if (leftRect.bottom() <= clippedBounds.bottom()) {
}
int y=(int)(div * dotsPerDivision);
if (div % divsPerMajorMark == 0) {
String num="String_Node_Str" + (div / divsPerMajorMark) * unitsPerMajorMark;
if (isHorizontal()) {
Dimension numSize=FigureUtilities.getStringExtents(num,getFont());
if (numSize.width % 2 == 0) {
numSize.width--;
}
Point textLocation=new Point(y - (numSize.width / 2) + leftMargin,clippedBounds.x + textMargin - leading);
forbiddenZone.setLocation(textLocation);
forbiddenZone.setSize(numSize);
forbiddenZone.expand(1,1);
graphics.fillRectangle(forbiddenZone);
if (canDrawNumber(num,textLocation,graphics)) {
graphics.drawText(num,textLocation);
}
}
 else {
Image numImage=ImageUtilities.createRotatedImageOfString(num,getFont(),getForegroundColor(),getBackgroundColor());
Point textLocation=new Point(clippedBounds.x + textMargin,y - (numImage.getBounds().height / 2) + leftMargin);
forbiddenZone.setLocation(textLocation);
forbiddenZone.setSize(numImage.getBounds().width,numImage.getBounds().height);
forbiddenZone.expand(1,1 + (numImage.getBounds().height % 2 == 0 ? 1 : 0));
graphics.fillRectangle(forbiddenZone);
if (canDrawNumber(num,new Point(textLocation.x,textLocation.y + getScaleLeftSpace().y - numImage.getBounds().height),graphics)) {
graphics.drawImage(numImage,textLocation);
}
numImage.dispose();
}
}
 else if ((div % divsPerMajorMark) % mediumMarkerDivNum == 0) {
Point start=transposer.t(new Point((clippedBounds.getRight().x - mediumMarkWidth) / 2,y + leftMargin));
Point end=transposer.t(new Point(((clippedBounds.getRight().x - mediumMarkWidth) / 2) + mediumMarkWidth,y + leftMargin));
if (!forbiddenZone.contains(start)) {
graphics.drawLine(start,end);
}
}
 else {
Point start=transposer.t(new Point((clippedBounds.getRight().x - smallMarkWidth) / 2,y + leftMargin));
Point end=transposer.t(new Point(((clippedBounds.getRight().x - smallMarkWidth) / 2) + smallMarkWidth,y + leftMargin));
if (!forbiddenZone.contains(start)) {
graphics.drawLine(start,end);
}
}
}
clippedBounds.expand(BORDER_WIDTH,0);
graphics.setForegroundColor(ColorConstants.buttonDarker);
graphics.drawLine(transposer.t(clippedBounds.getTopRight().translate(-1,-1)),transposer.t(clippedBounds.getBottomRight().translate(-1,-1)));
Color c=Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
graphics.setBackgroundColor(c);
Rectangle rect=new Rectangle(0,0,clippedBounds.height,leftMargin - 2);
rect=transposer.t(rect);
graphics.fillRectangle(rect);
graphics.fillRectangle(getEndRect(graphics.getClip(Rectangle.SINGLETON)));
}

Fixed version (ground truth):
protected void paintFigure(Graphics graphics){
  setIntervalForPaint();
  double dotsPerUnit=getDPU();
  Rectangle clip=transposer.t(graphics.getClip(Rectangle.SINGLETON));
  Rectangle figClientArea=transposer.t(getClientArea());
  Rectangle clippedBounds=clip;
  clippedBounds.x=figClientArea.x;
  clippedBounds.width=figClientArea.width - BORDER_WIDTH;
  if (isOpaque()) {
    graphics.fillRectangle(transposer.t(clippedBounds));
  }
  int unitsPerMajorMark=(int)(minPixelsBetweenMajorMarks / dotsPerUnit);
  if (minPixelsBetweenMajorMarks % dotsPerUnit != 0.0) {
    unitsPerMajorMark++;
  }
  if (interval > 0) {
    int intervalMultiple=interval;
    while (intervalMultiple < unitsPerMajorMark) {
      intervalMultiple+=interval;
    }
    unitsPerMajorMark=intervalMultiple;
  }
 else   if (unitsPerMajorMark != 1 && unitsPerMajorMark % 2 != 0) {
    unitsPerMajorMark++;
  }
  int divsPerMajorMark;
  if (divisions > 0 && dotsPerUnit * unitsPerMajorMark / divisions >= minPixelsBetweenMarks) {
    divsPerMajorMark=divisions;
  }
 else {
    divsPerMajorMark=2;
    if (getUnit() == RulerProvider.UNIT_CENTIMETERS) {
      divsPerMajorMark=10;
    }
 else     if (getUnit() == RulerProvider.UNIT_INCHES) {
      divsPerMajorMark=8;
    }
    while (dotsPerUnit * unitsPerMajorMark / divsPerMajorMark < minPixelsBetweenMarks) {
      divsPerMajorMark/=2;
      if (divsPerMajorMark == 0) {
        break;
      }
    }
    if (divsPerMajorMark == 0) {
      divsPerMajorMark=1;
    }
  }
  int mediumMarkerDivNum=1;
switch (divsPerMajorMark) {
case 20:
case 10:
case 5:
    mediumMarkerDivNum=5;
  break;
case 16:
case 8:
mediumMarkerDivNum=4;
break;
case 4:
mediumMarkerDivNum=2;
break;
case 2:
mediumMarkerDivNum=1;
}
Rectangle leftRect=transposer.t(getScaleLeftSpace());
int leftMargin=leftRect.y;
double dotsPerDivision=dotsPerUnit * unitsPerMajorMark / divsPerMajorMark;
int startMark=(int)((clippedBounds.y - leftMargin) / (dotsPerUnit * unitsPerMajorMark)) * divsPerMajorMark;
if (clippedBounds.y < 0) {
startMark-=divsPerMajorMark;
}
int endMark=(int)(((clippedBounds.y + clippedBounds.height - leftMargin) / dotsPerDivision)) + 1;
int leading=FigureUtilities.getFontMetrics(getFont()).getLeading();
Rectangle forbiddenZone=new Rectangle();
for (int div=startMark; div <= endMark; div++) {
if (leftRect.bottom() <= clippedBounds.bottom()) {
}
int y=(int)(div * dotsPerDivision);
if (div % divsPerMajorMark == 0) {
String num="String_Node_Str" + (div / divsPerMajorMark) * unitsPerMajorMark;
if (isHorizontal()) {
Dimension numSize=FigureUtilities.getStringExtents(num,getFont());
if (numSize.width % 2 == 0) {
numSize.width--;
}
Point textLocation=new Point(y - (numSize.width / 2) + leftMargin,clippedBounds.x + textMargin - leading);
forbiddenZone.setLocation(textLocation);
forbiddenZone.setSize(numSize);
forbiddenZone.expand(1,1);
graphics.fillRectangle(forbiddenZone);
{
graphics.drawText(num,textLocation);
}
}
 else {
Image numImage=ImageUtilities.createRotatedImageOfString(num,getFont(),getForegroundColor(),getBackgroundColor());
Point textLocation=new Point(clippedBounds.x + textMargin,y - (numImage.getBounds().height / 2) + leftMargin);
forbiddenZone.setLocation(textLocation);
forbiddenZone.setSize(numImage.getBounds().width,numImage.getBounds().height);
forbiddenZone.expand(1,1 + (numImage.getBounds().height % 2 == 0 ? 1 : 0));
graphics.fillRectangle(forbiddenZone);
{
graphics.drawImage(numImage,textLocation);
}
numImage.dispose();
}
}
 else if ((div % divsPerMajorMark) % mediumMarkerDivNum == 0) {
Point start=transposer.t(new Point((clippedBounds.getRight().x - mediumMarkWidth) / 2,y + leftMargin));
Point end=transposer.t(new Point(((clippedBounds.getRight().x - mediumMarkWidth) / 2) + mediumMarkWidth,y + leftMargin));
if (!forbiddenZone.contains(start)) {
graphics.drawLine(start,end);
}
}
 else {
Point start=transposer.t(new Point((clippedBounds.getRight().x - smallMarkWidth) / 2,y + leftMargin));
Point end=transposer.t(new Point(((clippedBounds.getRight().x - smallMarkWidth) / 2) + smallMarkWidth,y + leftMargin));
if (!forbiddenZone.contains(start)) {
graphics.drawLine(start,end);
}
}
}
clippedBounds.expand(BORDER_WIDTH,0);
graphics.setForegroundColor(ColorConstants.buttonDarker);
graphics.drawLine(transposer.t(clippedBounds.getTopRight().translate(-1,-1)),transposer.t(clippedBounds.getBottomRight().translate(-1,-1)));
Color c=Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
graphics.setBackgroundColor(c);
Rectangle rect=new Rectangle(0,0,transposer.t(getBounds()).width,leftMargin);
rect=transposer.t(rect);
graphics.fillRectangle(rect);
graphics.fillRectangle(getEndRect(graphics.getClip(Rectangle.SINGLETON)));
}