Changeset 13919 in josm


Ignore:
Timestamp:
2018-06-11T20:52:44+02:00 (5 weeks ago)
Author:
Don-vip
Message:

rendering of IPrimitives

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/OffsetIterator.java

    r12505 r13919  
    77import java.util.stream.Collectors;
    88
    9 import org.openstreetmap.josm.data.osm.Node;
     9import org.openstreetmap.josm.data.osm.INode;
    1010import org.openstreetmap.josm.gui.MapViewState;
    1111import org.openstreetmap.josm.gui.MapViewState.MapViewPoint;
     
    5555     * @param offset The offset of the line.
    5656     */
    57     public OffsetIterator(MapViewState mapState, List<Node> nodes, double offset) {
     57    public OffsetIterator(MapViewState mapState, List<? extends INode> nodes, double offset) {
    5858        this.mapState = mapState;
    59         this.nodes = nodes.stream().filter(Node::isLatLonKnown).map(mapState::getPointFor).collect(Collectors.toList());
     59        this.nodes = nodes.stream().filter(INode::isLatLonKnown).map(mapState::getPointFor).collect(Collectors.toList());
    6060        this.offset = offset;
    6161    }
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r13852 r13919  
    4949import org.openstreetmap.josm.data.osm.IPrimitive;
    5050import org.openstreetmap.josm.data.osm.IRelation;
     51import org.openstreetmap.josm.data.osm.IRelationMember;
    5152import org.openstreetmap.josm.data.osm.IWay;
    5253import org.openstreetmap.josm.data.osm.Node;
     
    5556import org.openstreetmap.josm.data.osm.OsmUtils;
    5657import org.openstreetmap.josm.data.osm.Relation;
    57 import org.openstreetmap.josm.data.osm.RelationMember;
    5858import org.openstreetmap.josm.data.osm.Way;
    5959import org.openstreetmap.josm.data.osm.WaySegment;
     
    526526     * @since 12285
    527527     */
    528     public void drawArea(Way w, Color color, MapImage fillImage, Float extent, Float extentThreshold, boolean disabled) {
     528    public void drawArea(IWay<?> w, Color color, MapImage fillImage, Float extent, Float extentThreshold, boolean disabled) {
    529529        Path2D.Double pfClip = null;
    530530        if (extent != null) {
     
    561561     * @param bs The text and it's alignment.
    562562     */
    563     public void drawBoxText(Node n, BoxTextElement bs) {
     563    public void drawBoxText(INode n, BoxTextElement bs) {
    564564        if (!isShowNames() || bs == null)
    565565            return;
     
    631631     * @param align alignment of the image. The top, center or bottom edge can be aligned with the way.
    632632     */
    633     public void drawRepeatImage(Way way, MapImage pattern, boolean disabled, double offset, double spacing, double phase,
     633    public void drawRepeatImage(IWay<?> way, MapImage pattern, boolean disabled, double offset, double spacing, double phase,
    634634            LineImageAlignment align) {
    635635        final int imgWidth = pattern.getWidth();
     
    730730     * @param theta the angle of rotation in radians
    731731     */
    732     public void drawNodeIcon(Node n, MapImage img, boolean disabled, boolean selected, boolean member, double theta) {
     732    public void drawNodeIcon(INode n, MapImage img, boolean disabled, boolean selected, boolean member, double theta) {
    733733        MapViewPoint p = mapState.getPointFor(n);
    734734
     
    821821     * @param strokeColor The color to use for the outer corner of the symbol
    822822     */
    823     public void drawNodeSymbol(Node n, Symbol s, Color fillColor, Color strokeColor) {
     823    public void drawNodeSymbol(INode n, Symbol s, Color fillColor, Color strokeColor) {
    824824        MapViewPoint p = mapState.getPointFor(n);
    825825
     
    853853     * @param clr The color to use for drawing the text.
    854854     */
    855     public void drawOrderNumber(Node n1, Node n2, int orderNumber, Color clr) {
     855    public void drawOrderNumber(INode n1, INode n2, int orderNumber, Color clr) {
    856856        MapViewPoint p1 = mapState.getPointFor(n1);
    857857        MapViewPoint p2 = mapState.getPointFor(n2);
     
    929929     * @param disabled draw using disabled style
    930930     */
    931     public void drawRestriction(Relation r, MapImage icon, boolean disabled) {
    932         Way fromWay = null;
    933         Way toWay = null;
    934         OsmPrimitive via = null;
     931    public void drawRestriction(IRelation<?> r, MapImage icon, boolean disabled) {
     932        IWay<?> fromWay = null;
     933        IWay<?> toWay = null;
     934        IPrimitive via = null;
    935935
    936936        /* find the "from", "via" and "to" elements */
    937         for (RelationMember m : r.getMembers()) {
     937        for (IRelationMember<?> m : r.getMembers()) {
    938938            if (m.getMember().isIncomplete())
    939939                return;
    940940            else {
    941941                if (m.isWay()) {
    942                     Way w = m.getWay();
     942                    IWay<?> w = (IWay<?>) m.getMember();
    943943                    if (w.getNodesCount() < 2) {
    944944                        continue;
     
    964964                    }
    965965                } else if (m.isNode()) {
    966                     Node n = m.getNode();
     966                    INode n = (INode) m.getMember();
    967967                    if (via == null && "via".equals(m.getRole())) {
    968968                        via = n;
     
    10071007
    10081008        /* find the "direct" nodes before the via node */
    1009         Node fromNode;
     1009        INode fromNode;
    10101010        if (fromWay.firstNode() == via) {
    10111011            fromNode = fromWay.getNode(1);
     
    12271227     * @param onewayReversed for oneway=-1 and similar
    12281228     */
    1229     public void drawWay(Way way, Color color, BasicStroke line, BasicStroke dashes, Color dashedColor, float offset,
     1229    public void drawWay(IWay<?> way, Color color, BasicStroke line, BasicStroke dashes, Color dashedColor, float offset,
    12301230            boolean showOrientation, boolean showHeadArrowOnly,
    12311231            boolean showOneway, boolean onewayReversed) {
     
    12411241        }
    12421242
    1243         List<Node> wayNodes = way.getNodes();
     1243        List<? extends INode> wayNodes = way.getNodes();
    12441244        if (wayNodes.size() < 2) return;
    12451245
     
    14101410    }
    14111411
    1412     private MapViewPath getPath(Way w) {
     1412    private MapViewPath getPath(IWay<?> w) {
    14131413        MapViewPath path = new MapViewPath(mapState);
    14141414        if (w.isClosed()) {
     
    14201420    }
    14211421
    1422     private static Path2D.Double getPFClip(Way w, double extent) {
     1422    private static Path2D.Double getPFClip(IWay<?> w, double extent) {
    14231423        Path2D.Double clip = new Path2D.Double();
    14241424        buildPFClip(clip, w.getNodes(), extent);
     
    14511451     * @param extent the extent
    14521452     */
    1453     private static void buildPFClip(Path2D.Double clip, List<Node> nodes, double extent) {
     1453    private static void buildPFClip(Path2D.Double clip, List<? extends INode> nodes, double extent) {
    14541454        boolean initial = true;
    1455         for (Node n : nodes) {
     1455        for (INode n : nodes) {
    14561456            EastNorth p = n.getEastNorth();
    14571457            if (p != null) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/AreaElement.java

    r13662 r13919  
    88
    99import org.openstreetmap.josm.data.osm.IPrimitive;
     10import org.openstreetmap.josm.data.osm.IWay;
    1011import org.openstreetmap.josm.data.osm.Relation;
    11 import org.openstreetmap.josm.data.osm.Way;
    1212import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
    1313import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
     
    123123            boolean selected, boolean outermember, boolean member) {
    124124        Color myColor = color;
    125         if (osm instanceof Way) {
     125        if (osm instanceof IWay) {
    126126            if (color != null) {
    127127                if (selected) {
     
    131131                }
    132132            }
    133             painter.drawArea((Way) osm, myColor, fillImage, extent, extentThreshold, painter.isInactiveMode() || osm.isDisabled());
     133            painter.drawArea((IWay<?>) osm, myColor, fillImage, extent, extentThreshold, painter.isInactiveMode() || osm.isDisabled());
    134134        } else if (osm instanceof Relation) {
    135135            if (color != null && (selected || outermember)) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/BoxTextElement.java

    r13662 r13919  
    77import java.util.Objects;
    88
     9import org.openstreetmap.josm.data.osm.INode;
    910import org.openstreetmap.josm.data.osm.IPrimitive;
    1011import org.openstreetmap.josm.data.osm.Node;
     
    284285    public void paintPrimitive(IPrimitive osm, MapPaintSettings settings, StyledMapRenderer painter,
    285286            boolean selected, boolean outermember, boolean member) {
    286         if (osm instanceof Node) {
    287             painter.drawBoxText((Node) osm, this);
     287        if (osm instanceof INode) {
     288            painter.drawBoxText((INode) osm, this);
    288289        }
    289290    }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineElement.java

    r13662 r13919  
    88import java.util.Optional;
    99
     10import org.openstreetmap.josm.data.osm.INode;
    1011import org.openstreetmap.josm.data.osm.IPrimitive;
    11 import org.openstreetmap.josm.data.osm.Node;
     12import org.openstreetmap.josm.data.osm.IWay;
    1213import org.openstreetmap.josm.data.osm.Way;
    1314import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
     
    128129        the direction should be shown at all and not only because it's selected */
    129130        boolean showOnlyHeadArrowOnly = showOrientation && !selected && paintSettings.isShowHeadArrowOnly();
    130         Node lastN;
     131        INode lastN;
    131132
    132133        Color myDashedColor = dashesBackground;
     
    155156        }
    156157
    157         if (primitive instanceof Way) {
    158             Way w = (Way) primitive;
     158        if (primitive instanceof IWay) {
     159            IWay<?> w = (IWay<?>) primitive;
    159160            painter.drawWay(w, myColor, myLine, myDashLine, myDashedColor, offset, showOrientation,
    160161                    showOnlyHeadArrowOnly, showOneway, onewayReversed);
     
    164165                int orderNumber = 0;
    165166                lastN = null;
    166                 for (Node n : w.getNodes()) {
     167                for (INode n : w.getNodes()) {
    167168                    if (lastN != null) {
    168169                        orderNumber++;
     
    245246
    246247    /**
    247      * Creates a simple line with default widt.
     248     * Creates a simple line with default width.
    248249     * @param color The color to use
    249250     * @param isAreaEdge If this is an edge for an area. Edges are drawn at lower Z-Index.
     
    259260            c.put(Z_INDEX, -3f);
    260261        }
    261         Way w = new Way();
    262         return createLine(new Environment(w, mc, "default", null));
     262        return createLine(new Environment(new Way(), mc, "default", null));
    263263    }
    264264
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java

    r13662 r13919  
    1010import java.util.stream.IntStream;
    1111
     12import org.openstreetmap.josm.data.osm.INode;
    1213import org.openstreetmap.josm.data.osm.IPrimitive;
    13 import org.openstreetmap.josm.data.osm.Node;
    14 import org.openstreetmap.josm.data.osm.Relation;
     14import org.openstreetmap.josm.data.osm.IRelation;
    1515import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
    1616import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
     
    269269    public void paintPrimitive(IPrimitive primitive, MapPaintSettings settings, StyledMapRenderer painter,
    270270            boolean selected, boolean outermember, boolean member) {
    271         if (primitive instanceof Node) {
    272             Node n = (Node) primitive;
     271        if (primitive instanceof INode) {
     272            INode n = (INode) primitive;
    273273            if (mapImage != null && painter.isShowIcons()) {
    274274                painter.drawNodeIcon(n, mapImage, painter.isInactiveMode() || n.isDisabled(), selected, member,
     
    314314
    315315            }
    316         } else if (primitive instanceof Relation && mapImage != null) {
    317             painter.drawRestriction((Relation) primitive, mapImage, painter.isInactiveMode() || primitive.isDisabled());
     316        } else if (primitive instanceof IRelation && mapImage != null) {
     317            painter.drawRestriction((IRelation<?>) primitive, mapImage, painter.isInactiveMode() || primitive.isDisabled());
    318318        }
    319319    }
    320320
    321321    private void paintWithSymbol(MapPaintSettings settings, StyledMapRenderer painter, boolean selected, boolean member,
    322             Node n) {
     322            INode n) {
    323323        Color fillColor = symbol.fillColor;
    324324        if (fillColor != null) {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/RepeatImageElement.java

    r13662 r13919  
    55
    66import org.openstreetmap.josm.data.osm.IPrimitive;
    7 import org.openstreetmap.josm.data.osm.Way;
     7import org.openstreetmap.josm.data.osm.IWay;
    88import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
    99import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
     
    122122    public void paintPrimitive(IPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter,
    123123            boolean selected, boolean outermember, boolean member) {
    124         if (primitive instanceof Way) {
    125             Way w = (Way) primitive;
     124        if (primitive instanceof IWay) {
     125            IWay<?> w = (IWay<?>) primitive;
    126126            painter.drawRepeatImage(w, pattern, painter.isInactiveMode() || w.isDisabled(), offset, spacing, phase, align);
    127127        }
  • trunk/src/org/openstreetmap/josm/tools/SubclassFilteredCollection.java

    r10691 r13919  
    66import java.util.Iterator;
    77import java.util.NoSuchElementException;
     8import java.util.Objects;
    89import java.util.function.Predicate;
    910
     
    7677     */
    7778    public SubclassFilteredCollection(Collection<? extends S> collection, Predicate<? super S> predicate) {
    78         this.collection = collection;
    79         this.predicate = predicate;
     79        this.collection = Objects.requireNonNull(collection);
     80        this.predicate = Objects.requireNonNull(predicate);
    8081    }
    8182
Note: See TracChangeset for help on using the changeset viewer.