Program: 72688
Project: 72688
Buggy source:
/** 
 * @param g
 * @param rowIndex
 * @param colIndex
 * @param data [style][width][color][rowIndex][colIndex].
 */
private void drawRight(Graphics g,int rowIndex,int colIndex,int x,int y,int w,int h,int[] data){
  if (data[0] == 0 && data[1] == 0) {
    return;
  }
  int nTopWidth=0;
  int nTopStyle=0;
  int nTopX=-1;
  int nTopY=-1;
  if (rowIndex > 0) {
    int[] nTop=borderData[(rowIndex - 1) * (2 * colCount + 1) + colCount + colIndex + 1];
    nTopWidth=nTop[1];
    nTopStyle=nTop[0];
    nTopX=nTop[3];
    nTopY=nTop[4];
  }
  int nBottomWidth=0;
  int nBottomStyle=0;
  int nBottomX=-1;
  int nBottomY=-1;
  if (rowIndex < rowCount - 1) {
    int[] nBottom=borderData[(rowIndex + 1) * (2 * colCount + 1) + colCount + colIndex + 1];
    nBottomWidth=nBottom[1];
    nBottomStyle=nBottom[0];
    nBottomX=nBottom[3];
    nBottomY=nBottom[4];
  }
  int nTopLeftWidth=0;
  int nTopLeftStyle=0;
  int nTopLeftX=-1;
  int nTopLeftY=-1;
  if (colIndex <= colCount - 1 && rowIndex >= 0) {
    int[] nTopLeft=borderData[rowIndex * (2 * colCount + 1) + colIndex];
    nTopLeftWidth=nTopLeft[1];
    nTopLeftStyle=nTopLeft[0];
    nTopLeftX=nTopLeft[3];
    nTopLeftY=nTopLeft[4];
  }
  int nTopRightWidth=0;
  int nTopRightStyle=0;
  int nTopRightX=-1;
  int nTopRightY=-1;
  if (colIndex < colCount - 1 && rowIndex >= 0) {
    int[] nTopRight=borderData[rowIndex * (2 * colCount + 1) + colIndex + 1];
    nTopRightWidth=nTopRight[1];
    nTopRightStyle=nTopRight[0];
    nTopRightX=nTopRight[3];
    nTopRightY=nTopRight[4];
  }
  int nBottomLeftWidth=0;
  int nBottomLeftStyle=0;
  int nBottomLeftX=-1;
  int nBottomLeftY=-1;
  if (colIndex <= colCount - 1 && rowIndex <= rowCount - 1) {
    int[] nBottomLeft=borderData[(rowIndex + 1) * (2 * colCount + 1) + colIndex];
    nBottomLeftWidth=nBottomLeft[1];
    nBottomLeftStyle=nBottomLeft[0];
    nBottomLeftX=nBottomLeft[3];
    nBottomLeftY=nBottomLeft[4];
  }
  int nBottomRightWidth=0;
  int nBottomRightStyle=0;
  int nBottomRightX=-1;
  int nBottomRightY=-1;
  if (colIndex < colCount - 1 && rowIndex <= rowCount - 1) {
    int[] nBottomRight=borderData[(rowIndex + 1) * (2 * colCount + 1) + colIndex + 1];
    nBottomRightWidth=nBottomRight[1];
    nBottomRightStyle=nBottomRight[0];
    nBottomRightX=nBottomRight[3];
    nBottomRightY=nBottomRight[4];
  }
  int ntexWidth=Math.max(nTopLeftWidth,nTopRightWidth);
  boolean exTop=false;
  boolean exBottom=false;
  int ry=(rowIndex == 0) ? (y + ntexWidth) : (y + ntexWidth / 2);
  int rh=(rowIndex == 0) ? (h - ntexWidth) : (h - ntexWidth / 2);
  if (((TableBorderCollisionArbiter.canExtend(data,nTopWidth,nTopStyle,nTopLeftWidth,nTopLeftStyle,nTopLeftX,nTopLeftY,nTopRightWidth,nTopRightStyle,nTopRightX,nTopRightY,true,true) || TableBorderCollisionArbiter.isBrotherWin(data,nTopWidth,nTopStyle,nTopX,nTopY,nTopLeftWidth,nTopLeftStyle,nTopLeftX,nTopLeftY,nTopRightWidth,nTopRightStyle,nTopRightX,nTopRightY,true,true)) && (nTopLeftX != -2 && nTopRightX != -2)) || (data[3] == -2)) {
    ry=(rowIndex == 0) ? (y) : (y - ntexWidth / 2 - ntexWidth % 2);
    rh=(rowIndex == 0) ? (h) : (h + ntexWidth / 2 + ntexWidth % 2);
    exTop=true;
  }
  int nbexWidth=Math.max(nBottomLeftWidth,nBottomRightWidth);
  if (((TableBorderCollisionArbiter.canExtend(data,nBottomWidth,nBottomStyle,nBottomRightWidth,nBottomRightStyle,nBottomRightX,nBottomRightY,nBottomLeftWidth,nBottomLeftStyle,nBottomLeftX,nBottomLeftY,false,true) || TableBorderCollisionArbiter.isBrotherWin(data,nBottomWidth,nBottomStyle,nBottomX,nBottomY,nBottomRightWidth,nBottomRightStyle,nBottomRightX,nBottomRightY,nBottomLeftWidth,nBottomLeftStyle,nBottomLeftX,nBottomLeftY,false,true)) && (nBottomLeftX != -2 && nBottomRightX != -2)) || (data[3] == -2)) {
    rh+=((rowIndex == rowCount - 1) ? (0) : (nbexWidth / 2));
    exBottom=true;
  }
 else {
    rh-=((rowIndex == rowCount - 1) ? (nbexWidth) : (nbexWidth / 2 + nbexWidth % 2));
  }
  int direction=BorderUtil.RIGHT;
  int[] widths=new int[]{0,0,0,data[1]};
  if (data[3] == nTopLeftX && data[4] == nTopLeftY && data[3] == nBottomLeftX && data[4] == nBottomLeftY) {
    widths[0]=exTop ? nTopLeftWidth : 0;
    widths[1]=exBottom ? nBottomLeftWidth : 0;
    widths[2]=0;
    widths[3]=data[1];
  }
 else   if (data[3] == nTopLeftX && data[4] == nTopLeftY) {
    widths[0]=exTop ? nTopLeftWidth : 0;
    widths[1]=0;
    widths[2]=0;
    widths[3]=data[1];
  }
 else   if (data[3] == nBottomLeftX && data[4] == nBottomLeftY) {
    widths[0]=0;
    widths[1]=exBottom ? nBottomLeftWidth : 0;
    widths[2]=0;
    widths[3]=data[1];
  }
 else   if (data[3] == nTopRightX && data[4] == nTopRightY && data[3] == nBottomRightX && data[4] == nBottomRightY) {
    direction=BorderUtil.LEFT;
    widths[0]=exTop ? nTopRightWidth : 0;
    widths[1]=exBottom ? nBottomRightWidth : 0;
    widths[2]=data[1];
    widths[3]=0;
  }
 else   if (data[3] == nTopRightX && data[4] == nTopRightY) {
    direction=BorderUtil.LEFT;
    widths[0]=exTop ? nTopRightWidth : 0;
    widths[1]=0;
    widths[2]=data[1];
    widths[3]=0;
  }
 else   if (data[3] == nBottomRightX && data[4] == nBottomRightY) {
    direction=BorderUtil.LEFT;
    widths[0]=0;
    widths[1]=exBottom ? nBottomRightWidth : 0;
    widths[2]=data[1];
    widths[3]=0;
  }
 else   if (data[3] != rowIndex || data[4] != colIndex) {
    direction=BorderUtil.LEFT;
    widths[0]=0;
    widths[1]=0;
    widths[2]=data[1];
    widths[3]=0;
  }
  Rectangle r=new Rectangle(x + w - data[1] / 2 - data[1] % 2,ry,data[1],rh);
  if (colIndex == colCount - 1) {
    r.x=x + w - data[1];
  }
  if (data[0] != 0) {
    g.setForegroundColor(ColorManager.getColor(data[2]));
    if (data[0] == -2) {
      BorderUtil.drawDoubleLine(g,direction,widths,r);
    }
 else {
      BorderUtil.drawSingleLine(g,direction,data[0],widths,r);
    }
  }
 else   if (data[1] > 0) {
    g.setForegroundColor(ReportColorConstants.ShadowLineColor);
    BorderUtil.drawDefaultLine(g,direction,r);
  }
}

