public static String convertColorName(String color){
  if (color.length() != 0) {
switch (color.charAt(0)) {
case 'b':
case 'B':
      if (color.equalsIgnoreCase("black")) {
        return "0x000000";
      }
    if (color.equalsIgnoreCase("blue")) {
      return "0x0000FF";
    }
  break;
case 'g':
case 'G':
if (color.equalsIgnoreCase("green")) {
  return "0x008000";
}
if (color.equalsIgnoreCase("gray")) {
return "0x808080";
}
break;
case 's':
case 'S':
if (color.equalsIgnoreCase("silver")) {
return "0xC0C0C0";
}
break;
case 'l':
case 'L':
if (color.equalsIgnoreCase("lime")) {
return "0x00FF00";
}
break;
case 'o':
case 'O':
if (color.equalsIgnoreCase("olive")) {
return "0x808000";
}
break;
case 'w':
case 'W':
if (color.equalsIgnoreCase("white")) {
return "0xFFFFFF";
}
break;
case 'y':
case 'Y':
if (color.equalsIgnoreCase("yellow")) {
return "0xFFFF00";
}
break;
case 'm':
case 'M':
if (color.equalsIgnoreCase("maroon")) {
return "0x800000";
}
if (color.equalsIgnoreCase("magenta")) {
return "0xFF00FF";
}
break;
case 'n':
case 'N':
if (color.equalsIgnoreCase("navy")) {
return "0x000080";
}
break;
case 'r':
case 'R':
if (color.equalsIgnoreCase("red")) {
return "0xFF0000";
}
break;
case 'p':
case 'P':
if (color.equalsIgnoreCase("purple")) {
return "0x800080";
}
break;
case 't':
case 'T':
if (color.equalsIgnoreCase("teal")) {
return "0x008080";
}
break;
case 'f':
case 'F':
if (color.equalsIgnoreCase("fuchsia")) {
return "0xFF00FF";
}
break;
case 'a':
case 'A':
if (color.equalsIgnoreCase("aqua")) {
return "0x00FFFF";
}
break;
case 'c':
case 'C':
if (color.equalsIgnoreCase("cyan")) {
return "0x00FFFF";
}
break;
case 'h':
case 'H':
if (color.equalsIgnoreCase("haloGreen")) {
return "0x80FF4D";
}
if (color.equalsIgnoreCase("haloBlue")) {
return "0x009DFF";
}
if (color.equalsIgnoreCase("haloOrange")) {
return "0xFFB600";
}
if (color.equalsIgnoreCase("haloSilver")) {
return "0xAECAD9";
}
break;
}
}
return null;
}

public static String convertColorName ( String color ) { if ( color . length ( ) != 0 ) { switch ( color . charAt ( 0 ) ) { case 'b' : case 'B' : if ( color . equalsIgnoreCase ( "black" ) ) { return "0x000000" ; } if ( color . equalsIgnoreCase ( "blue" ) ) { return "0x0000FF" ; } break ; case 'g' : case 'G' : if ( color . equalsIgnoreCase ( "green" ) ) { return "0x008000" ; } if ( color . equalsIgnoreCase ( "gray" ) ) { return "0x808080" ; } break ; case 's' : case 'S' : if ( color . equalsIgnoreCase ( "silver" ) ) { return "0xC0C0C0" ; } break ; case 'l' : case 'L' : if ( color . equalsIgnoreCase ( "lime" ) ) { return "0x00FF00" ; } break ; case 'o' : case 'O' : if ( color . equalsIgnoreCase ( "olive" ) ) { return "0x808000" ; } break ; case 'w' : case 'W' : if ( color . equalsIgnoreCase ( "white" ) ) { return "0xFFFFFF" ; } break ; case 'y' : case 'Y' : if ( color . equalsIgnoreCase ( "yellow" ) ) { return "0xFFFF00" ; } break ; case 'm' : case 'M' : if ( color . equalsIgnoreCase ( "maroon" ) ) { return "0x800000" ; } if ( color . equalsIgnoreCase ( "magenta" ) ) { return "0xFF00FF" ; } break ; case 'n' : case 'N' : if ( color . equalsIgnoreCase ( "navy" ) ) { return "0x000080" ; } break ; case 'r' : case 'R' : if ( color . equalsIgnoreCase ( "red" ) ) { return "0xFF0000" ; } break ; case 'p' : case 'P' : if ( color . equalsIgnoreCase ( "purple" ) ) { return "0x800080" ; } break ; case 't' : case 'T' : if ( color . equalsIgnoreCase ( "teal" ) ) { return "0x008080" ; } break ; case 'f' : case 'F' : if ( color . equalsIgnoreCase ( "fuchsia" ) ) { return "0xFF00FF" ; } break ; case 'a' : case 'A' : if ( color . equalsIgnoreCase ( "aqua" ) ) { return "0x00FFFF" ; } break ; case 'c' : case 'C' : if ( color . equalsIgnoreCase ( "cyan" ) ) { return "0x00FFFF" ; } break ; case 'h' : case 'H' : if ( color . equalsIgnoreCase ( "haloGreen" ) ) { return "0x80FF4D" ; } if ( color . equalsIgnoreCase ( "haloBlue" ) ) { return "0x009DFF" ; } if ( color . equalsIgnoreCase ( "haloOrange" ) ) { return "0xFFB600" ; } if ( color . equalsIgnoreCase ( "haloSilver" ) ) { return "0xAECAD9" ; } break ; } } return null ; }
converts one of the sixteen colors defined in http : / / www . w3 . org / tr / rec - html40 / types . html # h - 6 . 5 to the 0x000000 format .
