Changeset 15904 in josm for trunk/src/com/kitfox
- Timestamp:
- 2020-02-22T19:40:29+01:00 (5 years ago)
- Location:
- trunk/src/com/kitfox/svg
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/kitfox/svg/SVGElement.java
r15901 r15904 89 89 * Styles defined for this elemnt via the <b>style</b> attribute. 90 90 */ 91 protected final HashMap<String, St yleAttribute> inlineStyles = new HashMap<>();91 protected final HashMap<String, String> inlineStyles = new HashMap<>(); 92 92 /** 93 93 * Presentation attributes set for this element. Ie, any attribute other 94 94 * than the <b>style</b> attribute. 95 95 */ 96 protected final HashMap<String, St yleAttribute> presAttribs = new HashMap<>();96 protected final HashMap<String, String> presAttributes = new HashMap<>(); 97 97 /** 98 98 * A list of presentation attributes to not include in the presentation … … 273 273 if (style != null) 274 274 { 275 HashMap<?, ?> map =XMLParseUtil.parseStyle(style, inlineStyles);275 XMLParseUtil.parseStyle(style, inlineStyles); 276 276 } 277 277 … … 299 299 String value = attrs.getValue(i); 300 300 301 presAttrib s.put(name, new StyleAttribute(name, value == null ? null : value.intern()));301 presAttributes.put(name, value == null ? null : value.intern()); 302 302 } 303 303 } … … 316 316 public Set<String> getPresentationAttributes() 317 317 { 318 return presAttrib s.keySet();318 return presAttributes.keySet(); 319 319 } 320 320 … … 486 486 487 487 //Check for local inline styles 488 St yleAttributestyAttr = inlineStyles.get(styName);489 490 attrib.setStringValue(styAttr == null ? "" : styAttr .getStringValue());488 String styAttr = inlineStyles.get(styName); 489 490 attrib.setStringValue(styAttr == null ? "" : styAttr); 491 491 492 492 //Return if we've found a non animated style … … 498 498 499 499 //Check for presentation attribute 500 St yleAttribute presAttr = presAttribs.get(styName);501 502 attrib.setStringValue(presAttr == null ? "" : presAttr .getStringValue());500 String presAttr = presAttributes.get(styName); 501 502 attrib.setStringValue(presAttr == null ? "" : presAttr); 503 503 504 504 //Return if we've found a presentation attribute instead … … 546 546 { 547 547 //Check for local inline styles 548 return inlineStyles.get(styName); 548 final String value = inlineStyles.get(styName); 549 return value != null ? new StyleAttribute(styName, value) : null; 549 550 } 550 551 … … 561 562 562 563 //Make sure we have a coresponding presentation attribute 563 St yleAttribute presAttr = presAttribs.get(presName);564 String presAttr = presAttributes.get(presName); 564 565 565 566 //Copy presentation value directly 566 attrib.setStringValue(presAttr == null ? "" : presAttr .getStringValue());567 attrib.setStringValue(presAttr == null ? "" : presAttr); 567 568 568 569 //Return if we found presentation attribute 569 if (presAttr != null) 570 { 571 return true; 572 } 573 574 return false; 570 return presAttr != null; 575 571 } 576 572 … … 584 580 { 585 581 //Check for local inline styles 586 return presAttribs.get(styName); 582 final String value = presAttributes.get(styName); 583 return value != null ? new StyleAttribute(styName, value) : null; 587 584 } 588 585 -
trunk/src/com/kitfox/svg/xml/XMLParseUtil.java
r14598 r15904 302 302 * @param map - A map to which these styles will be added 303 303 */ 304 public static HashMap<String, StyleAttribute> parseStyle(String styleString, HashMap<String, StyleAttribute> map) {304 public static void parseStyle(String styleString, HashMap<String, String> map) { 305 305 final Pattern patSemi = Pattern.compile(";"); 306 306 307 String[] styles = patSemi.split(styleString); 308 309 for (int i = 0; i < styles.length; i++) 310 { 311 if (styles[i].length() == 0) 312 { 313 continue; 314 } 315 316 int colon = styles[i].indexOf(':'); 317 if (colon == -1) 318 { 319 continue; 320 } 321 322 String key = styles[i].substring(0, colon).trim().intern(); 323 String value = quoteMatch.reset(styles[i].substring(colon + 1).trim()).replaceAll("").intern(); 324 325 map.put(key, new StyleAttribute(key, value)); 326 } 327 328 return map; 307 // com.kitfox.svg.xml.StyleAttribute 58,595 (3.6%) 1,992,230 B (1.4%) n/a 308 patSemi.splitAsStream(styleString) 309 .filter(style -> !style.isEmpty()) 310 .forEach(style -> { 311 int colon = style.indexOf(':'); 312 if (colon == -1) return; 313 String key = style.substring(0, colon).trim().intern(); 314 String value = quoteMatch.reset(style.substring(colon + 1).trim()).replaceAll("").intern(); 315 map.put(key, value); 316 }); 329 317 } 330 318 }
Note:
See TracChangeset
for help on using the changeset viewer.