Program: 70585
Project: 70585
Buggy source:
/** 
 * Adjusts the text by one half of width or height, according to the direction in position state. Returns new location if position changed, or returns the original location instance without position change.
 * @param iLabelPosition position state
 * @param lo location
 * @param itm
 * @param dAngleInDegrees the rotated degree of font
 * @return new location if position changed, or the original locationinstance.
 */
final protected Location adjustTextPosition(int iLabelPosition,final Location lo,final ITextMetrics itm,double dAngleInDegrees){
  if (iLabelPosition > POSITION_MASK) {
    final double dAngleInRadians=((-dAngleInDegrees * Math.PI) / 180.0);
    final double dSineTheta=Math.abs(Math.sin(dAngleInRadians));
    final double dCosTheta=Math.abs(Math.cos(dAngleInRadians));
    Location newLo=LocationImpl.copyInstance(lo);
    if ((iLabelPosition & POSITION_MOVE_ABOVE) == POSITION_MOVE_ABOVE) {
      newLo.setY(lo.getY() - (itm.getFullHeight() * dCosTheta + itm.getFullWidth() * dSineTheta) / 2);
    }
 else     if ((iLabelPosition & POSITION_MOVE_BELOW) == POSITION_MOVE_BELOW) {
      newLo.setY(lo.getY() + (itm.getFullHeight() * dCosTheta + itm.getFullWidth() * dSineTheta) / 2);
    }
 else     if ((iLabelPosition & POSITION_MOVE_LEFT) == POSITION_MOVE_LEFT) {
      newLo.setX(lo.getX() - (itm.getFullWidth() * dCosTheta + itm.getFullHeight() * dSineTheta) / 2);
    }
 else     if ((iLabelPosition & POSITION_MOVE_RIGHT) == POSITION_MOVE_RIGHT) {
      newLo.setX(lo.getX() + (itm.getFullWidth() * dCosTheta + itm.getFullHeight() * dSineTheta) / 2);
    }
    return newLo;
  }
  return lo;
}

Fixed version (ground truth):
/** 
 * Adjusts the text by one half of width or height, according to the direction in position state. Returns new location if position changed, or returns the original location instance without position change.
 * @param iLabelPosition position state
 * @param lo location
 * @param itm
 * @param dAngleInDegrees the rotated degree of font
 * @return new location if position changed, or the original locationinstance.
 */
final protected Location adjustTextPosition(int iLabelPosition,final Location lo,final ITextMetrics itm,double dAngleInDegrees){
  if (iLabelPosition > POSITION_MASK) {
    final double dAngleInRadians=((-dAngleInDegrees * Math.PI) / 180.0);
    final double dSineTheta=Math.abs(Math.sin(dAngleInRadians));
    final double dCosTheta=Math.abs(Math.cos(dAngleInRadians));
    Location newLo=lo.copyInstance();
    if ((iLabelPosition & POSITION_MOVE_ABOVE) == POSITION_MOVE_ABOVE) {
      newLo.setY(lo.getY() - (itm.getFullHeight() * dCosTheta + itm.getFullWidth() * dSineTheta) / 2);
    }
 else     if ((iLabelPosition & POSITION_MOVE_BELOW) == POSITION_MOVE_BELOW) {
      newLo.setY(lo.getY() + (itm.getFullHeight() * dCosTheta + itm.getFullWidth() * dSineTheta) / 2);
    }
 else     if ((iLabelPosition & POSITION_MOVE_LEFT) == POSITION_MOVE_LEFT) {
      newLo.setX(lo.getX() - (itm.getFullWidth() * dCosTheta + itm.getFullHeight() * dSineTheta) / 2);
    }
 else     if ((iLabelPosition & POSITION_MOVE_RIGHT) == POSITION_MOVE_RIGHT) {
      newLo.setX(lo.getX() + (itm.getFullWidth() * dCosTheta + itm.getFullHeight() * dSineTheta) / 2);
    }
    return newLo;
  }
  return lo;
}