/** * 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)); } }
/** * Clear the link to the VisAD display. This will subsequently cause {@link #getDisplay()} and * {@link #getControl()} to return <code>null</code>; consequently, information stored in the * Control might have to be reestablished. This method invokes the method {@link * ScalarMapListener#controlChanged(ScalarMapControlEvent)} on all registered {@link * ScalarMapListener}s with this instance as the event source, {@link * ScalarMapEvent#CONTROL_REMOVED} as the event ID, and the control as the event control. * * @throws RemoteException Java RMI failure * @throws VisADException VisAD failure */ synchronized void nullDisplay() throws RemoteException, VisADException { if (control != null) { control.nullControl(); ScalarMapControlEvent evt; evt = new ScalarMapControlEvent(this, ScalarMapEvent.CONTROL_REMOVED, control); notifyCtlListeners(evt); } control = null; display = null; ScalarIndex = -1; DisplayScalarIndex = -1; scale_flag = back_scale_flag; if (axisScale != null) axisScale.setAxisOrdinal(-1); }