예제 #1
0
  /**
   * Creates the Control for the associated DisplayScalar. This method invokes the method {@link
   * ScalarMapListener#controlChanged(ScalarMapControlEvent)} on all registered {@link
   * ScalarMapListener}s with this instance as the event source and {@link
   * ScalarMapEvent#CONTROL_ADDED} or {@link ScalarMapEvent#CONTROL_REPLACED} as the event ID --
   * depending on whether this is the first control or not. The event control is the previous
   * control if the event ID is {@link ScalarMapEvent#CONTROL_REPLACED}. If the event ID is {@link
   * ScalarMapEvent#CONTROL_ADDED}, then the event control is the created control or <code>null
   * </code> -- depending on whether or not the control was successfully created.
   *
   * @throws RemoteException Java RMI failure
   * @throws VisADException VisAD failure
   */
  synchronized void setControl() throws VisADException, RemoteException {
    int evtID;
    Control evtCtl;
    if (control != null) {
      evtID = ScalarMapEvent.CONTROL_REPLACED;
      evtCtl = control;
    } else {
      evtID = ScalarMapEvent.CONTROL_ADDED;
      evtCtl = null;
    }

    if (display == null) {
      throw new DisplayException("ScalarMap.setControl: not part of " + "any Display");
    }
    control = display.getDisplayRenderer().makeControl(this);
    if (control != null) {
      display.addControl(control);

      if (evtCtl == null) {
        evtCtl = control;
      }
    }

    if (control != null || evtCtl != null) {
      notifyCtlListeners(new ScalarMapControlEvent(this, evtID, evtCtl));
    }
  }
예제 #2
0
  /**
   * Specify <CODE>DisplayImpl</CODE> to be rendered.
   *
   * @param d <CODE>Display</CODE> to render.
   * @exception VisADException If a <CODE>DisplayImpl</CODE> has already been specified.
   */
  public void setDisplay(DisplayImpl d) throws VisADException {
    if (display != null) {
      throw new DisplayException("DisplayRenderer.setDisplay: " + "display already set");
    }
    display = d;

    // reinitialize rendererControl
    if (rendererControl == null) {
      rendererControl = new RendererControl(display);
      initControl(rendererControl);
    } else {
      RendererControl rc = new RendererControl(display);
      rc.syncControl(rendererControl);
      rendererControl = rc;
    }
    rendererControl.addControlListener(this);
    display.addControl(rendererControl);
  }