private String trimText(String text){
  if (text.length() > BUBBLE_TEXT_LENGTH) {
    text=text.substring(0,BUBBLE_TEXT_LENGTH);
    int n=text.lastIndexOf(' ');
    n=Math.max(n,text.lastIndexOf('-'));
    n=Math.max(n,text.lastIndexOf('.'));
    n=Math.max(n,text.lastIndexOf(','));
    if (n > 0) {
      text=text.substring(0,n);
    }
    text+=" ...";
  }
  return text;
}

private String trimText ( String text ) { if ( text . length ( ) > BUBBLE_TEXT_LENGTH ) { text = text . substring ( 0 , BUBBLE_TEXT_LENGTH ) ; int n = text . lastIndexOf ( ' ' ) ; n = Math . max ( n , text . lastIndexOf ( '-' ) ) ; n = Math . max ( n , text . lastIndexOf ( '.' ) ) ; n = Math . max ( n , text . lastIndexOf ( ',' ) ) ; if ( n > 0 ) { text = text . substring ( 0 , n ) ; } text += " ..." ; } return text ; }
trim text for a speech bubble .
