- Timestamp:
- 2009-08-10T06:02:47+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapView.java
r1918 r1943 20 20 import java.util.Collection; 21 21 import java.util.Collections; 22 import java.util.Comparator; 22 23 import java.util.Enumeration; 23 24 import java.util.LinkedList; … … 259 260 260 261 /** 261 * Moves the layer to the given new position. No event is fired. 262 * Moves the layer to the given new position. No event is fired, but repaints 263 * according to the new Z-Order of the layers. 264 * 262 265 * @param layer The layer to move 263 266 * @param pos The new position of the layer … … 276 279 } 277 280 AudioPlayer.reset(); 281 repaint(); 278 282 } 279 283 … … 284 288 throw new IllegalArgumentException(tr("layer not in list.")); 285 289 return curLayerPos; 290 } 291 292 /** 293 * Creates a list of the visible layers in Z-Order, the layer with the lowest Z-Order 294 * first, layer with the highest Z-Order last. 295 * 296 * @return a list of the visible in Z-Order, the layer with the lowest Z-Order 297 * first, layer with the highest Z-Order last. 298 */ 299 protected List<Layer> getVisibleLayersInZOrder() { 300 ArrayList<Layer> ret = new ArrayList<Layer>(); 301 for (Layer l: layers) { 302 if (l.isVisible()) { 303 ret.add(l); 304 } 305 } 306 // sort according to position in the list of layers, with one exception: 307 // an active data layer always becomes a higher Z-Order than all other 308 // data layers 309 // 310 Collections.sort( 311 ret, 312 new Comparator<Layer>() { 313 public int compare(Layer l1, Layer l2) { 314 if (l1 instanceof OsmDataLayer && l2 instanceof OsmDataLayer) { 315 if (l1 == getActiveLayer()) return -1; 316 if (l2 == getActiveLayer()) return 1; 317 return new Integer(layers.indexOf(l1)).compareTo(layers.indexOf(l2)); 318 } else 319 return new Integer(layers.indexOf(l1)).compareTo(layers.indexOf(l2)); 320 } 321 } 322 ); 323 Collections.reverse(ret); 324 return ret; 286 325 } 287 326 … … 305 344 tempG.fillRect(0, 0, getWidth(), getHeight()); 306 345 307 Layer activeLayer = getActiveLayer(); 308 for (int i = layers.size()-1; i >= 0; --i) { 309 Layer l = layers.get(i); 310 if (l.isVisible() && l != getActiveLayer()) { 311 l.paint(tempG, this); 312 } 313 } 314 if (activeLayer != null && activeLayer.isVisible()) { 315 activeLayer.paint(tempG, this); 316 } 317 346 for (Layer l: getVisibleLayersInZOrder()) { 347 l.paint(tempG, this); 348 } 318 349 for (MapViewPaintable mvp : temporaryLayers) { 319 350 mvp.paint(tempG, this);
Note:
See TracChangeset
for help on using the changeset viewer.