public static Color parseColor(String str) throws NumberFormatException
	{
		if (str == null || str.equals(mxConstants.NONE))
		{
			return null;
		}
		else if (rgbRegex.matcher(str).matches())
		{
			return parseRgb(str);
		}
		else if (!str.startsWith("#"))
		{
			Color result = htmlColors.get(str);

			// LATER: Return the result even if it's null to avoid invalid color codes
			if (result != null)
			{
				return result;
			}
		}
		else if (str.length() == 4)
		{
			// Adds support for special short notation of hex colors, eg. #abc=#aabbcc
			str = new String(
					new char[] { '#', str.charAt(1), str.charAt(1),
							str.charAt(2), str.charAt(2), str.charAt(3),
							str.charAt(3) });
		}

		int value = 0;
		try
		{
			String tmp = str;

			if (tmp.startsWith("#"))
			{
				tmp = tmp.substring(1);
			}

			value = (int) Long.parseLong(tmp, 16);
		}
		catch (NumberFormatException nfe)
		{
			try
			{
				value = Long.decode(str).intValue();
			}
			catch (NumberFormatException e)
			{
				// ignores exception and returns black
			}
		}

		return new Color(value);
	}