- public Color getColor(E id) {
- Color color = null;
-
- String bg = getString(id).trim();
- if (bg.startsWith("#") && (bg.length() == 7 || bg.length() == 9)) {
- try {
- int r = Integer.parseInt(bg.substring(1, 3), 16);
- int g = Integer.parseInt(bg.substring(3, 5), 16);
- int b = Integer.parseInt(bg.substring(5, 7), 16);
- int a = 255;
- if (bg.length() == 9) {
- a = Integer.parseInt(bg.substring(7, 9), 16);
- }
- color = new Color(r, g, b, a);
- } catch (NumberFormatException e) {
- color = null; // no changes
- }
- }
-
- // Try by name if still not found
- if (color == null) {
- try {
- Field field = Color.class.getField(bg);
- color = (Color) field.get(null);
- } catch (Exception e) {
- }
- }
- //
-
- return color;