Changeset 790
- Timestamp:
- 01/30/14 12:01:46 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/io/Conversion.java
r659 r790 349 349 350 350 try { 351 // Find the field and value of colorName 352 Field[] fields = java.awt.Color.class.getFields(); 353 Field field = null; 354 for (int i = 0; i < fields.length; i++) { 355 if (fields[i].getName().equalsIgnoreCase(value)) { 356 field = fields[i]; 357 break; 351 // Try to decode the string as a hex or octal color code 352 return Color.decode(value); 353 } catch (NumberFormatException nfe) { 354 try { 355 // Try to find the field in the Color class with the same name as the given string 356 Field[] fields = java.awt.Color.class.getFields(); 357 Field field = null; 358 for (int i = 0; i < fields.length; i++) { 359 if (fields[i].getName().equalsIgnoreCase(value)) { 360 field = fields[i]; 361 break; 362 } 358 363 } 364 return (Color) field.get(null); 365 } catch (Exception e) { 366 return getColor(value, (Color) orig); 359 367 } 360 return (Color) field.get(null);361 } catch (Exception e) {362 return getColor(value, (Color) orig);363 368 } 364 369 }
Note:
See TracChangeset
for help on using the changeset viewer.