Exemple #1
0
 /**
  * Creates a list of the visible layers in Z-Order, the layer with the lowest Z-Order first, layer
  * with the highest Z-Order last.
  *
  * @return a list of the visible in Z-Order, the layer with the lowest Z-Order first, layer with
  *     the highest Z-Order last.
  */
 public List<Layer> getVisibleLayersInZOrder() {
   layerLock.readLock().lock();
   try {
     List<Layer> ret = new ArrayList<>();
     for (Layer l : layers) {
       if (l.isVisible()) {
         ret.add(l);
       }
     }
     // sort according to position in the list of layers, with one exception:
     // an active data layer always becomes a higher Z-Order than all other data layers
     Collections.sort(
         ret,
         new Comparator<Layer>() {
           @Override
           public int compare(Layer l1, Layer l2) {
             if (l1 instanceof OsmDataLayer && l2 instanceof OsmDataLayer) {
               if (l1 == getActiveLayer()) return -1;
               if (l2 == getActiveLayer()) return 1;
               return Integer.compare(layers.indexOf(l1), layers.indexOf(l2));
             } else return Integer.compare(layers.indexOf(l1), layers.indexOf(l2));
           }
         });
     Collections.reverse(ret);
     return ret;
   } finally {
     layerLock.readLock().unlock();
   }
 }
Exemple #2
0
 @Override
 public void propertyChange(PropertyChangeEvent evt) {
   if (evt.getPropertyName().equals(Layer.VISIBLE_PROP)) {
     repaint();
   } else if (evt.getPropertyName().equals(Layer.OPACITY_PROP)) {
     Layer l = (Layer) evt.getSource();
     if (l.isVisible()) {
       changedLayer = l;
       repaint();
     }
   } else if (evt.getPropertyName().equals(OsmDataLayer.REQUIRES_SAVE_TO_DISK_PROP)
       || evt.getPropertyName().equals(OsmDataLayer.REQUIRES_UPLOAD_TO_SERVER_PROP)) {
     OsmDataLayer layer = (OsmDataLayer) evt.getSource();
     if (layer == getEditLayer()) {
       refreshTitle();
     }
   }
 }