* This method prepares data required for painting the "helper line" from
* the last used position to the mouse cursor. It duplicates some code from
* mouseReleased() (FIXME).
*/
private void computeHelperLine() {
MapView mv = Main.map.mapView;
if (mousePos == null) {
// Don't draw the line.
currentMouseEastNorth = null;
currentBaseNode = null;
return;
}
Collection<OsmPrimitive> selection = getCurrentDataSet().getSelected();
Node currentMouseNode = null;
mouseOnExistingNode = null;
mouseOnExistingWays = new HashSet<>();
showStatusInfo(-1, -1, -1, snapHelper.isSnapOn());
if (!ctrl && mousePos != null) {
currentMouseNode = mv.getNearestNode(mousePos, OsmPrimitive.isSelectablePredicate);
}
// We need this for highlighting and we'll only do so if we actually want to re-use
// *and* there is no node nearby (because nodes beat ways when re-using)
if(!ctrl && currentMouseNode == null) {
List<WaySegment> wss = mv.getNearestWaySegments(mousePos, OsmPrimitive.isSelectablePredicate);
for(WaySegment ws : wss) {
mouseOnExistingWays.add(ws.way);
}
}
if (currentMouseNode != null) {
// user clicked on node
if (selection.isEmpty()) return;
currentMouseEastNorth = currentMouseNode.getEastNorth();
mouseOnExistingNode = currentMouseNode;
} else {
// no node found in clicked area
currentMouseEastNorth = mv.getEastNorth(mousePos.x, mousePos.y);
}
determineCurrentBaseNodeAndPreviousNode(selection);
if (previousNode == null) {
snapHelper.noSnapNow();