Changeset 7238 in josm for trunk/src/org/openstreetmap/josm/gui/mappaint
- Timestamp:
- 2014-06-10T13:02:24+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/mappaint
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java
r7083 r7238 23 23 protected Map<String, Object> prop = new HashMap<>(); 24 24 25 private static final Pattern HEX_COLOR_PATTERN = Pattern.compile("#([0-9a-fA-F]{3}|[0-9a-fA-F]{6} )");25 private static final Pattern HEX_COLOR_PATTERN = Pattern.compile("#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})"); 26 26 27 27 public <T> T get(String key, T def, Class<T> klass) { … … 106 106 if (o instanceof Keyword) 107 107 return (T) ((Keyword) o).val; 108 if (o instanceof Color) { 109 Color c = (Color) o; 110 int alpha = c.getAlpha(); 111 if (alpha != 255) 112 return (T) String.format("#%06x%02x", ((Color) o).getRGB() & 0x00ffffff, alpha); 113 return (T) String.format("#%06x", ((Color) o).getRGB() & 0x00ffffff); 114 115 } 108 116 109 117 return (T) o.toString(); … … 129 137 if (o instanceof Boolean) 130 138 return (Boolean) o; 139 String s = null; 131 140 if (o instanceof Keyword) { 132 String s = ((Keyword) o).val; 133 if ("true".equals(s) || "yes".equals(s)) 134 return true; 135 if ("false".equals(s) || "no".equals(s)) 136 return false; 137 } 141 s = ((Keyword) o).val; 142 } else if (o instanceof String) { 143 s = (String) o; 144 } 145 if (s != null) 146 return !(s.isEmpty() || "false".equals(s) || "no".equals(s) || "0".equals(s) || "0.0".equals(s)); 147 if (o instanceof Number) 148 return ((Number) o).floatValue() == 0.0f; 149 if (o instanceof List) 150 return !((List) o).isEmpty(); 151 if (o instanceof float[]) 152 return ((float[]) o).length != 0; 153 138 154 return null; 139 155 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
r7237 r7238 467 467 468 468 /** 469 * Obtains the JOSM'key {@link org.openstreetmap.josm.data.Preferences} color for key {@code key},470 * and defaults to {@code def} if that is null.471 * @see org.openstreetmap.josm.data.Preferences#getColor(String, java.awt.Color)472 */473 public static Color JOSM_pref_color(String key, Color def) {474 Color res = Main.pref.getColor(key, null);475 return res != null ? res : def;476 }477 478 /**479 469 * Tests if string {@code target} matches pattern {@code pattern} 480 470 * @see Pattern#matches(String, CharSequence) … … 642 632 * @return the same object, unchanged 643 633 */ 634 @NullableArguments 644 635 public static Object print(Object o) { 645 636 System.out.print(o == null ? "none" : o.toString()); … … 653 644 * @return the same object, unchanged 654 645 */ 646 @NullableArguments 655 647 public static Object println(Object o) { 656 648 System.out.println(o == null ? "none" : o.toString());
Note:
See TracChangeset
for help on using the changeset viewer.