Changeset 8064 in josm for trunk/src/org
- Timestamp:
- 2015-02-14T18:34:24+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r7668 r8064 177 177 // update selection to reflect which way being modified 178 178 DataSet currentDataSet = getCurrentDataSet(); 179 if ( currentBaseNode!= null && currentDataSet != null && !currentDataSet.getSelected().isEmpty()) {180 Way continueFrom = getWayForNode( currentBaseNode);181 if (alt && continueFrom != null && (! currentBaseNode.isSelected() || continueFrom.isSelected())) {182 addRemoveSelection(currentDataSet, currentBaseNode, continueFrom);179 if (getCurrentBaseNode() != null && currentDataSet != null && !currentDataSet.getSelected().isEmpty()) { 180 Way continueFrom = getWayForNode(getCurrentBaseNode()); 181 if (alt && continueFrom != null && (!getCurrentBaseNode().isSelected() || continueFrom.isSelected())) { 182 addRemoveSelection(currentDataSet, getCurrentBaseNode(), continueFrom); 183 183 needsRepaint = true; 184 184 } else if (!alt && continueFrom != null && !continueFrom.isSelected()) { … … 211 211 // isn't, set wayIsFinished to true to avoid superfluous repaints. 212 212 determineCurrentBaseNodeAndPreviousNode(getCurrentDataSet().getSelected()); 213 wayIsFinished = currentBaseNode== null;213 wayIsFinished = getCurrentBaseNode() == null; 214 214 215 215 toleranceMultiplier = 0.01 * NavigatableComponent.PROP_SNAP_DISTANCE.get(); … … 808 808 } 809 809 810 if ( currentBaseNode == null || currentBaseNode== currentMouseNode)810 if (getCurrentBaseNode() == null || getCurrentBaseNode() == currentMouseNode) 811 811 return; // Don't create zero length way segments. 812 812 813 813 814 double curHdg = Math.toDegrees( currentBaseNode.getEastNorth()814 double curHdg = Math.toDegrees(getCurrentBaseNode().getEastNorth() 815 815 .heading(currentMouseEastNorth)); 816 816 double baseHdg=-1; 817 817 if (previousNode != null) { 818 818 baseHdg = Math.toDegrees(previousNode.getEastNorth() 819 .heading( currentBaseNode.getEastNorth()));819 .heading(getCurrentBaseNode().getEastNorth())); 820 820 } 821 821 … … 938 938 } 939 939 940 /** 941 * Replies the current base node, after having checked it is still usable (see #11105). 942 * @return the current base node (can be null). If not-null, it's guaranteed the node is usable 943 */ 940 944 public Node getCurrentBaseNode() { 945 if (currentBaseNode != null && (currentBaseNode.getDataSet() == null || !currentBaseNode.isUsable())) { 946 currentBaseNode = null; 947 } 941 948 return currentBaseNode; 942 949 } … … 1035 1042 EastNorth p1=ws.getFirstNode().getEastNorth(); 1036 1043 EastNorth p2=ws.getSecondNode().getEastNorth(); 1037 if (snapHelper.dir2!=null && currentBaseNode!=null) { 1038 EastNorth xPoint = Geometry.getSegmentSegmentIntersection(p1, p2, snapHelper.dir2, currentBaseNode.getEastNorth()); 1044 if (snapHelper.dir2 != null && getCurrentBaseNode() != null) { 1045 EastNorth xPoint = Geometry.getSegmentSegmentIntersection(p1, p2, snapHelper.dir2, 1046 getCurrentBaseNode().getEastNorth()); 1039 1047 if (xPoint!=null) { 1040 1048 n.setEastNorth(xPoint); … … 1102 1110 if (Main.map.mapView == null || mousePos == null 1103 1111 // don't draw line if we don't know where from or where to 1104 || currentBaseNode== null || currentMouseEastNorth == null1112 || getCurrentBaseNode() == null || currentMouseEastNorth == null 1105 1113 // don't draw line if mouse is outside window 1106 1114 || !Main.map.mapView.getBounds().contains(mousePos)) … … 1118 1126 return; 1119 1127 GeneralPath b = new GeneralPath(); 1120 Point p1=mv.getPoint( currentBaseNode);1128 Point p1=mv.getPoint(getCurrentBaseNode()); 1121 1129 Point p2=mv.getPoint(currentMouseEastNorth); 1122 1130 … … 1175 1183 * Check whether a connection will be made 1176 1184 */ 1177 if ( currentBaseNode!= null && !wayIsFinished) {1185 if (getCurrentBaseNode() != null && !wayIsFinished) { 1178 1186 if (alt) { 1179 1187 rv.append(" ").append(tr("Start new way from last node.")); … … 1225 1233 DataSet ds = getCurrentDataSet(); 1226 1234 if (ds == null) return null; 1227 if ( currentBaseNode!= null && !ds.getSelected().isEmpty()) {1228 Way continueFrom = getWayForNode( currentBaseNode);1235 if (getCurrentBaseNode() != null && !ds.getSelected().isEmpty()) { 1236 Way continueFrom = getWayForNode(getCurrentBaseNode()); 1229 1237 if (continueFrom != null) 1230 1238 return Collections.<OsmPrimitive>singleton(continueFrom); … … 1364 1372 if (!snapOn || !active) 1365 1373 return; 1366 Point p1=mv.getPoint( currentBaseNode);1374 Point p1=mv.getPoint(getCurrentBaseNode()); 1367 1375 Point p2=mv.getPoint(dir2); 1368 1376 Point p3=mv.getPoint(projected); … … 1423 1431 */ 1424 1432 public void checkAngleSnapping(EastNorth currentEN, double baseHeading, double curHeading) { 1425 EastNorth p0 = currentBaseNode.getEastNorth();1433 EastNorth p0 = getCurrentBaseNode().getEastNorth(); 1426 1434 EastNorth snapPoint = currentEN; 1427 1435 double angle = -1; … … 1473 1481 // find out the distance, in metres, between the base point and projected point 1474 1482 LatLon mouseLatLon = Main.map.mapView.getProjection().eastNorth2latlon(snapPoint); 1475 double distance = currentBaseNode.getCoor().greatCircleDistance(mouseLatLon);1483 double distance = getCurrentBaseNode().getCoor().greatCircleDistance(mouseLatLon); 1476 1484 double hdg = Math.toDegrees(p0.heading(snapPoint)); 1477 1485 // heading of segment from current to calculated point, not to mouse position
Note:
See TracChangeset
for help on using the changeset viewer.