class ColorUtilities {

    public static Color convertFromColorString(String color)
    {
        Color aColor = null;
        if (color != null)
        {
            try
            {
                // see if the property corresponds to a Color.<name> static
                // field
                Field colorField = Color.class.getField(color.toUpperCase());
                try
                {
                    aColor = (Color)colorField.get(null);
                }
                catch (IllegalAccessException e)
                {
                    LOGGER.error("Could not access field by reflection.", e);
                }
            }
            catch (NoSuchFieldException e)
            {
                // takes open ended formats like: 45-32-18-9,100-100-100-100
                // in r-g-b-a format
                String[] colors = color.split("-");
                if (colors.length == 4)
                {
                    try
                    {
                        aColor = new java.awt.Color(Integer.parseInt(colors[0]), Integer.parseInt(colors[1]),
                                Integer.parseInt(colors[2]), Integer.parseInt(colors[3]));
                    }
                    catch (NumberFormatException nfe)
                    {
                        LOGGER.warn("Failed to parse color [" + color + "]: " + nfe, nfe);
                    }
                    catch (IllegalArgumentException iae)
                    {
                        LOGGER.warn("Failed to parse color [" + color + "]: " + iae, iae);
                    }
                }
            }
        }
        return aColor;
    }

    private  ColorUtilities();

}