Esempio n. 1
0
  @Override
  public void activeLayerChange(Layer oldLayer, Layer newLayer) {
    boolean modeChanged = false;
    if (mapMode == null || !mapMode.layerIsSupported(newLayer)) {
      MapMode newMapMode = getLastMapMode(newLayer);
      modeChanged = newMapMode != mapMode;
      if (newMapMode != null) {
        selectMapMode(
            newMapMode,
            newLayer); // it would be nice to select first supported mode when layer is first
                       // selected, but it don't work well with for example editgpx layer
      } else if (mapMode != null) {
        mapMode.exitMode(); // if new mode is null - simply exit from previous mode
      }
    }
    if (!modeChanged && mapMode != null) {
      // Let mapmodes know about new active layer
      mapMode.exitMode();
      mapMode.enterMode();
    }
    // invalidate repaint cache
    Main.map.mapView.preferenceChanged(null);

    // After all listeners notice new layer, some buttons will be disabled/enabled
    // and possibly need to be hidden/shown.
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            validateToolBarsVisibility();
          }
        });
  }
Esempio n. 2
0
  public void selectDrawTool(boolean onlyIfModeless) {
    if (onlyIfModeless && !Main.pref.getBoolean("modeless", false)) return;

    selectMapMode(mapModeDraw);
  }