Exemple #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;
    }
Exemple #2
0
    /**
     * Remove an adapter
     *
     * @param adapter adapter to remove
     */
    public final synchronized void remove(ScalarMapAdapter adapter) {

      adapter.removePropertyChangeListener(adapter.SCALAR_MAP, listener);

      ScalarMap scalarMap = adapter.getScalarMap();
      ScalarMapAdapter source = (ScalarMapAdapter) map.get(scalarMap);

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

        changed = true;

        updater.update();
      }
    }