Changeset 5093 in josm
- Timestamp:
- 2012-03-17T11:18:59+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r5075 r5093 268 268 } 269 269 270 private boolean repaintIfRequired(HashSet<OsmPrimitive> newHighlights) { 271 if(!drawTargetHighlight) 272 return false; 273 274 boolean needsRepaint = false; 275 for(OsmPrimitive x : newHighlights) { 276 if(oldHighlights.contains(x)) { 277 continue; 278 } 279 needsRepaint = true; 280 x.setHighlighted(true); 281 } 282 oldHighlights.removeAll(newHighlights); 283 for(OsmPrimitive x : oldHighlights) { 284 x.setHighlighted(false); 285 needsRepaint = true; 286 } 287 oldHighlights = newHighlights; 288 return needsRepaint; 289 } 290 270 291 /** 271 292 * handles adding highlights and updating the cursor for the given mouse event. … … 286 307 */ 287 308 private boolean giveUserFeedback(MouseEvent e, int modifiers) { 288 boolean needsRepaint = false;289 290 309 Collection<OsmPrimitive> c = MapView.asColl( 291 310 mv.getNearestNodeOrWay(e.getPoint(), OsmPrimitive.isSelectablePredicate, true)); … … 294 313 determineMapMode(!c.isEmpty()); 295 314 296 if(drawTargetHighlight) { 297 needsRepaint = removeHighlighting(); 298 } 315 HashSet<OsmPrimitive> newHighlights = new HashSet<OsmPrimitive>(); 299 316 300 317 virtualWays.clear(); … … 302 319 if(mode == Mode.move && setupVirtual(e)) { 303 320 DataSet ds = getCurrentDataSet(); 304 if (ds != null ) {305 if(drawTargetHighlight)ds.setHighlightedVirtualNodes(virtualWays);321 if (ds != null && drawTargetHighlight) { 322 ds.setHighlightedVirtualNodes(virtualWays); 306 323 } 307 324 mv.setNewCursor(SelectActionCursor.virtual_node.cursor(), this); 308 325 // don't highlight anything else if a virtual node will be 309 return drawTargetHighlight; // if no highlighting, repaint is not needed326 return repaintIfRequired(newHighlights); 310 327 } 311 328 … … 314 331 // return early if there can't be any highlights 315 332 if(!drawTargetHighlight || mode != Mode.move || c.isEmpty()) 316 return needsRepaint;333 return repaintIfRequired(newHighlights); 317 334 318 335 // CTRL toggles selection, but if while dragging CTRL means merge … … 323 340 // we are in toggle mode. 324 341 if(isToggleMode || !x.isSelected()) { 325 x.setHighlighted(true); 326 oldHighlights.add(x); 327 } 328 } 329 return needsRepaint || !oldHighlights.isEmpty(); 342 newHighlights.add(x); 343 } 344 } 345 return repaintIfRequired(newHighlights); 330 346 } 331 347
Note:
See TracChangeset
for help on using the changeset viewer.