Пример #1
0
 /**
  * Clears the currentPhoto of the other GeoImageLayer's. Otherwise there could be multiple
  * selected photos.
  */
 private void clearOtherCurrentPhotos() {
   for (GeoImageLayer layer : Main.map.mapView.getLayersOfType(GeoImageLayer.class)) {
     if (layer != this) {
       layer.clearCurrentPhoto(false);
     }
   }
 }
Пример #2
0
  @Override
  public void mergeFrom(Layer from) {
    GeoImageLayer l = (GeoImageLayer) from;

    // Stop to load thumbnails on both layers.  Thumbnail loading will continue the next time
    // the layer is painted.
    stopLoadThumbs();
    l.stopLoadThumbs();

    final ImageEntry selected =
        l.data != null && l.currentPhoto >= 0 ? l.data.get(l.currentPhoto) : null;

    if (l.data != null) {
      data.addAll(l.data);
    }
    Collections.sort(data);

    // Supress the double photos.
    if (data.size() > 1) {
      ImageEntry cur;
      ImageEntry prev = data.get(data.size() - 1);
      for (int i = data.size() - 2; i >= 0; i--) {
        cur = data.get(i);
        if (cur.getFile().equals(prev.getFile())) {
          data.remove(i);
        } else {
          prev = cur;
        }
      }
    }

    if (selected != null && !data.isEmpty()) {
      GuiHelper.runInEDTAndWait(
          new Runnable() {
            @Override
            public void run() {
              for (int i = 0; i < data.size(); i++) {
                if (selected.equals(data.get(i))) {
                  currentPhoto = i;
                  ImageViewerDialog.showImage(GeoImageLayer.this, data.get(i));
                  break;
                }
              }
            }
          });
    }

    setName(l.getName());
    thumbsLoaded &= l.thumbsLoaded;
  }
Пример #3
0
 /**
  * Get a string representation of all layers suitable for the {@code source} changeset tag.
  *
  * @return A String of sources separated by ';'
  */
 public String getLayerInformationForSourceTag() {
   final Collection<String> layerInfo = new ArrayList<>();
   if (!getLayersOfType(GpxLayer.class).isEmpty()) {
     // no i18n for international values
     layerInfo.add("survey");
   }
   for (final GeoImageLayer i : getLayersOfType(GeoImageLayer.class)) {
     layerInfo.add(i.getName());
   }
   for (final ImageryLayer i : getLayersOfType(ImageryLayer.class)) {
     layerInfo.add(
         ImageryInfo.ImageryType.BING.equals(i.getInfo().getImageryType()) ? "Bing" : i.getName());
   }
   return Utils.join("; ", layerInfo);
 }
Пример #4
0
    @Override
    protected void finish() {
      if (!errorMessages.isEmpty()) {
        JOptionPane.showMessageDialog(
            Main.parent, formatErrorMessages(), tr("Error"), JOptionPane.ERROR_MESSAGE);
      }
      if (layer != null) {
        Main.main.addLayer(layer);
        layer.hook_up_mouse_events(); // Main.map.mapView should exist
        // now. Can add mouse listener
        Main.map.mapView.addPropertyChangeListener(layer);
        if (Main.map.getToggleDialog(ImageViewerDialog.class) == null) {
          ImageViewerDialog.newInstance();
          Main.map.addToggleDialog(ImageViewerDialog.getInstance());
        }

        if (!cancelled && layer.data.size() > 0) {
          boolean noGeotagFound = true;
          for (ImageEntry e : layer.data) {
            if (e.getPos() != null) {
              noGeotagFound = false;
            }
          }
          if (noGeotagFound) {
            new CorrelateGpxWithImages(layer).actionPerformed(null);
          }
        }
      }
    }
Пример #5
0
  @Override
  public void mergeFrom(Layer from) {
    GeoImageLayer l = (GeoImageLayer) from;

    ImageEntry selected = null;
    if (l.currentPhoto >= 0) {
      selected = l.data.get(l.currentPhoto);
    }

    data.addAll(l.data);
    Collections.sort(data);

    // Supress the double photos.
    if (data.size() > 1) {
      ImageEntry cur;
      ImageEntry prev = data.get(data.size() - 1);
      for (int i = data.size() - 2; i >= 0; i--) {
        cur = data.get(i);
        if (cur.getFile().equals(prev.getFile())) {
          data.remove(i);
        } else {
          prev = cur;
        }
      }
    }

    if (selected != null) {
      for (int i = 0; i < data.size(); i++) {
        if (data.get(i) == selected) {
          currentPhoto = i;
          ImageViewerDialog.showImage(GeoImageLayer.this, data.get(i));
          break;
        }
      }
    }

    setName(l.getName());
  }