private static boolean isSameLine(final TextPosition cur,final TextPosition prev){
  if (cur.getY() == prev.getY()) {
    return true;
  }
 else {
    final float prevCenter=prev.getY() + prev.getHeight() / 2.0f;
    final float prevHeight=prev.getHeight();
    final float curCenter=cur.getY() + cur.getHeight() / 2.0f;
    final boolean result=Math.abs(curCenter - prevCenter) < (prevHeight * 0.25f);
    return result;
  }
}

private static boolean isSameLine ( final TextPosition cur , final TextPosition prev ) { if ( cur . getY ( ) == prev . getY ( ) ) { return true ; } else { final float prevCenter = prev . getY ( ) + prev . getHeight ( ) / 2.0f ; final float prevHeight = prev . getHeight ( ) ; final float curCenter = cur . getY ( ) + cur . getHeight ( ) / 2.0f ; final boolean result = Math . abs ( curCenter - prevCenter ) < ( prevHeight * 0.25f ) ; return result ; } }
detects whether text in two positions is on the same line . this method is a bit fuzzy so we also get potential superscripts and subscripts .