Fixed version (ground truth):
/** 
 * @param g
 * @param rowIndex
 * @param colIndex
 * @param data [style][width][color][rowIndex][colIndex].
 */
private void drawRight(Graphics g,int rowIndex,int colIndex,int x,int y,int w,int h,int[] data){
  if (data[0] == 0 && data[1] == 0) {
    return;
  }
  int nTopWidth=0;
  int nTopStyle=0;
  int nTopX=-1;
  int nTopY=-1;
  if (rowIndex > 0) {
    int[] nTop=borderData[(rowIndex - 1) * (2 * colCount + 1) + colCount + colIndex + 1];
    nTopWidth=nTop[1];
    nTopStyle=nTop[0];
    nTopX=nTop[3];
    nTopY=nTop[4];
  }
  int nBottomWidth=0;
  int nBottomStyle=0;
  int nBottomX=-1;
  int nBottomY=-1;
  if (rowIndex < rowCount - 1) {
    int[] nBottom=borderData[(rowIndex + 1) * (2 * colCount + 1) + colCount + colIndex + 1];
    nBottomWidth=nBottom[1];
    nBottomStyle=nBottom[0];
    nBottomX=nBottom[3];
    nBottomY=nBottom[4];
  }
  int nTopLeftWidth=0;
  int nTopLeftStyle=0;
  int nTopLeftX=-1;
  int nTopLeftY=-1;
  if (colIndex <= colCount - 1 && rowIndex >= 0) {
    int[] nTopLeft=borderData[rowIndex * (2 * colCount + 1) + colIndex];
    nTopLeftWidth=nTopLeft[1];
    nTopLeftStyle=nTopLeft[0];
    nTopLeftX=nTopLeft[3];
    nTopLeftY=nTopLeft[4];
  }
  int nTopRightWidth=0;
  int nTopRightStyle=0;
  int nTopRightX=-1;
  int nTopRightY=-1;
  if (colIndex < colCount - 1 && rowIndex >= 0) {
    int[] nTopRight=borderData[rowIndex * (2 * colCount + 1) + colIndex + 1];
    nTopRightWidth=nTopRight[1];
    nTopRightStyle=nTopRight[0];
    nTopRightX=nTopRight[3];
    nTopRightY=nTopRight[4];
  }
  int nBottomLeftWidth=0;
  int nBottomLeftStyle=0;
  int nBottomLeftX=-1;
  int nBottomLeftY=-1;
  if (colIndex <= colCount - 1 && rowIndex <= rowCount - 1) {
    int[] nBottomLeft=borderData[(rowIndex + 1) * (2 * colCount + 1) + colIndex];
    nBottomLeftWidth=nBottomLeft[1];
    nBottomLeftStyle=nBottomLeft[0];
    nBottomLeftX=nBottomLeft[3];
    nBottomLeftY=nBottomLeft[4];
  }
  int nBottomRightWidth=0;
  int nBottomRightStyle=0;
  int nBottomRightX=-1;
  int nBottomRightY=-1;
  if (colIndex < colCount - 1 && rowIndex <= rowCount - 1) {
    int[] nBottomRight=borderData[(rowIndex + 1) * (2 * colCount + 1) + colIndex + 1];
    nBottomRightWidth=nBottomRight[1];
    nBottomRightStyle=nBottomRight[0];
    nBottomRightX=nBottomRight[3];
    nBottomRightY=nBottomRight[4];
  }
  int ntexWidth=Math.max(nTopLeftWidth,nTopRightWidth);
  boolean exTop=false;
  boolean exBottom=false;
  int ry=(rowIndex == 0) ? (y + ntexWidth) : (y + ntexWidth / 2);
  int rh=(rowIndex == 0) ? (h - ntexWidth) : (h - ntexWidth / 2);
  if (((TableBorderCollisionArbiter.canExtend(data,nTopWidth,nTopStyle,nTopLeftWidth,nTopLeftStyle,nTopLeftX,nTopLeftY,nTopRightWidth,nTopRightStyle,nTopRightX,nTopRightY,true,true) || TableBorderCollisionArbiter.isBrotherWin(data,nTopWidth,nTopStyle,nTopX,nTopY,nTopLeftWidth,nTopLeftStyle,nTopLeftX,nTopLeftY,nTopRightWidth,nTopRightStyle,nTopRightX,nTopRightY,true,true)) && (nTopLeftX != -2 && nTopRightX != -2)) || (data[3] == -2)) {
    ry=(rowIndex == 0) ? (y) : (y - ntexWidth / 2 - ntexWidth % 2);
    rh=(rowIndex == 0) ? (h) : (h + ntexWidth / 2 + ntexWidth % 2);
    exTop=true;
  }
  int nbexWidth=Math.max(nBottomLeftWidth,nBottomRightWidth);
  if (((TableBorderCollisionArbiter.canExtend(data,nBottomWidth,nBottomStyle,nBottomRightWidth,nBottomRightStyle,nBottomRightX,nBottomRightY,nBottomLeftWidth,nBottomLeftStyle,nBottomLeftX,nBottomLeftY,false,true) || TableBorderCollisionArbiter.isBrotherWin(data,nBottomWidth,nBottomStyle,nBottomX,nBottomY,nBottomRightWidth,nBottomRightStyle,nBottomRightX,nBottomRightY,nBottomLeftWidth,nBottomLeftStyle,nBottomLeftX,nBottomLeftY,false,true)) && (nBottomLeftX != -2 && nBottomRightX != -2)) || (data[3] == -2)) {
    rh+=((rowIndex == rowCount - 1) ? (0) : (nbexWidth / 2));
    exBottom=true;
  }
 else {
    rh-=((rowIndex == rowCount - 1) ? (nbexWidth) : (nbexWidth / 2 + nbexWidth % 2));
  }
  int direction=BorderUtil.RIGHT;
  int[] widths=new int[]{0,0,0,data[1]};
  if (data[3] == nTopLeftX && data[4] == nTopLeftY && data[3] == nBottomLeftX && data[4] == nBottomLeftY) {
    widths[0]=exTop ? nTopLeftWidth : 0;
    widths[1]=exBottom ? nBottomLeftWidth : 0;
    widths[2]=0;
    widths[3]=data[1];
  }
 else   if (data[3] == nTopLeftX && data[4] == nTopLeftY) {
    widths[0]=exTop ? nTopLeftWidth : 0;
    widths[1]=0;
    widths[2]=0;
    widths[3]=data[1];
  }
 else   if (data[3] == nBottomLeftX && data[4] == nBottomLeftY) {
    widths[0]=0;
    widths[1]=exBottom ? nBottomLeftWidth : 0;
    widths[2]=0;
    widths[3]=data[1];
  }
 else   if (data[3] == nTopRightX && data[4] == nTopRightY && data[3] == nBottomRightX && data[4] == nBottomRightY) {
    direction=BorderUtil.LEFT;
    widths[0]=exTop ? nTopRightWidth : 0;
    widths[1]=exBottom ? nBottomRightWidth : 0;
    widths[2]=data[1];
    widths[3]=0;
  }
 else   if (data[3] == nTopRightX && data[4] == nTopRightY) {
    direction=BorderUtil.LEFT;
    widths[0]=exTop ? nTopRightWidth : 0;
    widths[1]=0;
    widths[2]=data[1];
    widths[3]=0;
  }
 else   if (data[3] == nBottomRightX && data[4] == nBottomRightY) {
    direction=BorderUtil.LEFT;
    widths[0]=0;
    widths[1]=exBottom ? nBottomRightWidth : 0;
    widths[2]=data[1];
    widths[3]=0;
  }
 else   if (data[3] != rowIndex || data[4] != colIndex) {
    direction=BorderUtil.LEFT;
    widths[0]=0;
    widths[1]=0;
    widths[2]=data[1];
    widths[3]=0;
  }
  Rectangle r=new Rectangle(x + w - data[1] / 2 - data[1] % 2,ry,data[1],rh);
  if (colIndex == colCount - 1) {
    r.x=x + w - data[1];
  }
  if (data[0] != 0) {
    g.setForegroundColor(ColorManager.getColor(data[2]));
    BorderUtil.drawBorderLine(g,direction,data[0],widths,r);
  }
 else   if (data[1] > 0) {
    g.setForegroundColor(ReportColorConstants.ShadowLineColor);
    BorderUtil.drawDefaultLine(g,direction,r);
  }
}