Changeset 5754 in josm for trunk


Ignore:
Timestamp:
2013-03-03T16:19:49+01:00 (11 years ago)
Author:
Don-vip
Message:

fix #8486 - Render "work in progress" tags (note, fixme) as tagged nodes in wireframe mode

Location:
trunk/src/org/openstreetmap/josm/data/osm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r5687 r5754  
    2626import org.openstreetmap.josm.tools.Predicate;
    2727import org.openstreetmap.josm.tools.template_engine.TemplateEngineDataProvider;
     28
    2829
    2930/**
     
    101102
    102103    /**
     104     * If the primitive is annotated with a tag such as note, fixme, etc.
     105     * Match the "work in progress" tags in default elemstyles.xml.
     106     */
     107    protected static final int FLAG_ANNOTATED = 1 << 12;
     108
     109    /**
    103110     * Replies the sub-collection of {@link OsmPrimitive}s of type <code>type</code> present in
    104111     * another collection of {@link OsmPrimitive}s. The result collection is a list.
     
    606613    }
    607614
    608     /*----------------------------------
    609      * UNINTERESTING AND DIRECTION KEYS
    610      *----------------------------------*/
    611 
     615    /*---------------------------------------------------
     616     * WORK IN PROGRESS, UNINTERESTING AND DIRECTION KEYS
     617     *--------------------------------------------------*/
     618
     619    private static volatile Collection<String> workinprogress = null;
    612620    private static volatile Collection<String> uninteresting = null;
    613621    private static volatile Collection<String> discardable = null;
    614622   
    615623    /**
    616      * Contains a list of "uninteresting" keys that do not make an object
     624     * Returns a list of "uninteresting" keys that do not make an object
    617625     * "tagged".  Entries that end with ':' are causing a whole namespace to be considered
    618626     * "uninteresting".  Only the first level namespace is considered.
    619627     * Initialized by isUninterestingKey()
     628     * @return The list of uninteresting keys.
    620629     */
    621630    public static Collection<String> getUninterestingKeys() {
    622631        if (uninteresting == null) {
    623632            LinkedList<String> l = new LinkedList<String>(Arrays.asList(
    624                 "source", "source_ref", "source:", "note", "comment",
    625                 "converted_by", "watch", "watch:", "fixme", "FIXME",
     633                "source", "source_ref", "source:", "comment",
     634                "converted_by", "watch", "watch:",
    626635                "description", "attribution"));
    627636            l.addAll(getDiscardableKeys());
     637            l.addAll(getWorkInProgressKeys());
    628638            uninteresting = Main.pref.getCollection("tags.uninteresting", l);
    629639        }
     
    634644     * Returns a list of keys which have been deemed uninteresting to the point
    635645     * that they can be silently removed from data which is being edited.
     646     * @return The list of discardable keys.
    636647     */
    637648    public static Collection<String> getDiscardableKeys() {
    638         if(discardable == null) {
     649        if (discardable == null) {
    639650            discardable = Main.pref.getCollection("tags.discardable",
    640651                    Arrays.asList("created_by",
     
    647658        return discardable;
    648659    }
    649 
    650     /**
    651      * Returns true if key is considered "uninteresting".
     660   
     661    /**
     662     * Returns a list of "work in progress" keys that do not make an object
     663     * "tagged" but "annotated".
     664     * @return The list of work in progress keys.
     665     * @since 5754
     666     */
     667    public static Collection<String> getWorkInProgressKeys() {
     668        if (workinprogress == null) {
     669            workinprogress = Main.pref.getCollection("tags.workinprogress",
     670                    Arrays.asList("note", "fixme", "FIXME"));
     671        }
     672        return workinprogress;
     673    }
     674
     675    /**
     676     * Determines if key is considered "uninteresting".
     677     * @param key The key to check
     678     * @return true if key is considered "uninteresting".
    652679     */
    653680    public static boolean isUninterestingKey(String key) {
     
    713740    }
    714741
    715     /**
    716      * true if this object is considered "tagged". To be "tagged", an object
     742    private void updateAnnotated() {
     743        if (keys != null) {
     744            for (String key: keySet()) {
     745                if (getWorkInProgressKeys().contains(key)) {
     746                    updateFlagsNoLock(FLAG_ANNOTATED, true);
     747                    return;
     748                }
     749            }
     750        }
     751        updateFlagsNoLock(FLAG_ANNOTATED, false);
     752    }
     753
     754    /**
     755     * Determines if this object is considered "tagged". To be "tagged", an object
    717756     * must have one or more "interesting" tags. "created_by" and "source"
    718757     * are typically considered "uninteresting" and do not make an object
    719758     * "tagged".
     759     * @return true if this object is considered "tagged"
    720760     */
    721761    public boolean isTagged() {
    722762        return (flags & FLAG_TAGGED) != 0;
     763    }
     764   
     765    /**
     766     * Determines if this object is considered "annotated". To be "annotated", an object
     767     * must have one or more "work in progress" tags, such as "note" or "fixme".
     768     * @return true if this object is considered "annotated"
     769     * @since 5754
     770     */
     771    public boolean isAnnotated() {
     772        return (flags & FLAG_ANNOTATED) != 0;
    723773    }
    724774
     
    803853        updateDirectionFlags();
    804854        updateTagged();
     855        updateAnnotated();
    805856        if (dataSet != null) {
    806857            dataSet.fireTagsChanged(this, originalKeys);
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRenderer.java

    r5657 r5754  
    248248                color = selectedColor;
    249249            } else if (n.isConnectionNode()) {
    250                 if (n.isTagged()) {
     250                if (isNodeTagged(n)) {
    251251                    color = taggedConnectionColor;
    252252                } else {
     
    254254                }
    255255            } else {
    256                 if (n.isTagged()) {
     256                if (isNodeTagged(n)) {
    257257                    color = taggedColor;
    258258                } else {
     
    262262
    263263            final int size = max((ds.isSelected(n) ? selectedNodeSize : 0),
    264                     (n.isTagged() ? taggedNodeSize : 0),
     264                    (isNodeTagged(n) ? taggedNodeSize : 0),
    265265                    (n.isConnectionNode() ? connectionNodeSize : 0),
    266266                    unselectedNodeSize);
    267267
    268268            final boolean fill = (ds.isSelected(n) && fillSelectedNode) ||
    269             (n.isTagged() && fillTaggedNode) ||
     269            (isNodeTagged(n) && fillTaggedNode) ||
    270270            (n.isConnectionNode() && fillConnectionNode) ||
    271271            fillUnselectedNode;
     
    273273            drawNode(n, color, size, fill);
    274274        }
     275    }
     276   
     277    private boolean isNodeTagged(Node n) {
     278        return n.isTagged() || n.isAnnotated();
    275279    }
    276280
Note: See TracChangeset for help on using the changeset viewer.