@Override
 public void enterMode() {
   super.enterMode();
   if (!hasImageryLayersToAdjust()) {
     warnNoImageryLayers();
     return;
   }
   List<ImageryLayer> layers = Main.getLayerManager().getLayersOfType(ImageryLayer.class);
   if (layers.size() == 1) {
     adjustingLayer = layers.get(0);
   } else {
     adjustingLayer = (ImageryLayer) askAdjustLayer(getVisibleLayers());
   }
   if (adjustingLayer == null) return;
   if (!adjustingLayer.isVisible()) {
     adjustingLayer.setVisible(true);
   }
   Main.map.mapView.addMouseListener(this);
   Main.map.mapView.addMouseMotionListener(this);
   listener =
       new TimedKeyReleaseListener() {
         @Override
         protected void doKeyReleaseEvent(KeyEvent evt) {
           if (releaseEvent.getKeyCode() == getShortcut().getKeyStroke().getKeyCode()) {
             if (oldMapMode != null && !(oldMapMode instanceof ImageryAdjustMapMode))
               Main.map.selectMapMode(oldMapMode);
           }
         }
       };
 }
Пример #2
0
 @Override
 public Component getExportPanel() {
   final JPanel p = new JPanel(new GridBagLayout());
   export = new JCheckBox();
   export.setSelected(true);
   final JLabel lbl = new JLabel(layer.getName(), layer.getIcon(), SwingConstants.LEFT);
   lbl.setToolTipText(layer.getToolTipText());
   p.add(export, GBC.std());
   p.add(lbl, GBC.std());
   p.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL));
   return p;
 }
Пример #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);
 }
 @Override
 public void mouseDragged(MouseEvent e) {
   if (adjustingLayer == null || prevEastNorth == null) return;
   EastNorth eastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY());
   adjustingLayer.displace(
       eastNorth.east() - prevEastNorth.east(), eastNorth.north() - prevEastNorth.north());
   prevEastNorth = eastNorth;
   Main.map.mapView.repaint();
 }
  @Override
  public void mousePressed(MouseEvent e) {
    if (e.getButton() != MouseEvent.BUTTON1) return;

    requestFocusInMapView();

    if (adjustingLayer.isVisible()) {
      prevEastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY());
      Main.map.mapView.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
    }
  }
Пример #6
0
 @Override
 public Element export(ExportSupport support) throws IOException {
   Element layerElem = support.createElement("layer");
   layerElem.setAttribute("type", "imagery");
   layerElem.setAttribute("version", "0.1");
   ImageryPreferenceEntry e = new ImageryPreferenceEntry(layer.getInfo());
   Map<String, String> data = Preferences.serializeStruct(e, ImageryPreferenceEntry.class);
   for (Map.Entry<String, String> entry : data.entrySet()) {
     Element attrElem = support.createElement(entry.getKey());
     layerElem.appendChild(attrElem);
     attrElem.appendChild(support.createTextNode(entry.getValue()));
   }
   return layerElem;
 }