Changeset 35753 in osm for applications/editors/josm


Ignore:
Timestamp:
2021-05-17T20:31:51+02:00 (4 years ago)
Author:
taylor.smock
Message:

AlignWays: recompile for compatibility with JOSM r17896

Location:
applications/editors/josm/plugins/alignways
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/alignways/build.xml

    r35746 r35753  
    22<project name="alignways" default="dist" basedir=".">
    33    <!-- enter the SVN commit message -->
    4     <property name="commit.message" value="AlignWays: recompile for compatibility with JOSM r17867"/>
     4    <property name="commit.message" value="AlignWays: recompile for compatibility with JOSM r17896"/>
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    6     <property name="plugin.main.version" value="17867"/>
     6    <property name="plugin.main.version" value="17896"/>
    77
    88    <!-- Configure these properties (replace "..." accordingly).
  • applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysAlgnSegment.java

    r34489 r35753  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.alignways;
     3
     4import org.openstreetmap.josm.data.Bounds;
     5import org.openstreetmap.josm.data.coor.EastNorth;
     6import org.openstreetmap.josm.data.osm.IWaySegment;
     7import org.openstreetmap.josm.data.osm.Node;
     8import org.openstreetmap.josm.data.osm.OsmPrimitive;
     9import org.openstreetmap.josm.data.osm.Way;
     10import org.openstreetmap.josm.gui.MainApplication;
     11import org.openstreetmap.josm.gui.MapView;
     12import org.openstreetmap.josm.gui.NavigatableComponent;
     13import org.openstreetmap.josm.tools.Logging;
    314
    415import java.awt.BasicStroke;
     
    1728import java.util.Map;
    1829
    19 import org.openstreetmap.josm.data.Bounds;
    20 import org.openstreetmap.josm.data.coor.EastNorth;
    21 import org.openstreetmap.josm.data.osm.Node;
    22 import org.openstreetmap.josm.data.osm.OsmPrimitive;
    23 import org.openstreetmap.josm.data.osm.WaySegment;
    24 import org.openstreetmap.josm.gui.MainApplication;
    25 import org.openstreetmap.josm.gui.MapView;
    26 import org.openstreetmap.josm.gui.NavigatableComponent;
    27 import org.openstreetmap.josm.tools.Logging;
    28 
    2930/**
    3031 * @author tilusnet &lt;tilusnet@gmail.com&gt;
     
    4849    private final Color pivotColor = Color.YELLOW;
    4950    private final Color crossColor = pivotColor;
    50     private final Map<Node, ArrayList<WaySegment>> adjWaySegs = new HashMap<>();
     51    private final Map<Node, ArrayList<IWaySegment<Node, Way>>> adjWaySegs = new HashMap<>();
    5152
    5253    public AlignWaysAlgnSegment(MapView mapview, Point p)
     
    6263     */
    6364    @Override
    64     public void setSegment(WaySegment segment) {
     65    public void setSegment(IWaySegment<Node, Way> segment) {
    6566        super.setSegment(segment);
    6667        setPivots();
     
    6869
    6970    @Override
    70     void setSegmentEndpoints(WaySegment segment) {
     71    void setSegmentEndpoints(IWaySegment<Node, Way> segment) {
    7172        super.setSegmentEndpoints(segment);
    7273
     
    192193     * @return The collection of the adjacent waysegments.
    193194     */
    194     private Collection<WaySegment> determineAdjacentWaysegments(Node node) {
    195         Collection<WaySegment> wsSet = new HashSet<>();
     195    private Collection<IWaySegment<Node, Way>> determineAdjacentWaysegments(Node node) {
     196        Collection<IWaySegment<Node, Way>> wsSet = new HashSet<>();
    196197        final double radius = 10.0;
    197198        final int stepsOnCircle = 24;
     
    205206            Point pnew = new Point();
    206207            pnew.setLocation(x, y);
    207             WaySegment ws = MainApplication.getMap().mapView.getNearestWaySegment(pnew, OsmPrimitive::isUsable);
     208            IWaySegment<Node, Way> ws = MainApplication.getMap().mapView.getNearestWaySegment(pnew, OsmPrimitive::isUsable);
    208209            if (ws != null && !ws.equals(this.segment) &&
    209210                    (ws.getFirstNode().equals(node) || ws.getSecondNode().equals(node))) {
     
    226227     * @return Collection of the adjacent way segments.
    227228     */
    228     public ArrayList<WaySegment> getAdjacentWaySegments(Node node) {
     229    public ArrayList<IWaySegment<Node, Way>> getAdjacentWaySegments(Node node) {
    229230        return adjWaySegs.get(node);
    230231    }
     
    236237        // Note: segment should never be null here, and its nodes should never be missing.
    237238        // If they are, it's a bug, possibly related to tracking of DataSet deletions.
    238         if (segment.way.getNodesCount() <= segment.lowerIndex + 1) {
     239        if (segment.getWay().getNodesCount() <= segment.getUpperIndex()) {
    239240            Logging.warn("Not drawing AlignWays pivot points: underlying nodes disappeared");
    240241            return;
  • applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysCmdKeepAngles.java

    r34489 r35753  
    22package org.openstreetmap.josm.plugins.alignways;
    33
    4 import static org.openstreetmap.josm.tools.I18n.tr;
    5 
    6 import java.util.ArrayList;
    7 import java.util.Map;
    8 
    9 import javax.swing.JOptionPane;
    10 
    114import org.openstreetmap.josm.data.coor.EastNorth;
    125import org.openstreetmap.josm.data.osm.DataSet;
     6import org.openstreetmap.josm.data.osm.INode;
     7import org.openstreetmap.josm.data.osm.IWaySegment;
    138import org.openstreetmap.josm.data.osm.Node;
    14 import org.openstreetmap.josm.data.osm.WaySegment;
     9import org.openstreetmap.josm.data.osm.Way;
    1510import org.openstreetmap.josm.gui.MainApplication;
    1611import org.openstreetmap.josm.plugins.alignways.geometry.AlignWaysGeomLine;
    1712import org.openstreetmap.josm.plugins.alignways.geometry.AlignWaysGeomLine.IntersectionStatus;
    1813import org.openstreetmap.josm.plugins.alignways.geometry.AlignWaysGeomPoint;
     14
     15import javax.swing.JOptionPane;
     16import java.util.ArrayList;
     17import java.util.Map;
     18
     19import static org.openstreetmap.josm.tools.I18n.tr;
    1920
    2021/**
     
    5354        }
    5455
    55         ArrayList<WaySegment> alws = algnSeg.getAdjacentWaySegments(endpoint);
     56        ArrayList<IWaySegment<Node, Way>> alws = algnSeg.getAdjacentWaySegments(endpoint);
    5657        int alwsSize = alws.size();
    5758        if (0 < alwsSize && alwsSize <= 2) {
     
    164165    }
    165166
    166     private Node getNonEqualNode(WaySegment waySegment, Node endpoint) {
     167    private <N extends INode> N getNonEqualNode(IWaySegment<N, ?> waySegment, N endpoint) {
    167168        if (waySegment.getFirstNode().equals(endpoint)) {
    168169            return waySegment.getSecondNode();
  • applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysCmdKeepLength.java

    r34489 r35753  
    1616import org.openstreetmap.josm.data.coor.EastNorth;
    1717import org.openstreetmap.josm.data.osm.DataSet;
     18import org.openstreetmap.josm.data.osm.IWaySegment;
    1819import org.openstreetmap.josm.data.osm.Node;
    1920import org.openstreetmap.josm.data.osm.OsmPrimitive;
    20 import org.openstreetmap.josm.data.osm.WaySegment;
     21import org.openstreetmap.josm.data.osm.Way;
    2122import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2223import org.openstreetmap.josm.gui.MainApplication;
     
    8687        MapView mapView = MainApplication.getMap().mapView;
    8788        algnSeg = AlignWaysSegmentMgr.getInstance(mapView).getAlgnSeg();
    88         WaySegment algnWS = algnSeg.getSegment();
    89         WaySegment refWS = AlignWaysSegmentMgr.getInstance(mapView).getRefSeg().getSegment();
     89        IWaySegment<Node, Way> algnWS = algnSeg.getSegment();
     90        IWaySegment<Node, Way> refWS = AlignWaysSegmentMgr.getInstance(mapView).getRefSeg().getSegment();
    9091
    9192        this.pivot = algnSeg.getCurrPivotCoord();
     
    204205    public Collection<? extends OsmPrimitive> getParticipatingPrimitives() {
    205206        Collection<OsmPrimitive> prims = new HashSet<>(displaceableNodes);
    206         prims.add(algnSeg.getSegment().way);
     207        prims.add(algnSeg.getSegment().getWay());
    207208        return Collections.unmodifiableCollection(prims);
    208209    }
  • applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysSegment.java

    r34489 r35753  
    1515
    1616import org.openstreetmap.josm.data.Bounds;
     17import org.openstreetmap.josm.data.osm.IWaySegment;
    1718import org.openstreetmap.josm.data.osm.Node;
    1819import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1920import org.openstreetmap.josm.data.osm.Way;
    20 import org.openstreetmap.josm.data.osm.WaySegment;
    2121import org.openstreetmap.josm.gui.MapView;
    2222import org.openstreetmap.josm.gui.layer.MapViewPaintable;
     
    2929public class AlignWaysSegment implements MapViewPaintable {
    3030
    31     protected WaySegment segment;
     31    protected IWaySegment<Node, Way> segment;
    3232    protected MapView mapview;
    3333    protected Color segmentColor = Color.WHITE;
     
    4545    }
    4646
    47     void setSegment(WaySegment segment) {
     47    void setSegment(IWaySegment<Node, Way> segment) {
    4848        this.segment = segment;
    4949        if (segment != null) {
     
    5353    }
    5454
    55     void setSegmentEndpoints(WaySegment segment) {
     55    void setSegmentEndpoints(IWaySegment<Node, Way> segment) {
    5656        if (segment != null) {
    5757            try {
     
    6565    }
    6666
    67     protected WaySegment getNearestWaySegment(Point p) {
     67    protected IWaySegment<Node, Way> getNearestWaySegment(Point p) {
    6868        return mapview.getNearestWaySegment(p, OsmPrimitive::isUsable);
    6969    }
     
    7575    }
    7676
    77     public WaySegment getSegment() {
     77    public IWaySegment<Node, Way> getSegment() {
    7878        return segment;
    7979    }
     
    8787        // Note: segment should never be null here, and its nodes should never be missing.
    8888        // If they are, it's a bug, possibly related to tracking of DataSet deletions.
    89         if (segment.way.getNodesCount() <= segment.lowerIndex + 1) {
     89        if (segment.getWay().getNodesCount() <= segment.getUpperIndex()) {
    9090            Logging.warn("Not drawing AlignWays highlighting segment: underlying nodes disappeared");
    9191            return;
     
    117117            return false;
    118118
    119         return (primitive instanceof Way && segment.way.equals(primitive)) ||
     119        return (primitive instanceof Way && segment.getWay().equals(primitive)) ||
    120120                (primitive instanceof Node && segmentEndPoints.contains(primitive));
    121121
Note: See TracChangeset for help on using the changeset viewer.