Changeset 32921 in osm for applications/editors/josm
- Timestamp:
- 2016-09-03T22:23:26+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysAlgnSegment.java
r32920 r32921 114 114 */ 115 115 private EastNorth getPivotCoord(PivotLocations pp) { 116 switch (pp) { 117 case NONE: 118 return null; 119 case NODE1: 120 return segment.way.getNode(segment.lowerIndex).getEastNorth(); 121 case NODE2: 122 return segment.way.getNode(segment.lowerIndex + 1).getEastNorth(); 123 case CENTRE: 124 return getPivotCoord(PivotLocations.NODE1).getCenter( 125 getPivotCoord(PivotLocations.NODE2)); 126 default: 127 // Should never happen 116 try { 117 EastNorth n1; 118 EastNorth n2; 119 switch (pp) { 120 case NODE1: 121 return segment.way.getNode(segment.lowerIndex).getEastNorth(); 122 case NODE2: 123 return segment.way.getNode(segment.lowerIndex + 1).getEastNorth(); 124 case CENTRE: 125 n1 = getPivotCoord(PivotLocations.NODE1); 126 n2 = getPivotCoord(PivotLocations.NODE2); 127 return n1 != null && n2 != null ? n1.getCenter(n2) : null; 128 case NONE: 129 default: 130 return null; 131 } 132 } catch (IndexOutOfBoundsException e) { 133 Main.error(e); 128 134 return null; 129 135 } -
applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysSegment.java
r32920 r32921 14 14 import java.util.HashSet; 15 15 16 import org.openstreetmap.josm.Main; 16 17 import org.openstreetmap.josm.data.Bounds; 17 18 import org.openstreetmap.josm.data.osm.Node; … … 54 55 void setSegmentEndpoints(WaySegment segment) { 55 56 if (segment != null) { 56 Node node1 = segment.way.getNode(segment.lowerIndex); 57 Node node2 = segment.way.getNode(segment.lowerIndex + 1); 57 try { 58 Node node1 = segment.way.getNode(segment.lowerIndex); 59 Node node2 = segment.way.getNode(segment.lowerIndex + 1); 58 60 59 segmentEndPoints = new HashSet<>(); 60 segmentEndPoints.add(node1); 61 segmentEndPoints.add(node2); 61 segmentEndPoints = new HashSet<>(); 62 segmentEndPoints.add(node1); 63 segmentEndPoints.add(node2); 64 } catch (IndexOutOfBoundsException e) { 65 Main.error(e); 66 } 62 67 } 63 68 } … … 97 102 98 103 protected void drawSegment(Graphics2D g, MapView mv) { 99 Node n1 = segment.way.getNode(segment.lowerIndex); 100 Node n2 = segment.way.getNode(segment.lowerIndex + 1); 104 try { 105 Node n1 = segment.way.getNode(segment.lowerIndex); 106 Node n2 = segment.way.getNode(segment.lowerIndex + 1); 101 107 102 Line2D newline = new Line2D.Double(mv.getPoint(n1), mv.getPoint(n2)); 103 g.draw(newline); 108 g.draw(new Line2D.Double(mv.getPoint(n1), mv.getPoint(n2))); 109 } catch (IndexOutOfBoundsException e) { 110 Main.error(e); 111 } 104 112 } 105 113
Note:
See TracChangeset
for help on using the changeset viewer.