private Alignment fineTuneAlignment(final Alignment firstCompute,final int xframe,final int yframe,final Point frameLocation,final Point componentLocation,final int compWidth,final int compHeight){
switch (firstCompute) {
case TOPLEFT:
case TOPRIGHT:
    if (componentLocation.x - frameLocation.x + compWidth / 2 > xframe / 2) {
      return Alignment.TOPRIGHT;
    }
 else {
      return Alignment.TOPLEFT;
    }
case LEFTBOTTOM:
case LEFTTOP:
  if (componentLocation.y - frameLocation.y + compHeight / 2 > yframe / 2) {
    return Alignment.LEFTBOTTOM;
  }
 else {
    return Alignment.LEFTTOP;
  }
case RIGHTBOTTOM:
case RIGHTTOP:
if (componentLocation.y - frameLocation.y + compHeight / 2 > yframe / 2) {
  return Alignment.RIGHTBOTTOM;
}
 else {
  return Alignment.RIGHTTOP;
}
case BOTTOMLEFT:
case BOTTOMRIGHT:
if (componentLocation.x - frameLocation.x + compWidth / 2 > xframe / 2) {
return Alignment.BOTTOMRIGHT;
}
 else {
return Alignment.BOTTOMLEFT;
}
default :
if (realAlignment == Alignment.INNERLEFT || realAlignment == Alignment.INNERRIGHT) {
return realAlignment;
}
if (componentLocation.x - frameLocation.x > xframe + frameLocation.x - (compWidth + componentLocation.x)) {
return Alignment.INNERRIGHT;
}
 else {
return Alignment.INNERLEFT;
}
}
}

private Alignment fineTuneAlignment ( final Alignment firstCompute , final int xframe , final int yframe , final Point frameLocation , final Point componentLocation , final int compWidth , final int compHeight ) { switch ( firstCompute ) { case TOPLEFT : case TOPRIGHT : if ( componentLocation . x - frameLocation . x + compWidth / 2 > xframe / 2 ) { return Alignment . TOPRIGHT ; } else { return Alignment . TOPLEFT ; } case LEFTBOTTOM : case LEFTTOP : if ( componentLocation . y - frameLocation . y + compHeight / 2 > yframe / 2 ) { return Alignment . LEFTBOTTOM ; } else { return Alignment . LEFTTOP ; } case RIGHTBOTTOM : case RIGHTTOP : if ( componentLocation . y - frameLocation . y + compHeight / 2 > yframe / 2 ) { return Alignment . RIGHTBOTTOM ; } else { return Alignment . RIGHTTOP ; } case BOTTOMLEFT : case BOTTOMRIGHT : if ( componentLocation . x - frameLocation . x + compWidth / 2 > xframe / 2 ) { return Alignment . BOTTOMRIGHT ; } else { return Alignment . BOTTOMLEFT ; } default : if ( realAlignment == Alignment . INNERLEFT || realAlignment == Alignment . INNERRIGHT ) { return realAlignment ; } if ( componentLocation . x - frameLocation . x > xframe + frameLocation . x - ( compWidth + componentLocation . x ) ) { return Alignment . INNERRIGHT ; } else { return Alignment . INNERLEFT ; } } }
after the calculatealignment ( ) decided the optimal side , this method decides which is the optimal direction for the bubble
