source: josm/trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetType.java@ 6070

Last change on this file since 6070 was 6070, checked in by stoecker, 11 years ago

see #8853 remove tabs, trailing spaces, windows line ends, strange characters

File size: 1.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.tagging;
3
4import org.openstreetmap.josm.data.osm.OsmPrimitive;
5import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
6
7/**
8 * Enumeration of OSM primitive types associated with names and icons
9 */
10public enum TaggingPresetType {
11 NODE("Mf_node", "node"), WAY("Mf_way", "way"), RELATION("Mf_relation", "relation"), CLOSEDWAY("Mf_closedway", "closedway");
12 private final String iconName;
13 private final String name;
14
15 TaggingPresetType(String iconName, String name) {
16 this.iconName = iconName;
17 this.name = name;
18 }
19
20 public String getIconName() {
21 return iconName;
22 }
23
24 public String getName() {
25 return name;
26 }
27
28 public static TaggingPresetType forPrimitive(OsmPrimitive p) {
29 return forPrimitiveType(p.getDisplayType());
30 }
31
32 public static TaggingPresetType forPrimitiveType(OsmPrimitiveType type) {
33 if (type == OsmPrimitiveType.NODE) return NODE;
34 if (type == OsmPrimitiveType.WAY) return WAY;
35 if (type == OsmPrimitiveType.CLOSEDWAY) return CLOSEDWAY;
36 if (type == OsmPrimitiveType.RELATION || type == OsmPrimitiveType.MULTIPOLYGON)
37 return RELATION;
38 throw new IllegalArgumentException("Unexpected primitive type: " + type);
39 }
40
41 public static TaggingPresetType fromString(String type) {
42 for (TaggingPresetType t : TaggingPresetType.values()) {
43 if (t.getName().equals(type)) {
44 return t;
45 }
46 }
47 return null;
48 }
49
50}
Note: See TracBrowser for help on using the repository browser.