private void cleanupShadowsAndDrownedObjects(final boolean avoidSpaces){
  final int[] items=getUnusedFragments();
  final int count=items.length;
  int c, n;
  String separator;
  float diff;
  for (int p=0; p < count; p++) {
    c=items[p];
    if (!isUsed[c]) {
      float midX=(f_x1[c] + f_x2[c]) / 2;
      float midY=(f_y1[c] + f_y2[c]) / 2;
      for (int p2=p + 1; p2 < count; p2++) {
        n=items[p2];
        if ((f_x1[n] != f_x2[n]) && (!isUsed[n]) && (!isUsed[c])) {
          float fontDiff=this.fontSize[n] - fontSize[c];
          if (fontDiff < 0) {
            fontDiff=-fontDiff;
          }
          diff=(f_x2[n] - f_x1[n]) - (f_x2[c] - f_x1[c]);
          if (diff < 0) {
            diff=-diff;
          }
          if (fontDiff == 0 && (midX > f_x1[n]) && (midX < f_x2[n]) && (diff < 10) && (midY < f_y1[n]) && (midY > f_y2[n])) {
            isUsed[n]=true;
          }
 else {
            final boolean a_in_b=(f_x1[n] > f_x1[c]) && (f_x2[n] < f_x2[c]) && (f_y1[n] < f_y1[c])&& (f_y2[n] > f_y2[c]);
            final boolean b_in_a=(f_x1[c] > f_x1[n]) && (f_x2[c] < f_x2[n]) && (f_y1[c] < f_y1[n])&& (f_y2[c] > f_y2[n]);
            if (a_in_b || b_in_a) {
              if (f_y2[c] > f_y2[n]) {
                separator=getLineDownSeparator(content[c],content[n],isXMLExtraction);
                if ((!avoidSpaces) || (separator.indexOf(' ') == -1)) {
                  merge(c,n,separator,true);
                }
              }
 else {
                separator=getLineDownSeparator(content[n],content[c],isXMLExtraction);
                if (!avoidSpaces || separator.indexOf(' ') == -1) {
                  merge(n,c,separator,true);
                }
              }
              midX=(f_x1[c] + f_x2[c]) / 2;
              midY=(f_y1[c] + f_y2[c]) / 2;
            }
          }
        }
      }
    }
  }
}

private void cleanupShadowsAndDrownedObjects ( final boolean avoidSpaces ) { final int [ ] items = getUnusedFragments ( ) ; final int count = items . length ; int c , n ; String separator ; float diff ; for ( int p = 0 ; p < count ; p ++ ) { c = items [ p ] ; if ( ! isUsed [ c ] ) { float midX = ( f_x1 [ c ] + f_x2 [ c ] ) / 2 ; float midY = ( f_y1 [ c ] + f_y2 [ c ] ) / 2 ; for ( int p2 = p + 1 ; p2 < count ; p2 ++ ) { n = items [ p2 ] ; if ( ( f_x1 [ n ] != f_x2 [ n ] ) && ( ! isUsed [ n ] ) && ( ! isUsed [ c ] ) ) { float fontDiff = this . fontSize [ n ] - fontSize [ c ] ; if ( fontDiff < 0 ) { fontDiff = - fontDiff ; } diff = ( f_x2 [ n ] - f_x1 [ n ] ) - ( f_x2 [ c ] - f_x1 [ c ] ) ; if ( diff < 0 ) { diff = - diff ; } if ( fontDiff == 0 && ( midX > f_x1 [ n ] ) && ( midX < f_x2 [ n ] ) && ( diff < 10 ) && ( midY < f_y1 [ n ] ) && ( midY > f_y2 [ n ] ) ) { isUsed [ n ] = true ; } else { final boolean a_in_b = ( f_x1 [ n ] > f_x1 [ c ] ) && ( f_x2 [ n ] < f_x2 [ c ] ) && ( f_y1 [ n ] < f_y1 [ c ] ) && ( f_y2 [ n ] > f_y2 [ c ] ) ; final boolean b_in_a = ( f_x1 [ c ] > f_x1 [ n ] ) && ( f_x2 [ c ] < f_x2 [ n ] ) && ( f_y1 [ c ] < f_y1 [ n ] ) && ( f_y2 [ c ] > f_y2 [ n ] ) ; if ( a_in_b || b_in_a ) { if ( f_y2 [ c ] > f_y2 [ n ] ) { separator = getLineDownSeparator ( content [ c ] , content [ n ] , isXMLExtraction ) ; if ( ( ! avoidSpaces ) || ( separator . indexOf ( ' ' ) == - 1 ) ) { merge ( c , n , separator , true ) ; } } else { separator = getLineDownSeparator ( content [ n ] , content [ c ] , isXMLExtraction ) ; if ( ! avoidSpaces || separator . indexOf ( ' ' ) == - 1 ) { merge ( n , c , separator , true ) ; } } midX = ( f_x1 [ c ] + f_x2 [ c ] ) / 2 ; midY = ( f_y1 [ c ] + f_y2 [ c ] ) / 2 ; } } } } } } }
remove shadows from text created by double printing of text and drowned items where text inside other text
