question: public static String transformToolTipText ( final String description , final boolean addHTMLTags , final int lineLength , final boolean escapeSlashes , final boolean escapeHTML ) { String completeText = description . trim ( ) ; if ( escapeHTML ) { completeText = Tools . escapeHTML ( completeText ) ; } if ( escapeSlashes ) { completeText = completeText . replaceAll ( "/" , "&#47;" ) ; } StringBuffer result = new StringBuffer ( ) ; if ( addHTMLTags ) { result . append ( "<html>" ) ; } completeText = Tools . transformAllLineSeparators ( completeText ) ; String [ ] lines = completeText . split ( "\n" ) ; for ( String text : lines ) { boolean first = true ; while ( text . length ( ) > lineLength ) { int spaceIndex = text . indexOf ( " " , lineLength ) ; if ( ! first ) { result . append ( "<br>" ) ; } first = false ; if ( spaceIndex >= 0 ) { result . append ( text . substring ( 0 , spaceIndex ) ) ; text = text . substring ( spaceIndex + 1 ) ; } else { result . append ( text ) ; text = "" ; } } if ( ! first && text . length ( ) > 0 ) { result . append ( "<br>" ) ; } result . append ( text ) ; result . append ( "<br>" ) ; } if ( addHTMLTags ) { result . append ( "</html>" ) ; } return result . toString ( ) ; }
target:  This method transforms the given tool tip text into HTML. Lines are splitted at linebreaks and additional line breaks are added after ca. lineLength characters.