Program: 11653
Project: 11653
Buggy source:
protected void paintToVertical(GL gl,int width,int height,Rectangle2D textBounds){
  int xText=padding;
  int yText=padding;
  double textWidth=textBounds.getWidth();
  double textHeight=textBounds.getHeight();
  double halfTextWidth=textWidth / 2d;
  double halfTextHeight=textHeight / 2d;
switch (hPos) {
case Left:
    xText=(int)(padding - halfTextWidth + halfTextHeight);
  break;
case Center:
xText=(int)(width / 2d - halfTextWidth);
break;
case Right:
xText=(int)(width - halfTextWidth - halfTextHeight- padding);
break;
}
switch (vPos) {
case Bottom:
yText=(int)(padding - halfTextHeight + halfTextWidth);
break;
case Center:
yText=(int)(height / 2d - halfTextHeight);
break;
case Top:
yText=(int)(height - halfTextHeight - halfTextWidth- padding);
break;
}
if (this.paintBackground) {
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(0,width,0,height,-1,1);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glEnable(GL.GL_BLEND);
int buffer=2;
int xTextMin=(int)(xText + halfTextWidth - halfTextHeight - buffer);
int yTextMin=(int)(yText + halfTextWidth + halfTextHeight+ buffer);
int xTextMax=(int)(xText + halfTextWidth + halfTextHeight+ buffer+ 3);
int yTextMax=(int)(yText - halfTextWidth + halfTextHeight - buffer);
gl.glColor4fv(backgroundColor,0);
gl.glBegin(GL.GL_QUADS);
try {
gl.glVertex2f(xTextMin,yTextMin);
gl.glVertex2f(xTextMax,yTextMin);
gl.glVertex2f(xTextMax,yTextMax);
gl.glVertex2f(xTextMin,yTextMax);
}
  finally {
gl.glEnd();
}
}
gl.glDisable(GL.GL_BLEND);
textRenderer.beginRendering(width,height);
try {
double xShift=xText + halfTextWidth;
double yShift=yText + halfTextHeight;
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glTranslated(xShift,yShift,0);
gl.glRotated(90,0,0,1.0f);
gl.glTranslated(-xShift,-yShift,0);
textRenderer.setColor(textColor[0],textColor[1],textColor[2],textColor[3]);
textRenderer.draw(text,xText,yText);
}
  finally {
textRenderer.endRendering();
}
}

Fixed version (ground truth):
protected void paintToVertical(GL gl,int width,int height,Rectangle2D textBounds){
  int xText=padding;
  int yText=padding;
  double textWidth=textBounds.getWidth();
  double textHeight=textBounds.getHeight();
  int halfTextWidth=(int)(textWidth / 2d);
  int halfTextHeight=(int)(textHeight / 2d);
switch (hPos) {
case Left:
    xText=(int)(padding - halfTextWidth + halfTextHeight);
  break;
case Center:
xText=(int)(width / 2d - halfTextWidth);
break;
case Right:
xText=(int)(width - halfTextWidth - halfTextHeight- padding);
break;
}
switch (vPos) {
case Bottom:
yText=(int)(padding - halfTextHeight + halfTextWidth);
break;
case Center:
yText=(int)(height / 2d - halfTextHeight);
break;
case Top:
yText=(int)(height - halfTextHeight - halfTextWidth- padding);
break;
}
if (this.paintBackground) {
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(0,width,0,height,-1,1);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glEnable(GL.GL_BLEND);
int buffer=2;
int xTextMin=(int)(xText + halfTextWidth - halfTextHeight - buffer);
int yTextMin=(int)(yText + halfTextWidth + halfTextHeight+ buffer);
int xTextMax=(int)(xText + halfTextWidth + halfTextHeight+ buffer+ 3);
int yTextMax=(int)(yText - halfTextWidth + halfTextHeight - buffer);
gl.glColor4fv(backgroundColor,0);
gl.glBegin(GL.GL_QUADS);
try {
gl.glVertex2f(xTextMin,yTextMin);
gl.glVertex2f(xTextMax,yTextMin);
gl.glVertex2f(xTextMax,yTextMax);
gl.glVertex2f(xTextMin,yTextMax);
}
  finally {
gl.glEnd();
}
}
gl.glDisable(GL.GL_BLEND);
textRenderer.beginRendering(width,height);
try {
double xShift=xText + halfTextWidth;
double yShift=yText + halfTextHeight;
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glTranslated(xShift,yShift,0);
gl.glRotated(90,0,0,1.0f);
gl.glTranslated(-xShift,-yShift,0);
textRenderer.setColor(textColor[0],textColor[1],textColor[2],textColor[3]);
textRenderer.draw(text,xText,yText);
}
  finally {
textRenderer.endRendering();
}
}