private static String getHexSingle ( String hex , int colorIndex ) { validateHex ( hex ) ; if ( hex . startsWith ( "#" ) ) { hex = hex . substring ( 1 ) ; } int colorCharacters = 1 ; int numColors = hex . length ( ) ; if ( numColors > 4 ) { colorCharacters ++ ; numColors /= 2 ; } String color = null ; if ( colorIndex >= 0 || numColors > 3 ) { if ( numColors > 3 ) { colorIndex ++ ; } int startIndex = colorIndex ; if ( colorCharacters > 1 ) { startIndex *= 2 ; } color = hex . substring ( startIndex , startIndex + colorCharacters ) ; color = expandShorthandHexSingle ( color ) ; } return color ; }
Get the hex single color