private static Color getColor ( String colorString ) { Color color = null ; String [ ] colorParts = colorString . split ( "," ) ; try { switch ( colorParts . length ) { case 1 : Field field = Color . class . getField ( colorString ) ; color = ( Color ) field . get ( null ) ; break ; case 3 : color = new Color ( Integer . parseInt ( colorParts [ 0 ] ) , Integer . parseInt ( colorParts [ 1 ] ) , Integer . parseInt ( colorParts [ 2 ] ) ) ; break ; case 4 : color = new Color ( Integer . parseInt ( colorParts [ 0 ] ) , Integer . parseInt ( colorParts [ 1 ] ) , Integer . parseInt ( colorParts [ 2 ] ) , Integer . parseInt ( colorParts [ 3 ] ) ) ; break ; default : throw new GeoPackageException ( "Unexpected color arguments: " + colorParts . length + ", color: " + colorString ) ; } } catch ( Exception e ) { throw new GeoPackageException ( "Invalid color: " + colorString + ", Allowable Formats: colorName | r,g,b | r,g,b,a" , e ) ; } return color ; }
Get the color from the string