Example #1
0
  /**
   * Constructs. This is the most general constructor.
   *
   * @param displayAdapter The adapted display.
   * @param dataReference The reference to the datum.
   * @param constantMaps The constant maps for the datum. May be <code>null</code>.
   * @param renderer The renderer for the data. May be <code>null</code>. If non-<code>null</code>,
   *     then must not have been used before.
   * @throws VisADException The DataRenderer is already in-use for other data.
   * @throws RemoteException Java RMI failure.
   */
  public DataAdapter(
      DisplayAdapter displayAdapter,
      DataReference dataReference,
      ConstantMaps constantMaps,
      DataRenderer renderer)
      throws VisADException, RemoteException {

    display = displayAdapter.getDisplay();

    if (renderer != null) {
      if (rendererTable.get(renderer) != null) {
        throw new VisADException(
            getClass().getName() + ".<init>: " + "DataRenderer already in-use for other data");
      }

      rendererTable.put(renderer, this);
    }

    if (constantMaps == null) {
      mapAdapterListener = null;
    } else {
      mapAdapterListener =
          new PropertyChangeListener() {

            public void propertyChange(PropertyChangeEvent event) {

              PropertyChangeEvent newEvent =
                  new PropertyChangeEvent(
                      DataAdapter.this, CONSTANT_MAP, event.getOldValue(), event.getNewValue());

              newEvent.setPropagationId(event.getPropagationId());
              firePropertyChange(newEvent);
            }
          };

      constantMaps.addPropertyChangeListener(constantMaps.CONSTANT_MAP, mapAdapterListener);
    }

    this.dataReference = dataReference;
    this.constantMaps = constantMaps;
    dataRenderer = renderer;

    displayAdapter.add(this);
  }