public void setString ( String string ) { rawString = string ; colorIndices . clear ( ) ; // Search for color codes final StringBuilder stringBuilder = new StringBuilder ( string ) ; final Matcher matcher = COLOR_PATTERN . matcher ( string ) ; int removedCount = 0 ; while ( matcher . find ( ) ) { final int index = matcher . start ( ) - removedCount ; // Ignore escaped color codes if ( index > 0 && stringBuilder . charAt ( index - 1 ) == ' ' ) { // Remove the escape character stringBuilder . deleteCharAt ( index - 1 ) ; removedCount ++ ; continue ; } // Add the color for the index and delete it from the string final String colorCode = matcher . group ( ) ; colorIndices . put ( index , CausticUtil . fromPackedARGB ( Long . decode ( colorCode ) . intValue ( ) ) ) ; final int length = colorCode . length ( ) ; stringBuilder . delete ( index , index + length ) ; removedCount += length ; } // Color code free string this . string = stringBuilder . toString ( ) ; }
Sets the string to render .