Exemplo n.º 1
0
    /**
     * @param source
     * @param oldScalarMap The previous ScalarMap of the ScalarMapAdapter. May be <code>null</code>.
     * @return The controlling ScalarMapAdapter of the display.
     * @throws RemoteException
     * @throws VisADException
     */
    protected final synchronized ScalarMapAdapter accept(
        ScalarMapAdapter source, ScalarMap oldScalarMap) throws VisADException, RemoteException {

      ScalarMapAdapter adapter;

      if (oldScalarMap != null) {
        adapter = (ScalarMapAdapter) map.get(oldScalarMap);

        if ((adapter != null) && (adapter == source)) {
          map.remove(oldScalarMap);

          changed = true;
        }
      }

      ScalarMap newScalarMap = source.getScalarMap();

      adapter = (ScalarMapAdapter) map.get(newScalarMap);

      if (adapter != null) {
        source.duplicate(adapter);
      } else {
        adapter = source;

        map.put(newScalarMap, source);

        changed = true;
      }

      if (changed) {
        updater.update();
      }

      return adapter;
    }