source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/xml/Prototype.java@ 3836

Last change on this file since 3836 was 3836, checked in by bastiK, 13 years ago

mappaint restructuring aimed at mapcss support:

  • area- and line style of multipolygon outer & inner ways are no longer determined by MapPaintVisitor, but the information is calculated in advance and cached
  • cache is aware of zoom level
  • z_index property to allow more fancy styles in future

Performance: when the style cache is filled, painting is the same or ~5% faster. The first painting, which includes style generation, takes ~30% longer than before. (There is potential for optimization, though.) Memory usage unchanged.

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint.xml;
3
4import java.util.Collection;
5
6import org.openstreetmap.josm.data.osm.OsmPrimitive;
7import org.openstreetmap.josm.data.osm.OsmUtils;
8import org.openstreetmap.josm.gui.mappaint.Range;
9
10abstract public class Prototype {
11 // zoom range to display the feature
12 public Range range;
13
14 public int priority;
15 public String code;
16 public Collection<XmlCondition> conditions = null;
17
18 public Prototype(Range range) {
19 this.range = range;
20 }
21
22 public Prototype() {
23 }
24
25 public String getCode() {
26 if(code == null) {
27 code = "";
28 if (conditions != null) {
29 for(XmlCondition r: conditions) {
30 code += r.toCode();
31 }
32 }
33 }
34 return code;
35 }
36
37 public boolean check(OsmPrimitive primitive)
38 {
39 if(conditions == null)
40 return true;
41 for(XmlCondition r : conditions)
42 {
43 String k = primitive.get(r.key);
44 String bv = OsmUtils.getNamedOsmBoolean(r.boolValue);
45 if(k == null || (r.value != null && !k.equals(r.value))
46 || (bv != null && !bv.equals(OsmUtils.getNamedOsmBoolean(k))))
47 return false;
48 }
49 return true;
50 }
51
52}
Note: See TracBrowser for help on using the repository browser.