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

Last change on this file since 2675 was 2675, checked in by jttt, 14 years ago

MapPaintVisitor - delegate drawing to styles, MapPaintVisitor should only select correct style and then let primitives draw in correct order. (not finished yet)

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