use of com.ait.lienzo.shared.core.types.ColorName in project kie-wb-common by kiegroup.
the class SVGAttributeParser method toHexColorString.
public static String toHexColorString(final String raw) {
if (raw.startsWith("#")) {
return "#" + StringUtils.leftPad(raw.substring(1, raw.length()), 6, "0");
}
if (raw.startsWith("rgb")) {
Matcher m = RBG_PATTERN.matcher(raw);
if (m.matches()) {
final int r = Integer.valueOf(m.group(1));
final int g = Integer.valueOf(m.group(2));
final int b = Integer.valueOf(m.group(3));
return rgbToHexString(r, g, b);
}
}
final ColorName name = ColorName.lookup(raw);
final Color color = null != name ? ColorName.lookup(raw).getColor() : null;
if (null != color) {
return rgbToHexString(color.getR(), color.getG(), color.getB());
}
throw new RuntimeException("RGB value cannot be parsed! [" + raw + "]");
}