## visad
Class ActionImpl

    java.lang.Object
      visad.ActionImpl

All Implemented Interfaces:
  Action, EventListener, Runnable, ThingChangedListener

Direct Known Subclasses:
  CellImpl, DisplayImpl, FormulaVar

public abstract class ActionImpl
extends Object
implements Action, Runnable

ActionImpl is the abstract superclass for runnable threads that need to be notified when ThingReference objects change.

ActionImpl is the superclass of DisplayImpl and CellImpl.

ActionImpl is not Serializable and should not be copied between JVMs.

Constructor Summary
`ActionImpl(String name)` construct an ActionImpl

Method Summary
`(package private) void` `adaptedAddReference(RemoteThingReference ref, Action action)` does essentially the same thing as addReference(), but is called by the addReference() method of any RemoteActionImpl that adapts this ActionImpl
`(package private) void` `adaptedRemoveReference(RemoteThingReference ref)` does essentially the same thing as removeReference(), but is called by the removeReference() method of any RemoteActionImpl that adapts this ActionImpl
`(package private) void` `addLink(ReferenceActionLink link)` add a link to a ReferenceActionLink (and via it link to a ThingReference)
`void` `addReference(ThingReference ref)` Creates a link to a ThingReference.
`boolean` `checkTicks()`
`void` `disableAction()` disable activity in this ActionImpl and if necessary wait for end of current doAction() call
`abstract void` `doAction()` abstract method that implements activity of this ActionImpl
`void` `enableAction()` enable activity in this ActionImpl and trigger any pending activity
`(package private) ReferenceActionLink` `findLink(long id)` returns a linked ReferenceActionLink with the given id
`ReferenceActionLink` `findReference(ThingReference ref)` Returns the link associated with a ThingReference.
`Thread` `getCurrentActionThread()` return Thread currently active in run() method of this ActionImpl, or null is run() is not active
`(package private) long` `getLinkId()`
`Vector` `getLinks()`
`String` `getName()`
`(package private) void` `handleRunDisconnectException(ReferenceActionLink link)` remove linked ReferenceActionLink
`(package private) void` `notifyAction()` trigger activity in this ActionImpl
`void` `removeAllReferences()` delete all links to ThingReferences
`(package private) void` `removeLinks(ReferenceActionLink[] links)` called by DisplayImpl.removeReference and DisplayImpl.adaptedDisplayRemoveReference to remove links
`void` `removeReference(ThingReference ref)` Removes a link to a ThingReference.
`void` `run()` invoked by a Thread from the ThreadPool whenever there is a request for activity in this ActionImpl
`boolean` `setEnabled(boolean enable)` Set the "enabled" state of this action.
`void` `setName(String name)` change the name of this Action
`static void` `setThreadPoolMaximum(int num)` increase the maximum number of Threads allowed in the ThreadPool
`void` `stop()` stop activity in this ActionImpl
`static void` `stopThreadPool()` destroy all threads after they've drained the job queue
`boolean` `thingChanged(ThingChangedEvent e)` a linked ThingReference has changed, requesting activity in this ActionImpl
`void` `waitForTasks()` wait for all queued tasks in ThreadPool to finish

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ActionImpl

    public ActionImpl(String name)

  construct an ActionImpl

Parameters:
  `name` - - String name, used only for debugging

Method Detail

### stopThreadPool

    public static void stopThreadPool()

  destroy all threads after they've drained the job queue

### setThreadPoolMaximum

    public static void setThreadPoolMaximum(int num)
                                     throws Exception

  increase the maximum number of Threads allowed in the ThreadPool

  Parameters:
    `num` - - new maximum number of Threads in ThreadPool
  Throws:
    `Exception` - - num is less than previous maximum

### stop

    public void stop()

  stop activity in this ActionImpl

### getLinkId

    long getLinkId()

  Returns:
    long value of long counter used to give a unique id to each linked ReferenceActionLink

### checkTicks

    public boolean checkTicks()

  Returns:
    boolean that is disjunction (or) of flags saved in setTicks() calls to each linked ReferenceActionLink

### enableAction

    public void enableAction()

  enable activity in this ActionImpl and trigger any pending activity

### disableAction

    public void disableAction()

  disable activity in this ActionImpl and if necessary wait for end of current doAction() call

### setEnabled

    public boolean setEnabled(boolean enable)

  Set the "enabled" state of this action. This may be used in code like the following to ensure that the action has the same "enabled" state on leaving the code as it did on entering it:

  >      ActionImpl action = ...;
  >      boolean wasEnabled = action.setEnabled(false);
  >      ...
  >      action.setEnabled(wasEnabled);

  Parameters:
    `enable` - The new "enabled" state for this action.
  Returns:
    The previous "enabled" state of this action.

### getCurrentActionThread

    public Thread getCurrentActionThread()

  return Thread currently active in run() method of this ActionImpl, or null is run() is not active

### handleRunDisconnectException

    void handleRunDisconnectException(ReferenceActionLink link)

  remove linked ReferenceActionLink

  Parameters:
    `link` - - linked ReferenceActionLink to remove

### run

    public void run()

  invoked by a Thread from the ThreadPool whenever there is a request for activity in this ActionImpl

  Specified by:
    `run` in interface `Runnable`

