Changeset 8484 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2015-06-11T00:17:21+02:00 (9 years ago)
Author:
Don-vip
Message:

see #11266 - tagging presets icons: avoid unnecessary I/O access to non-existing png file + javadoc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetType.java

    r7937 r8484  
    1010 */
    1111public enum TaggingPresetType {
     12    /** Node */
    1213    NODE(/* ICON */ "Mf_node", "node"),
     14    /** Way */
    1315    WAY(/* ICON */ "Mf_way", "way"),
     16    /** Relation */
    1417    RELATION(/* ICON */ "Mf_relation", "relation"),
     18    /** Closed way */
    1519    CLOSEDWAY(/* ICON */ "Mf_closedway", "closedway");
    1620    private final String iconName;
     
    1822
    1923    TaggingPresetType(String iconName, String name) {
    20         this.iconName = iconName;
     24        this.iconName = iconName + ".svg";
    2125        this.name = name;
    2226    }
    2327
     28    /**
     29     * Replies the SVG icon name.
     30     * @return the SVG icon name
     31     */
    2432    public String getIconName() {
    2533        return iconName;
    2634    }
    2735
     36    /**
     37     * Replies the name, as used in XML presets.
     38     * @return the name: "node", "way", "relation" or "closedway"
     39     */
    2840    public String getName() {
    2941        return name;
    3042    }
    3143
     44    /**
     45     * Determines the {@code TaggingPresetType} of a given primitive.
     46     * @param p The OSM primitive
     47     * @return the {@code TaggingPresetType} of {@code p}
     48     */
    3249    public static TaggingPresetType forPrimitive(OsmPrimitive p) {
    3350        return forPrimitiveType(p.getDisplayType());
    3451    }
    3552
     53    /**
     54     * Determines the {@code TaggingPresetType} of a given primitive type.
     55     * @param type The OSM primitive type
     56     * @return the {@code TaggingPresetType} of {@code type}
     57     */
    3658    public static TaggingPresetType forPrimitiveType(OsmPrimitiveType type) {
    3759        if (type == OsmPrimitiveType.NODE) return NODE;
     
    4365    }
    4466
     67    /**
     68     * Determines the {@code TaggingPresetType} from a given string.
     69     * @param type The OSM primitive type as string ("node", "way", "relation" or "closedway")
     70     * @return the {@code TaggingPresetType} from {@code type}
     71     */
    4572    public static TaggingPresetType fromString(String type) {
    4673        for (TaggingPresetType t : TaggingPresetType.values()) {
     
    5178        return null;
    5279    }
    53 
    5480}
Note: See TracChangeset for help on using the changeset viewer.