示例#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;
    }
示例#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();
      }
    }
示例#3
0
    /**
     * Accept the adapter
     *
     * @param adapter adapter in question
     * @return the adapter
     * @throws RemoteException Java RMI error
     * @throws VisADException problem creating VisAD object
     */
    public final ScalarMapAdapter accept(ScalarMapAdapter adapter)
        throws VisADException, RemoteException {

      adapter.addPropertyChangeListener(adapter.SCALAR_MAP, listener);

      return accept(adapter, null);
    }