Changeset 13662 in josm for trunk


Ignore:
Timestamp:
2018-04-23T02:05:41+02:00 (7 years ago)
Author:
Don-vip
Message:

use of IPrimitive interface

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

Legend:

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

    r13636 r13662  
    101101
    102102    /**
     103     * Replies true, if this primitive is disabled. (E.g. a filter applies)
     104     * @return {@code true} if this object has the "disabled" flag enabled
     105     * @since 13662
     106     */
     107    default boolean isDisabled() {
     108        return false;
     109    }
     110
     111    /**
     112     * Replies true, if this primitive is disabled and marked as completely hidden on the map.
     113     * @return {@code true} if this object has both the "disabled" and "hide if disabled" flags enabled
     114     * @since 13662
     115     */
     116    default boolean isDisabledAndHidden() {
     117        return false;
     118    }
     119
     120    /**
    103121     * Replies the id of this primitive.
    104122     *
     
    251269        return getType();
    252270    }
     271
     272    /**
     273     * Determines if this object is considered "tagged". To be "tagged", an object
     274     * must have one or more "interesting" tags. "created_by" and "source"
     275     * are typically considered "uninteresting" and do not make an object "tagged".
     276     * @return true if this object is considered "tagged"
     277     * @since 13662
     278     */
     279    boolean isTagged();
     280
     281    /**
     282     * Determines if this object is considered "annotated". To be "annotated", an object
     283     * must have one or more "work in progress" tags, such as "note" or "fixme".
     284     * @return true if this object is considered "annotated"
     285     * @since 13662
     286     */
     287    boolean isAnnotated();
     288
     289    /**
     290     * true if this object has direction dependent tags (e.g. oneway)
     291     * @return {@code true} if this object has direction dependent tags
     292     * @since 13662
     293     */
     294    boolean hasDirectionKeys();
     295
     296    /**
     297     * true if this object has the "reversed direction" flag enabled
     298     * @return {@code true} if this object has the "reversed direction" flag enabled
     299     * @since 13662
     300     */
     301    boolean reversedDirection();
    253302}
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r13636 r13662  
    445445    }
    446446
    447     /**
    448      * Replies true, if this primitive is disabled. (E.g. a filter applies)
    449      * @return {@code true} if this object has the "disabled" flag enabled
    450      */
     447    @Override
    451448    public boolean isDisabled() {
    452449        return (flags & FLAG_DISABLED) != 0;
    453450    }
    454451
    455     /**
    456      * Replies true, if this primitive is disabled and marked as completely hidden on the map.
    457      * @return {@code true} if this object has both the "disabled" and "hide if disabled" flags enabled
    458      */
     452    @Override
    459453    public boolean isDisabledAndHidden() {
    460454        return ((flags & FLAG_DISABLED) != 0) && ((flags & FLAG_HIDE_IF_DISABLED) != 0);
     
    825819    }
    826820
    827     /**
    828      * Determines if this object is considered "tagged". To be "tagged", an object
    829      * must have one or more "interesting" tags. "created_by" and "source"
    830      * are typically considered "uninteresting" and do not make an object
    831      * "tagged".
    832      * @return true if this object is considered "tagged"
    833      */
     821    @Override
    834822    public boolean isTagged() {
    835823        return (flags & FLAG_TAGGED) != 0;
    836824    }
    837825
    838     /**
    839      * Determines if this object is considered "annotated". To be "annotated", an object
    840      * must have one or more "work in progress" tags, such as "note" or "fixme".
    841      * @return true if this object is considered "annotated"
    842      * @since 5754
    843      */
     826    @Override
    844827    public boolean isAnnotated() {
    845828        return (flags & FLAG_ANNOTATED) != 0;
     
    861844    }
    862845
    863     /**
    864      * true if this object has direction dependent tags (e.g. oneway)
    865      * @return {@code true} if this object has direction dependent tags
    866      */
     846    @Override
    867847    public boolean hasDirectionKeys() {
    868848        return (flags & FLAG_HAS_DIRECTIONS) != 0;
    869849    }
    870850
    871     /**
    872      * true if this object has the "reversed diretion" flag enabled
    873      * @return {@code true} if this object has the "reversed diretion" flag enabled
    874      */
     851    @Override
    875852    public boolean reversedDirection() {
    876853        return (flags & FLAG_DIRECTION_REVERSED) != 0;
  • trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java

    r13636 r13662  
    134134
    135135    @Override
     136    public boolean isTagged() {
     137        return hasKeys();
     138    }
     139
     140    @Override
     141    public boolean isAnnotated() {
     142        return false;
     143    }
     144
     145    @Override
     146    public boolean hasDirectionKeys() {
     147        return false;
     148    }
     149
     150    @Override
     151    public boolean reversedDirection() {
     152        return false;
     153    }
     154
     155    @Override
    136156    public StyleCache getCachedStyle() {
    137157        return null;
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r13657 r13662  
    4747import org.openstreetmap.josm.data.osm.BBox;
    4848import org.openstreetmap.josm.data.osm.DataSet;
     49import org.openstreetmap.josm.data.osm.IPrimitive;
    4950import org.openstreetmap.josm.data.osm.Node;
    5051import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    754755     * @since 11670
    755756     */
    756     public void drawAreaIcon(OsmPrimitive osm, MapImage img, boolean disabled, boolean selected, boolean member, double theta,
     757    public void drawAreaIcon(IPrimitive osm, MapImage img, boolean disabled, boolean selected, boolean member, double theta,
    757758            PositionForAreaStrategy iconPosition) {
    758759        Rectangle2D.Double iconRect = new Rectangle2D.Double(-img.getWidth() / 2.0, -img.getHeight() / 2.0, img.getWidth(), img.getHeight());
     
    10901091     * @since 11722
    10911092     */
    1092     public void drawText(OsmPrimitive osm, TextLabel text, PositionForAreaStrategy labelPositionStrategy) {
     1093    public void drawText(IPrimitive osm, TextLabel text, PositionForAreaStrategy labelPositionStrategy) {
    10931094        if (!isShowNames()) {
    10941095            return;
     
    11261127    }
    11271128
    1128     private void displayText(OsmPrimitive osm, TextLabel text, String name, Rectangle2D nb,
     1129    private void displayText(IPrimitive osm, TextLabel text, String name, Rectangle2D nb,
    11291130            MapViewPositionAndRotation center) {
    11301131        AffineTransform at = new AffineTransform();
     
    11821183     * @param consumer The consumer to call.
    11831184     */
    1184     private void forEachPolygon(OsmPrimitive osm, Consumer<MapViewPath> consumer) {
     1185    private void forEachPolygon(IPrimitive osm, Consumer<MapViewPath> consumer) {
    11851186        if (osm instanceof Way) {
    11861187            consumer.accept(getPath((Way) osm));
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/AreaElement.java

    r13368 r13662  
    77import java.util.Objects;
    88
    9 import org.openstreetmap.josm.data.osm.OsmPrimitive;
     9import org.openstreetmap.josm.data.osm.IPrimitive;
    1010import org.openstreetmap.josm.data.osm.Relation;
    1111import org.openstreetmap.josm.data.osm.Way;
     
    120120
    121121    @Override
    122     public void paintPrimitive(OsmPrimitive osm, MapPaintSettings paintSettings, StyledMapRenderer painter,
     122    public void paintPrimitive(IPrimitive osm, MapPaintSettings paintSettings, StyledMapRenderer painter,
    123123            boolean selected, boolean outermember, boolean member) {
    124124        Color myColor = color;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/AreaIconElement.java

    r12756 r13662  
    44import java.util.Objects;
    55
    6 import org.openstreetmap.josm.data.osm.OsmPrimitive;
     6import org.openstreetmap.josm.data.osm.IPrimitive;
    77import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
    88import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
     
    4343
    4444    @Override
    45     public void paintPrimitive(OsmPrimitive osm, MapPaintSettings paintSettings, StyledMapRenderer painter,
     45    public void paintPrimitive(IPrimitive osm, MapPaintSettings paintSettings, StyledMapRenderer painter,
    4646            boolean selected, boolean outermember, boolean member) {
    4747        if (painter.isShowIcons()) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/BoxTextElement.java

    r12476 r13662  
    77import java.util.Objects;
    88
     9import org.openstreetmap.josm.data.osm.IPrimitive;
    910import org.openstreetmap.josm.data.osm.Node;
    10 import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1111import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
    1212import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
     
    282282
    283283    @Override
    284     public void paintPrimitive(OsmPrimitive osm, MapPaintSettings settings, StyledMapRenderer painter,
     284    public void paintPrimitive(IPrimitive osm, MapPaintSettings settings, StyledMapRenderer painter,
    285285            boolean selected, boolean outermember, boolean member) {
    286286        if (osm instanceof Node) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineElement.java

    r13013 r13662  
    88import java.util.Optional;
    99
     10import org.openstreetmap.josm.data.osm.IPrimitive;
    1011import org.openstreetmap.josm.data.osm.Node;
    11 import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1212import org.openstreetmap.josm.data.osm.Way;
    1313import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
     
    110110
    111111    @Override
    112     public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
     112    public void paintPrimitive(IPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
    113113            boolean selected, boolean outermember, boolean member) {
    114114        /* show direction arrows, if draw.segment.relevant_directions_only is not set,
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java

    r12846 r13662  
    1010import java.util.stream.IntStream;
    1111
     12import org.openstreetmap.josm.data.osm.IPrimitive;
    1213import org.openstreetmap.josm.data.osm.Node;
    13 import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1414import org.openstreetmap.josm.data.osm.Relation;
    1515import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
     
    267267
    268268    @Override
    269     public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings settings, StyledMapRenderer painter,
     269    public void paintPrimitive(IPrimitive primitive, MapPaintSettings settings, StyledMapRenderer painter,
    270270            boolean selected, boolean outermember, boolean member) {
    271271        if (primitive instanceof Node) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/RepeatImageElement.java

    r12303 r13662  
    44import java.util.Objects;
    55
    6 import org.openstreetmap.josm.data.osm.OsmPrimitive;
     6import org.openstreetmap.josm.data.osm.IPrimitive;
    77import org.openstreetmap.josm.data.osm.Way;
    88import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
     
    120120
    121121    @Override
    122     public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
     122    public void paintPrimitive(IPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
    123123            boolean selected, boolean outermember, boolean member) {
    124124        if (primitive instanceof Way) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/StyleElement.java

    r12846 r13662  
    77import java.util.Objects;
    88
     9import org.openstreetmap.josm.data.osm.IPrimitive;
    910import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1011import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
     
    8889     * @param outermember true, if primitive is not selected and outer member of a selected multipolygon relation
    8990     * @param member true, if primitive is not selected and member of a selected relation
    90      */
    91     public abstract void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
     91     * @since 13662 (signature)
     92     */
     93    public abstract void paintPrimitive(IPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
    9294            boolean selected, boolean outermember, boolean member);
    9395
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/TextElement.java

    r12476 r13662  
    44import java.util.Objects;
    55
    6 import org.openstreetmap.josm.data.osm.OsmPrimitive;
     6import org.openstreetmap.josm.data.osm.IPrimitive;
    77import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
    88import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
     
    8888
    8989    @Override
    90     public void paintPrimitive(OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
     90    public void paintPrimitive(IPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
    9191            boolean selected, boolean outermember, boolean member) {
    9292        painter.drawText(primitive, text, getLabelPositionStrategy());
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/TextLabel.java

    r12476 r13662  
    77import java.util.Objects;
    88
     9import org.openstreetmap.josm.data.osm.IPrimitive;
    910import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1011import org.openstreetmap.josm.gui.mappaint.Cascade;
     
    184185     * derived for {@code osm}
    185186     */
    186     public String getString(OsmPrimitive osm) {
     187    public String getString(IPrimitive osm) {
    187188        if (labelCompositionStrategy == null) return null;
    188189        return labelCompositionStrategy.compose(osm);
Note: See TracChangeset for help on using the changeset viewer.