- Timestamp:
- 2013-12-29T12:43:55+01:00 (11 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/MultiCascade.java
r5342 r6561 21 21 public MultiCascade() { 22 22 layers = new HashMap<String, Cascade>(); 23 range = new Range();23 range = Range.ZERO_TO_INFINITY; 24 24 } 25 25 -
trunk/src/org/openstreetmap/josm/gui/mappaint/Range.java
r3836 r6561 11 11 private double upper; 12 12 13 public Range() { 14 this.lower = 0; 15 this.upper = Double.POSITIVE_INFINITY; 16 } 13 public static final Range ZERO_TO_INFINITY = new Range(0.0, Double.POSITIVE_INFINITY); 17 14 18 15 public Range(double lower, double upper) { … … 77 74 return String.format("|s%s-%s", lower, upper); 78 75 } 76 77 @Override 78 public boolean equals(Object o) { 79 if (this == o) return true; 80 if (o == null || getClass() != o.getClass()) return false; 81 82 Range range = (Range) o; 83 84 if (Double.compare(range.lower, lower) != 0) return false; 85 if (Double.compare(range.upper, upper) != 0) return false; 86 87 return true; 88 } 89 90 @Override 91 public int hashCode() { 92 int result; 93 long temp; 94 temp = Double.doubleToLongBits(lower); 95 result = (int) (temp ^ (temp >>> 32)); 96 temp = Double.doubleToLongBits(upper); 97 result = 31 * result + (int) (temp ^ (temp >>> 32)); 98 return result; 99 } 79 100 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj
r6560 r6561 463 463 ( 464 464 ( 465 <SET> w() key=<IDENT> w() 466 ( <EQUAL> val=expression() )? 467 { ins.add(new Instruction.AssignmentInstruction(key.image, val == null ? true : val)); } 468 ( <RBRACE> { return ins; } | <SEMICOLON> w() ) 465 <SET> w() 466 (<FULLSTOP>)? // specification allows "set .class" to set "class". we also support "set class" 467 key=<IDENT> w() 468 ( <EQUAL> val=expression() )? 469 { ins.add(new Instruction.AssignmentInstruction(key.image, val == null ? true : val)); } 470 ( <RBRACE> { return ins; } | <SEMICOLON> w() ) 469 471 ) 470 472 | 471 473 key=<IDENT> w() <COLON> w() 472 474 ( -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r6538 r6561 267 267 268 268 public static class GeneralSelector extends AbstractSelector { 269 p rivateString base;270 public Range range;271 p rivateString subpart;269 public final String base; 270 public final Range range; 271 public final String subpart; 272 272 273 273 public GeneralSelector(String base, Pair<Integer, Integer> zoom, List<Condition> conds, String subpart) { … … 279 279 if (a <= b) { 280 280 range = fromLevel(a, b); 281 } 282 } 283 if (range == null) { 284 range = new Range(); 281 } else { 282 range = Range.ZERO_TO_INFINITY; 283 } 284 } else { 285 range = Range.ZERO_TO_INFINITY; 285 286 } 286 287 this.subpart = subpart; … … 348 349 @Override 349 350 public String toString() { 350 return base + ( range == null? "" : range) + Utils.join("", conds) + (subpart != null ? ("::" + subpart) : "");351 return base + (Range.ZERO_TO_INFINITY.equals(range) ? "" : range) + Utils.join("", conds) + (subpart != null ? ("::" + subpart) : ""); 351 352 } 352 353 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/xml/AreaPrototype.java
r3836 r6561 23 23 { 24 24 priority = 0; 25 range = new Range();25 range = Range.ZERO_TO_INFINITY; 26 26 closed = false; 27 27 color = null; -
trunk/src/org/openstreetmap/josm/gui/mappaint/xml/IconPrototype.java
r6070 r6561 22 22 public void init() { 23 23 priority = 0; 24 range = new Range();24 range = Range.ZERO_TO_INFINITY; 25 25 icon = null; 26 26 annotate = null; -
trunk/src/org/openstreetmap/josm/gui/mappaint/xml/LinePrototype.java
r6248 r6561 35 35 { 36 36 priority = 0; 37 range = new Range();37 range = Range.ZERO_TO_INFINITY; 38 38 width = -1; 39 39 realWidth = null; -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.groovy
r6560 r6561 10 10 import org.openstreetmap.josm.gui.mappaint.MultiCascade 11 11 import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.MapCSSParser 12 import org.openstreetmap.josm.tools.Utils 13 14 import java.awt.Color 12 15 13 16 class MapCSSParserTest { … … 60 63 def css = new MapCSSStyleSource("") 61 64 getParser("" + 62 "way[highway=footway] { set path; color: #FF6644; width: 2; }\n" +65 "way[highway=footway] { set .path; color: #FF6644; width: 2; }\n" + 63 66 "way[highway=path] { set path; color: brown; width: 2; }\n" + 64 67 "way[\"set\"=escape] { }\n" + … … 75 78 assert "orange".equals(mc2.getCascade("default").get("color", null, String.class)) 76 79 assert mc2.getCascade("default").get("text-color", null, String.class) == null 80 def mc3 = new MultiCascade() 81 css.apply(mc3, getPrimitive("highway", "footway"), 1, null, false); 82 assert Utils.hexToColor("#FF6644").equals(mc3.getCascade("default").get("color", null, Color.class)) 77 83 } 78 84
Note:
See TracChangeset
for help on using the changeset viewer.