Changeset 13664 in josm


Ignore:
Timestamp:
2018-04-23T21:34:25+02:00 (5 months ago)
Author:
Don-vip
Message:

move a few methods from OsmPrimitive to IPrimitive

Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

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

    r13662 r13664  
    119119
    120120    /**
     121     * Determines if this object is selectable.
     122     * <p>
     123     * A primitive can be selected if all conditions are met:
     124     * <ul>
     125     * <li>it is drawable
     126     * <li>it is not disabled (greyed out) by a filter.
     127     * </ul>
     128     * @return {@code true} if this object is selectable
     129     * @since 13664
     130     */
     131    default boolean isSelectable() {
     132        return true;
     133    }
     134
     135    /**
     136     * Determines if this object is drawable.
     137     * <p>
     138     * A primitive is complete if all conditions are met:
     139     * <ul>
     140     * <li>type and id is known
     141     * <li>tags are known
     142     * <li>it is not deleted
     143     * <li>it is not hidden by a filter
     144     * <li>for nodes: lat/lon are known
     145     * <li>for ways: all nodes are known and complete
     146     * <li>for relations: all members are known and complete
     147     * </ul>
     148     * @return {@code true} if this object is drawable
     149     * @since xxx
     150     */
     151    default boolean isDrawable() {
     152        return true;
     153    }
     154
     155    /**
     156     * Determines whether the primitive is selected
     157     * @return whether the primitive is selected
     158     * @since xxx
     159     */
     160    default boolean isSelected() {
     161        return false;
     162    }
     163
     164    /**
     165     * Determines if this primitive is a member of a selected relation.
     166     * @return {@code true} if this primitive is a member of a selected relation, {@code false} otherwise
     167     * @since xxx
     168     */
     169    default boolean isMemberOfSelected() {
     170        return false;
     171    }
     172
     173    /**
     174     * Determines if this primitive is an outer member of a selected multipolygon relation.
     175     * @return {@code true} if this primitive is an outer member of a selected multipolygon relation, {@code false} otherwise
     176     * @since xxx
     177     */
     178    default boolean isOuterMemberOfSelected() {
     179        return false;
     180    }
     181
     182    /**
    121183     * Replies the id of this primitive.
    122184     *
     
    271333
    272334    /**
     335     * Updates the highlight flag for this primitive.
     336     * @param highlighted The new highlight flag.
     337     * @since 13664
     338     */
     339    void setHighlighted(boolean highlighted);
     340
     341    /**
     342     * Checks if the highlight flag for this primitive was set
     343     * @return The highlight flag.
     344     * @since 13664
     345     */
     346    boolean isHighlighted();
     347
     348    /**
    273349     * Determines if this object is considered "tagged". To be "tagged", an object
    274350     * must have one or more "interesting" tags. "created_by" and "source"
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r13662 r13664  
    480480    }
    481481
    482     /**
    483      * Determines if this object is selectable.
    484      * <p>
    485      * A primitive can be selected if all conditions are met:
    486      * <ul>
    487      * <li>it is drawable
    488      * <li>it is not disabled (greyed out) by a filter.
    489      * </ul>
    490      * @return {@code true} if this object is selectable
    491      */
     482    @Override
    492483    public boolean isSelectable() {
    493484        // not synchronized -> check disabled twice just to be sure we did not have a race condition.
     
    495486    }
    496487
    497     /**
    498      * Determines if this object is drawable.
    499      * <p>
    500      * A primitive is complete if all conditions are met:
    501      * <ul>
    502      * <li>type and id is known
    503      * <li>tags are known
    504      * <li>it is not deleted
    505      * <li>it is not hidden by a filter
    506      * <li>for nodes: lat/lon are known
    507      * <li>for ways: all nodes are known and complete
    508      * <li>for relations: all members are known and complete
    509      * </ul>
    510      * @return {@code true} if this object is drawable
    511      */
     488    @Override
    512489    public boolean isDrawable() {
    513490        return (flags & (FLAG_DELETED + FLAG_INCOMPLETE + FLAG_HIDE_IF_DISABLED)) == 0;
     
    578555    }
    579556
    580     /**
    581      * Determines whether the primitive is selected
    582      * @return whether the primitive is selected
    583      * @see DataSet#isSelected(OsmPrimitive)
    584      */
     557    @Override
    585558    public boolean isSelected() {
    586559        return dataSet != null && dataSet.isSelected(this);
    587560    }
    588561
    589     /**
    590      * Determines if this primitive is a member of a selected relation.
    591      * @return {@code true} if this primitive is a member of a selected relation, {@code false} otherwise
    592      */
     562    @Override
    593563    public boolean isMemberOfSelected() {
    594564        if (referrers == null)
     
    603573    }
    604574
    605     /**
    606      * Determines if this primitive is an outer member of a selected multipolygon relation.
    607      * @return {@code true} if this primitive is an outer member of a selected multipolygon relation, {@code false} otherwise
    608      * @since 7621
    609      */
     575    @Override
    610576    public boolean isOuterMemberOfSelected() {
    611577        if (referrers == null)
     
    632598    }
    633599
    634     /**
    635      * Updates the highlight flag for this primitive.
    636      * @param highlighted The new highlight flag.
    637      */
     600    @Override
    638601    public void setHighlighted(boolean highlighted) {
    639602        if (isHighlighted() != highlighted) {
     
    645608    }
    646609
    647     /**
    648      * Checks if the highlight flag for this primitive was set
    649      * @return The highlight flag.
    650      */
     610    @Override
    651611    public boolean isHighlighted() {
    652612        return (flags & FLAG_HIGHLIGHTED) != 0;
  • trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java

    r13662 r13664  
    154154
    155155    @Override
     156    public void setHighlighted(boolean highlighted) {
     157        // Override if needed
     158    }
     159
     160    @Override
     161    public boolean isHighlighted() {
     162        return false;
     163    }
     164
     165    @Override
    156166    public StyleCache getCachedStyle() {
    157167        return null;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java

    r13633 r13664  
    3333import org.openstreetmap.josm.data.osm.Node;
    3434import org.openstreetmap.josm.data.osm.OsmPrimitive;
     35import org.openstreetmap.josm.data.osm.OsmUtils;
    3536import org.openstreetmap.josm.data.osm.Relation;
    3637import org.openstreetmap.josm.data.osm.Tagged;
     
    641642            matchingRuleIndex = nodeRules;
    642643        } else if (osm instanceof Way) {
    643             if (osm.isKeyFalse("area")) {
     644            if (OsmUtils.isFalse(osm.get("area"))) {
    644645                matchingRuleIndex = wayNoAreaRules;
    645646            } else {
Note: See TracChangeset for help on using the changeset viewer.