source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyle.java@ 3805

Last change on this file since 3805 was 3805, checked in by bastiK, 14 years ago

some renaming (to make future commits easier to read)

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