private float calculateTranslationHeightAfterFieldRot(Rectangle bBox,double pageRotation,double relFieldRotation){
  if (relFieldRotation == 0) {
    return 0.0f;
  }
  if (pageRotation == 0) {
    if (relFieldRotation == Math.PI / 2) {
      return bBox.getHeight();
    }
    if (relFieldRotation == Math.PI) {
      return bBox.getHeight();
    }
  }
  if (pageRotation == -Math.PI / 2) {
    if (relFieldRotation == -Math.PI / 2) {
      return bBox.getWidth() - bBox.getHeight();
    }
    if (relFieldRotation == Math.PI / 2) {
      return bBox.getHeight();
    }
    if (relFieldRotation == Math.PI) {
      return bBox.getWidth();
    }
  }
  if (pageRotation == -Math.PI) {
    if (relFieldRotation == -1 * Math.PI) {
      return bBox.getHeight();
    }
    if (relFieldRotation == -1 * Math.PI / 2) {
      return bBox.getHeight() - bBox.getWidth();
    }
    if (relFieldRotation == Math.PI / 2) {
      return bBox.getWidth();
    }
  }
  if (pageRotation == -3 * Math.PI / 2) {
    if (relFieldRotation == -3 * Math.PI / 2) {
      return bBox.getWidth();
    }
    if (relFieldRotation == -Math.PI) {
      return bBox.getWidth();
    }
  }
  return 0.0f;
}

private float calculateTranslationHeightAfterFieldRot ( Rectangle bBox , double pageRotation , double relFieldRotation ) { if ( relFieldRotation == 0 ) { return 0.0f ; } if ( pageRotation == 0 ) { if ( relFieldRotation == Math . PI / 2 ) { return bBox . getHeight ( ) ; } if ( relFieldRotation == Math . PI ) { return bBox . getHeight ( ) ; } } if ( pageRotation == - Math . PI / 2 ) { if ( relFieldRotation == - Math . PI / 2 ) { return bBox . getWidth ( ) - bBox . getHeight ( ) ; } if ( relFieldRotation == Math . PI / 2 ) { return bBox . getHeight ( ) ; } if ( relFieldRotation == Math . PI ) { return bBox . getWidth ( ) ; } } if ( pageRotation == - Math . PI ) { if ( relFieldRotation == - 1 * Math . PI ) { return bBox . getHeight ( ) ; } if ( relFieldRotation == - 1 * Math . PI / 2 ) { return bBox . getHeight ( ) - bBox . getWidth ( ) ; } if ( relFieldRotation == Math . PI / 2 ) { return bBox . getWidth ( ) ; } } if ( pageRotation == - 3 * Math . PI / 2 ) { if ( relFieldRotation == - 3 * Math . PI / 2 ) { return bBox . getWidth ( ) ; } if ( relFieldRotation == - Math . PI ) { return bBox . getWidth ( ) ; } } return 0.0f ; }
calculate the necessary height offset after applying field rotation so that the origin of the bounding box is the lower left corner with respect to the field text .
