Changeset 12593 in josm for trunk/src/org
- Timestamp:
- 2017-08-11T20:16:39+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r12592 r12593 181 181 * set would have to be checked. 182 182 */ 183 private transient Set<OsmPrimitive> oldHighlights = new HashSet<>();183 private transient Optional<OsmPrimitive> currentHighlight = Optional.empty(); 184 184 185 185 /** … … 257 257 determineMapMode(c.isPresent()); 258 258 259 Set<OsmPrimitive> newHighlights = new HashSet<>();259 Optional<OsmPrimitive> newHighlight = Optional.empty(); 260 260 261 261 virtualManager.clear(); … … 267 267 mv.setNewCursor(SelectActionCursor.virtual_node.cursor(), this); 268 268 // don't highlight anything else if a virtual node will be 269 return repaintIfRequired(newHighlight s);269 return repaintIfRequired(newHighlight); 270 270 } 271 271 … … 274 274 // return early if there can't be any highlights 275 275 if (!drawTargetHighlight || mode != Mode.MOVE || !c.isPresent()) 276 return repaintIfRequired(newHighlight s);276 return repaintIfRequired(newHighlight); 277 277 278 278 // CTRL toggles selection, but if while dragging CTRL means merge … … 282 282 // when clicked. I.e. don't highlight selected elements unless 283 283 // we are in toggle mode. 284 newHighlight s.add(c.get());285 } 286 return repaintIfRequired(newHighlight s);284 newHighlight = c; 285 } 286 return repaintIfRequired(newHighlight); 287 287 } 288 288 … … 354 354 ds.clearHighlightedVirtualNodes(); 355 355 } 356 if ( oldHighlights.isEmpty())356 if (!currentHighlight.isPresent()) { 357 357 return needsRepaint; 358 359 for (OsmPrimitive prim : oldHighlights) { 360 prim.setHighlighted(false); 361 } 362 oldHighlights = new HashSet<>(); 358 } else { 359 currentHighlight.get().setHighlighted(false); 360 } 361 currentHighlight = Optional.empty(); 363 362 return true; 364 363 } 365 364 366 private boolean repaintIfRequired( Set<OsmPrimitive> newHighlights) {367 if (!drawTargetHighlight )365 private boolean repaintIfRequired(Optional<OsmPrimitive> newHighlight) { 366 if (!drawTargetHighlight || currentHighlight.equals(newHighlight)) 368 367 return false; 369 370 boolean needsRepaint = false; 371 for (OsmPrimitive x : newHighlights) { 372 if (oldHighlights.contains(x)) { 373 continue; 374 } 375 needsRepaint = true; 376 x.setHighlighted(true); 377 } 378 oldHighlights.removeAll(newHighlights); 379 for (OsmPrimitive x : oldHighlights) { 380 x.setHighlighted(false); 381 needsRepaint = true; 382 } 383 oldHighlights = newHighlights; 384 return needsRepaint; 368 currentHighlight.ifPresent(osm -> osm.setHighlighted(false)); 369 newHighlight.ifPresent(osm -> osm.setHighlighted(true)); 370 currentHighlight = newHighlight; 371 return true; 385 372 } 386 373 … … 521 508 if (p != null) { 522 509 p.setHighlighted(true); 523 oldHighlights.add(p);510 currentHighlight = Optional.of(p); 524 511 needsRepaint = true; 525 512 }
Note:
See TracChangeset
for help on using the changeset viewer.