private static int calculateDisplayedWidth(String string){
  final int tabWidth=DEFAULT_TAB_WIDTH;
  int column=0;
  for (int i=0; i < string.length(); i++) {
    if ('\t' == string.charAt(i)) {
      column+=tabWidth - (column % tabWidth);
    }
 else {
      column++;
    }
  }
  return column;
}

private static int calculateDisplayedWidth ( String string ) { final int tabWidth = DEFAULT_TAB_WIDTH ; int column = 0 ; for ( int i = 0 ; i < string . length ( ) ; i ++ ) { if ( '\t' == string . charAt ( i ) ) { column += tabWidth - ( column % tabWidth ) ; } else { column ++ ; } } return column ; }
returns the displayed width of a string , taking in account the displayed tab width . the result can be compared against the print margin .
