private static String formatBubble ( final BubbleWrap bubble , final String message , final int longestLine ) { String newLine = System . getProperty ( "line.separator" ) ; String [ ] lines = message . split ( newLine ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( bubble . buildTop ( longestLine ) ) ; if ( lines . length > 1 ) { sb . append ( bubble . formatMultiOpen ( lines [ 0 ] , longestLine ) ) ; for ( int i = 1 ; i < ( lines . length - 1 ) ; i ++ ) { sb . append ( bubble . formatMultiMid ( lines [ i ] , longestLine ) ) ; } sb . append ( bubble . formatMultiEnd ( lines [ ( lines . length - 1 ) ] , longestLine ) ) ; } else { sb . append ( bubble . formatSingle ( lines [ 0 ] ) ) ; } sb . append ( bubble . buildBottom ( longestLine ) ) ; return sb . toString ( ) ; }
Draws a complete bubble around a line - wrapped message .