Exemplo n.º 1
0
 /**
  * Converts a colour from #rrggbb to Java Color object.
  *
  * @param rgb String e.g. #ff00ee
  * @return Colour
  * @throws IllegalArgumentException If colour string is not valid
  */
 protected Color convertRgb(String rgb) throws IllegalArgumentException {
   // Get colour parameter
   Matcher m = REGEX_RGB.matcher(rgb);
   if (!m.matches()) {
     throw new IllegalArgumentException(
         "MathML invalid colour '" + rgb + "'; expected #rrggbb (lower-case)");
   }
   return new Color(
       Integer.parseInt(m.group(1), 16),
       Integer.parseInt(m.group(2), 16),
       Integer.parseInt(m.group(3), 16));
 }