Changeset 35753 in osm for applications/editors/josm/plugins/alignways/src
- Timestamp:
- 2021-05-17T20:31:51+02:00 (4 years ago)
- Location:
- applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysAlgnSegment.java
r34489 r35753 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.alignways; 3 4 import org.openstreetmap.josm.data.Bounds; 5 import org.openstreetmap.josm.data.coor.EastNorth; 6 import org.openstreetmap.josm.data.osm.IWaySegment; 7 import org.openstreetmap.josm.data.osm.Node; 8 import org.openstreetmap.josm.data.osm.OsmPrimitive; 9 import org.openstreetmap.josm.data.osm.Way; 10 import org.openstreetmap.josm.gui.MainApplication; 11 import org.openstreetmap.josm.gui.MapView; 12 import org.openstreetmap.josm.gui.NavigatableComponent; 13 import org.openstreetmap.josm.tools.Logging; 3 14 4 15 import java.awt.BasicStroke; … … 17 28 import java.util.Map; 18 29 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 29 30 /** 30 31 * @author tilusnet <tilusnet@gmail.com> … … 48 49 private final Color pivotColor = Color.YELLOW; 49 50 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<>(); 51 52 52 53 public AlignWaysAlgnSegment(MapView mapview, Point p) … … 62 63 */ 63 64 @Override 64 public void setSegment( WaySegmentsegment) {65 public void setSegment(IWaySegment<Node, Way> segment) { 65 66 super.setSegment(segment); 66 67 setPivots(); … … 68 69 69 70 @Override 70 void setSegmentEndpoints( WaySegmentsegment) {71 void setSegmentEndpoints(IWaySegment<Node, Way> segment) { 71 72 super.setSegmentEndpoints(segment); 72 73 … … 192 193 * @return The collection of the adjacent waysegments. 193 194 */ 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<>(); 196 197 final double radius = 10.0; 197 198 final int stepsOnCircle = 24; … … 205 206 Point pnew = new Point(); 206 207 pnew.setLocation(x, y); 207 WaySegmentws = MainApplication.getMap().mapView.getNearestWaySegment(pnew, OsmPrimitive::isUsable);208 IWaySegment<Node, Way> ws = MainApplication.getMap().mapView.getNearestWaySegment(pnew, OsmPrimitive::isUsable); 208 209 if (ws != null && !ws.equals(this.segment) && 209 210 (ws.getFirstNode().equals(node) || ws.getSecondNode().equals(node))) { … … 226 227 * @return Collection of the adjacent way segments. 227 228 */ 228 public ArrayList< WaySegment> getAdjacentWaySegments(Node node) {229 public ArrayList<IWaySegment<Node, Way>> getAdjacentWaySegments(Node node) { 229 230 return adjWaySegs.get(node); 230 231 } … … 236 237 // Note: segment should never be null here, and its nodes should never be missing. 237 238 // 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()) { 239 240 Logging.warn("Not drawing AlignWays pivot points: underlying nodes disappeared"); 240 241 return; -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysCmdKeepAngles.java
r34489 r35753 2 2 package org.openstreetmap.josm.plugins.alignways; 3 3 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 11 4 import org.openstreetmap.josm.data.coor.EastNorth; 12 5 import org.openstreetmap.josm.data.osm.DataSet; 6 import org.openstreetmap.josm.data.osm.INode; 7 import org.openstreetmap.josm.data.osm.IWaySegment; 13 8 import org.openstreetmap.josm.data.osm.Node; 14 import org.openstreetmap.josm.data.osm.Way Segment;9 import org.openstreetmap.josm.data.osm.Way; 15 10 import org.openstreetmap.josm.gui.MainApplication; 16 11 import org.openstreetmap.josm.plugins.alignways.geometry.AlignWaysGeomLine; 17 12 import org.openstreetmap.josm.plugins.alignways.geometry.AlignWaysGeomLine.IntersectionStatus; 18 13 import org.openstreetmap.josm.plugins.alignways.geometry.AlignWaysGeomPoint; 14 15 import javax.swing.JOptionPane; 16 import java.util.ArrayList; 17 import java.util.Map; 18 19 import static org.openstreetmap.josm.tools.I18n.tr; 19 20 20 21 /** … … 53 54 } 54 55 55 ArrayList< WaySegment> alws = algnSeg.getAdjacentWaySegments(endpoint);56 ArrayList<IWaySegment<Node, Way>> alws = algnSeg.getAdjacentWaySegments(endpoint); 56 57 int alwsSize = alws.size(); 57 58 if (0 < alwsSize && alwsSize <= 2) { … … 164 165 } 165 166 166 private Node getNonEqualNode(WaySegment waySegment, Nodeendpoint) {167 private <N extends INode> N getNonEqualNode(IWaySegment<N, ?> waySegment, N endpoint) { 167 168 if (waySegment.getFirstNode().equals(endpoint)) { 168 169 return waySegment.getSecondNode(); -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysCmdKeepLength.java
r34489 r35753 16 16 import org.openstreetmap.josm.data.coor.EastNorth; 17 17 import org.openstreetmap.josm.data.osm.DataSet; 18 import org.openstreetmap.josm.data.osm.IWaySegment; 18 19 import org.openstreetmap.josm.data.osm.Node; 19 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 20 import org.openstreetmap.josm.data.osm.Way Segment;21 import org.openstreetmap.josm.data.osm.Way; 21 22 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 22 23 import org.openstreetmap.josm.gui.MainApplication; … … 86 87 MapView mapView = MainApplication.getMap().mapView; 87 88 algnSeg = AlignWaysSegmentMgr.getInstance(mapView).getAlgnSeg(); 88 WaySegmentalgnWS = algnSeg.getSegment();89 WaySegmentrefWS = AlignWaysSegmentMgr.getInstance(mapView).getRefSeg().getSegment();89 IWaySegment<Node, Way> algnWS = algnSeg.getSegment(); 90 IWaySegment<Node, Way> refWS = AlignWaysSegmentMgr.getInstance(mapView).getRefSeg().getSegment(); 90 91 91 92 this.pivot = algnSeg.getCurrPivotCoord(); … … 204 205 public Collection<? extends OsmPrimitive> getParticipatingPrimitives() { 205 206 Collection<OsmPrimitive> prims = new HashSet<>(displaceableNodes); 206 prims.add(algnSeg.getSegment(). way);207 prims.add(algnSeg.getSegment().getWay()); 207 208 return Collections.unmodifiableCollection(prims); 208 209 } -
applications/editors/josm/plugins/alignways/src/org/openstreetmap/josm/plugins/alignways/AlignWaysSegment.java
r34489 r35753 15 15 16 16 import org.openstreetmap.josm.data.Bounds; 17 import org.openstreetmap.josm.data.osm.IWaySegment; 17 18 import org.openstreetmap.josm.data.osm.Node; 18 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 20 import org.openstreetmap.josm.data.osm.Way; 20 import org.openstreetmap.josm.data.osm.WaySegment;21 21 import org.openstreetmap.josm.gui.MapView; 22 22 import org.openstreetmap.josm.gui.layer.MapViewPaintable; … … 29 29 public class AlignWaysSegment implements MapViewPaintable { 30 30 31 protected WaySegmentsegment;31 protected IWaySegment<Node, Way> segment; 32 32 protected MapView mapview; 33 33 protected Color segmentColor = Color.WHITE; … … 45 45 } 46 46 47 void setSegment( WaySegmentsegment) {47 void setSegment(IWaySegment<Node, Way> segment) { 48 48 this.segment = segment; 49 49 if (segment != null) { … … 53 53 } 54 54 55 void setSegmentEndpoints( WaySegmentsegment) {55 void setSegmentEndpoints(IWaySegment<Node, Way> segment) { 56 56 if (segment != null) { 57 57 try { … … 65 65 } 66 66 67 protected WaySegmentgetNearestWaySegment(Point p) {67 protected IWaySegment<Node, Way> getNearestWaySegment(Point p) { 68 68 return mapview.getNearestWaySegment(p, OsmPrimitive::isUsable); 69 69 } … … 75 75 } 76 76 77 public WaySegmentgetSegment() {77 public IWaySegment<Node, Way> getSegment() { 78 78 return segment; 79 79 } … … 87 87 // Note: segment should never be null here, and its nodes should never be missing. 88 88 // 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()) { 90 90 Logging.warn("Not drawing AlignWays highlighting segment: underlying nodes disappeared"); 91 91 return; … … 117 117 return false; 118 118 119 return (primitive instanceof Way && segment. way.equals(primitive)) ||119 return (primitive instanceof Way && segment.getWay().equals(primitive)) || 120 120 (primitive instanceof Node && segmentEndPoints.contains(primitive)); 121 121
Note:
See TracChangeset
for help on using the changeset viewer.