source: osm/applications/editors/josm/plugins/mappaint/src/mappaint/ElemStyles.java@ 3590

Last change on this file since 3590 was 3590, checked in by ulf, 18 years ago

make it possible to have both an icon and an area for the same key/value pair (in a single or two rules - as you like). I've used it for amenity=parking, but this will probably be useful for other key/values as well.

Mixing area and line is still not possible, basically because JOSM core doesn't make a difference here (it's both just a way for JOSM). Fortunately, rules with both area and line possible are pretty rare.

File size: 1.4 KB
Line 
1package mappaint;
2
3import java.util.HashMap;
4import java.util.Iterator;
5
6import org.openstreetmap.josm.data.osm.OsmPrimitive;
7public class ElemStyles
8{
9 HashMap<String, ElemStyle> styles;
10
11 public ElemStyles()
12 {
13 styles = new HashMap<String, ElemStyle>();
14 }
15
16 public void add (String k, String v, ElemStyle style)
17 {
18 String key = k + "=" + v;
19
20 /* unfortunately, there don't seem to be an efficient way to */
21 /* find out, if a given OsmPrimitive is an area or not, */
22 /* so distinguish only between way and node here - for now */
23 if(style instanceof AreaElemStyle) {
24 key = key + "way";
25 }
26 else if(style instanceof LineElemStyle) {
27 key = key + "way";
28 }
29 else if(style instanceof IconElemStyle) {
30 key = key + "node";
31 }
32 styles.put(key, style);
33 }
34
35 public ElemStyle getStyle (OsmPrimitive p)
36 {
37 if(p.keys!=null)
38 {
39 String classname;
40
41 if(p instanceof org.openstreetmap.josm.data.osm.Node) {
42 classname = "node";
43 } else {
44 classname = "way";
45 }
46 Iterator<String> iterator = p.keys.keySet().iterator();
47 while(iterator.hasNext())
48 {
49 String key = iterator.next();
50 String kv = key + "=" + p.keys.get(key) + classname;
51 if(styles.containsKey(kv))
52 {
53 return styles.get(kv);
54 }
55 }
56 }
57 return null;
58 }
59
60 public boolean isArea(OsmPrimitive p)
61 {
62 return getStyle(p) instanceof AreaElemStyle;
63 }
64}
Note: See TracBrowser for help on using the repository browser.