### doAction

    public abstract void doAction()
                           throws VisADException,
                                  RemoteException

  abstract method that implements activity of this ActionImpl

  Throws:
    `VisADException` - a VisAD error occurred
    `RemoteException` - an RMI error occurred

### thingChanged

    public boolean thingChanged(ThingChangedEvent e)
                         throws VisADException,
                                RemoteException

  a linked ThingReference has changed, requesting activity in this ActionImpl

  Specified by:
    `thingChanged` in interface `ThingChangedListener`
  Parameters:
    `e` - ThingChangedEvent for change to ThingReference
  Throws:
    `VisADException` - a VisAD error occurred
    `RemoteException` - an RMI error occurred

### addLink

    void addLink(ReferenceActionLink link)
           throws VisADException,
                  RemoteException

  add a link to a ReferenceActionLink (and via it link to a ThingReference)

  Parameters:
    `link` - ReferenceActionLink to link to
  Throws:
    `VisADException` - a VisAD error occurred
    `RemoteException` - an RMI error occurred

### notifyAction

    void notifyAction()

  trigger activity in this ActionImpl

### waitForTasks

    public void waitForTasks()

  wait for all queued tasks in ThreadPool to finish

### addReference

    public void addReference(ThingReference ref)
                      throws ReferenceException,
                             RemoteVisADException,
                             VisADException,
                             RemoteException

  Creates a link to a ThingReference. Note that this method causes this object to register itself with the ThingReference.

  Specified by:
    `addReference` in interface `Action`
  Parameters:
    `ref` - The ThingReference to which to create the link. Subsequent invocation of `thingChanged(ThingChangedEvent)` causes invocation of `ref.acknowledgeThingChanged(this)` . This method invokes `ref.addThingChangedListener(this, ...)`.
  Throws:
    `RemoteVisADException` - if the reference isn't a `ThingReferenceImpl`.
    `ReferenceException` - if the reference has already been added.
    `VisADException` - if a VisAD failure occurs.
    `RemoteException` - if a Java RMI failure occurs.
  See Also:
    `thingChanged(ThingChangedEvent)`, `ThingReference.addThingChangedListener(ThingChangedListener, long)`

### adaptedAddReference

    void adaptedAddReference(RemoteThingReference ref,
                             Action action)
                       throws VisADException,
                              RemoteException

  does essentially the same thing as addReference(), but is called by the addReference() method of any RemoteActionImpl that adapts this ActionImpl

  Parameters:
    `ref` - RemoteThingReference being linked
    `action` - RemoteActionImpl adapting this ActionImpl
  Throws:
    `ReferenceException` - if the reference has already been added.
    `VisADException` - if a VisAD failure occurs.
    `RemoteException` - if a Java RMI failure occurs.

### removeReference

    public void removeReference(ThingReference ref)
                         throws VisADException,
                                RemoteException

  Removes a link to a ThingReference.

  This implementation invokes `findReference(ThingReference)`.

  Specified by:
    `removeReference` in interface `Action`
  Parameters:
    `ref` - The reference to be removed.
  Throws:
    `RemoteVisADException` - if the reference isn't a `ThingReferenceImpl`.
    `ReferenceException` - if the reference isn't a part of this instance.
    `VisADException` - if a VisAD failure occurs.
    `RemoteException` - if a Java RMI failure occurs.

### adaptedRemoveReference

    void adaptedRemoveReference(RemoteThingReference ref)
                          throws VisADException,
                                 RemoteException

  does essentially the same thing as removeReference(), but is called by the removeReference() method of any RemoteActionImpl that adapts this ActionImpl

  Parameters:
    `ref` - RemoteThingReference being removed
  Throws:
    `ReferenceException` - if the reference is not linked.
    `VisADException` - if a VisAD failure occurs.
    `RemoteException` - if a Java RMI failure occurs.

### removeAllReferences

    public void removeAllReferences()
                             throws VisADException,
                                    RemoteException

  delete all links to ThingReferences

  Specified by:
    `removeAllReferences` in interface `Action`
  Throws:
    `VisADException`
    `RemoteException`

### removeLinks

    void removeLinks(ReferenceActionLink[] links)
               throws VisADException,
                      RemoteException

  called by DisplayImpl.removeReference and DisplayImpl.adaptedDisplayRemoveReference to remove links

  Parameters:
    `links` - array of ReferenceActionLinks to remove
  Throws:
    `VisADException` - if a VisAD failure occurs.
    `RemoteException` - if a Java RMI failure occurs.

### findLink

    ReferenceActionLink findLink(long id)
                           throws VisADException

  returns a linked ReferenceActionLink with the given id

  Parameters:
    `id` - value to search for
  Returns:
    linked ReferenceActionLink with given id
  Throws:
    `VisADException` - if a VisAD failure occurs.

### findReference

    public ReferenceActionLink findReference(ThingReference ref)
                                      throws VisADException

  Returns the link associated with a ThingReference.

  Parameters:
    `ref` - The reference to find.
  Returns:
    The link associated with the reference.
  Throws:
    `ReferenceException` - if the argument is `null`.
    `VisADException` - if the argument is `null`.

### getLinks

    public Vector getLinks()

  Returns:
    Vector of linked ReferenceActionLinks

### getName

    public String getName()

  Specified by:
    `getName` in interface `Action`
  Returns:
    String name of this Action

### setName

    public void setName(String name)

  change the name of this Action

  Parameters:
    `name` - new String name