All Packages  Class Hierarchy  This Package  Previous  Next  Index
  Class jcsp.awt.ActiveApplet
java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |
                                   +----jcsp.awt.ActiveApplet
  -  public abstract class ActiveApplet
  -  extends Applet
  -  implements CSProcess
Process Diagram
 
  ________________
 |                |
 |  ActiveApplet  |
 |________________|
 
 Description
 The ActiveApplet is a sub class of Applet which controls a ProcessNetwork of
 CSProcess's. A ProcessNetwork is created to execute the run() method of the
 ActiveApplet, this enables the ActiveApplet to suspend the CSProcess's created
 by the sub classes when the stop() method is invoked, resume them when start() is
 invoked and stop them when stop() is invoked.
 
 NOTE: Unlike most other CSProcess's the ActiveApplet uses a ProcessNetwork
 to execute the run() method asynchronously, therefore the ActiveApplet does not
 need to be part of a Parallel construct.
 
 A Parallel construct is constructed as a protected variable which is used to
 execute the CSProcess's defined by this class and by sub classes in parallel.
 The run method of this class simply sets the Parallel construct running and will
 not complete unless all the CSProcess's terminate. Applets sub classing this
 class should call par.addProcess() to add any CSProcess's they which to be executed.
 
 It is possible to register Channels to be used to notify the
 occurrence of other types of Event that the Applet generates. This can
 be done by calling one of the addXXXXEventChannel() methods.
 
 When creating a new ActiveApplet the init() method should be overridden to define
 the components to be displayed and the CSProcess's to be executed. 
 Finally the ProcessNetwork must be started using network.start().
 
 NOTE: If network.start() is called before further calls to par.addProcess()
 the CSProcess's added after will not be executed.
 
 Channel Protocols
 
   
     | Input Channels | 
   
     |  |  |  | 
   
     | Output Channels | 
   
     |  |  |  | 
 
 Example
 
 import jcsp.lang.*;
 import jcsp.awt.*;
 public class AppletExample extends ActiveApplet {
   public void init() {
     setLayout(new FlowLayout());
     final Channel event = new One2OneChannel();
     final Channel label = new One2OneChannel();
     ActiveButton b = new ActiveButton(event, "Click Me");
     add(b);
     ActiveLabel l = new ActiveLabel(label)
     add(l);
     par.addProcess(new CSProcess[] {
       b,
       l,
       new CSProcess() {
         public void run() {
           int clickCount = 0;
           while (true) {
             event.read();
             label.write("Clicked " + clickCount " times");
           }
         }
       }
     });
     network.start(); // Must be called to start the processes running
   }
 }
 
  -  Author:
  
-  P.D.Austin
   
  -   network network
-   The ProcessNetwork used to control the execution of this CSProcess.
  
-   par par
-   The Parallel construct containing the processes to be executed by this CSProcess.
   
  -   ActiveApplet() ActiveApplet()
-   Called when the Applet is first initialised, this method will create a
 new ProcessNetwork to run this process in.
   
  -   addComponentEventChannel(ChannelOutput) addComponentEventChannel(ChannelOutput)
-   Add a new Channel to the Component which will be used to notify that
 a ComponentEvent has occurred on the component.
  
-   addContainerEventChannel(ChannelOutput) addContainerEventChannel(ChannelOutput)
-   Add a new Channel to the Container which will be used to notify that
 a ContainerEvent has occurred on the Container.
  
-   addFocusEventChannel(ChannelOutput) addFocusEventChannel(ChannelOutput)
-   Add a new Channel to the Component which will be used to notify that
 a FocusEvent has occurred on the component.
  
-   addKeyEventChannel(ChannelOutput) addKeyEventChannel(ChannelOutput)
-   Add a new Channel to the Component which will be used to notify that
 a KeyEvent has occurred on the component.
  
-   addMouseEventChannel(ChannelOutput) addMouseEventChannel(ChannelOutput)
-   Add a new Channel to the Component which will be used to notify that
 a MouseEvent has occurred on the component.
  
-   addMouseMotionEventChannel(ChannelOutput) addMouseMotionEventChannel(ChannelOutput)
-   Add a new Channel to the Component which will be used to notify that
 a MouseMotionEvent has occurred on the component.
  
-   destroy() destroy()
-   Called when the Applet needs to be destroyed.
  
-   run() run()
-   The main body of this process.
  
-   start() start()
-   Called when the Applet is made visible.
  
-   stop() stop()
-   Called when the Applet is made not visible.
   
 par
par
 protected Parallel par
  -  The Parallel construct containing the processes to be executed by this CSProcess.
 
 network
network
 protected ProcessNetwork network
  -  The ProcessNetwork used to control the execution of this CSProcess.
 
   
 ActiveApplet
ActiveApplet
 public ActiveApplet()
  -  Called when the Applet is first initialised, this method will create a
 new ProcessNetwork to run this process in. This method will wait to be notified by the run()
 process. Sub classes should not override this method and must call
 notify in the run() method when the process network has been created, but
 before the infinite loop is created.
 
 NOTE: If subclasses override this method they must call super.init().
 
 
   
 destroy
destroy
 public void destroy()
  -  Called when the Applet needs to be destroyed. This method will stop the
 ProcessNetwork causing all the CSProcess's to stop.
 
 NOTE: If subclasses override this method they must call super.destory().
 
   
- 
    -  Overrides:
    
-  destroy in class Applet
  
 
 start
start
 public void start()
  -  Called when the Applet is made visible. This method will resume the
 ProcessNetwork causing all the CSProcess's to resume execution.
 
 NOTE: If subclasses override this method they must call super.start().
 
   
- 
    -  Overrides:
    
-  start in class Applet
  
 
 stop
stop
 public void stop()
  -  Called when the Applet is made not visible. This method will suspend the
 ProcessNetwork causing all the CSProcess's to suspend execution.
 
 NOTE: If subclasses override this method they must call super.stop().
 
   
- 
    -  Overrides:
    
-  stop in class Applet
  
 
 addContainerEventChannel
addContainerEventChannel
 public void addContainerEventChannel(ChannelOutput containerEvent)
  -  Add a new Channel to the Container which will be used to notify that
 a ContainerEvent has occurred on the Container. This should be used
 instead of registering a ContainerListener with the Container. It is
 possible to add more than one Channel by calling this method multiple times
 If the reference passed is null no action will be taken. Otherwise
 a new ContainerEventHanlder will be generated for the Channel so that
 each Channel operates independently of the others.
 
 NOTE: This method must be called before this process is run otherwise
 it will not function correctly.
 
   
- 
    -  Parameters:
    
-  containerEvent - The channel to send Container events down. If the Channel
 is to be shared with other events it should be a Many2OneChannel.
    
-  See Also:
    
-  ContainerEventHandler
  
 
 addComponentEventChannel
addComponentEventChannel
 public void addComponentEventChannel(ChannelOutput componentEvent)
  -  Add a new Channel to the Component which will be used to notify that
 a ComponentEvent has occurred on the component. This should be used
 instead of registering a ComponentListener with the component. It is
 possible to add more than one Channel by calling this method multiple times
 If the reference passed is null no action will be taken. Otherwise
 a new ComponentEventHanlder will be generated for the Channel so that
 each Channel operates independently of the others.
 
 NOTE: This method must be called before this process is run otherwise
 it will not function correctly.
 
   
- 
    -  Parameters:
    
-  componentEvent - The channel to send component events down. If the Channel
 is to be shared with other events it should be a Many2OneChannel.
    
-  See Also:
    
-  ComponentEventHandler
  
 
 addFocusEventChannel
addFocusEventChannel
 public void addFocusEventChannel(ChannelOutput focusEvent)
  -  Add a new Channel to the Component which will be used to notify that
 a FocusEvent has occurred on the component. This should be used
 instead of registering a FocusListener with the component. It is
 possible to add more than one Channel by calling this method multiple times
 If the reference passed is null no action will be taken. Otherwise
 a new FocusEventHanlder will be generated for the Channel so that
 each Channel operates independently of the others.
 
 NOTE: This method must be called before this process is run otherwise
 it will not function correctly.
 
   
- 
    -  Parameters:
    
-  focusEvent - The channel to send focus events down. If the Channel
 is to be shared with other events it should be a Many2OneChannel.
    
-  See Also:
    
-  FocusEventHandler
  
 
 addKeyEventChannel
addKeyEventChannel
 public void addKeyEventChannel(ChannelOutput keyEvent)
  -  Add a new Channel to the Component which will be used to notify that
 a KeyEvent has occurred on the component. This should be used
 instead of registering a KeyListener with the component. It is
 possible to add more than one Channel by calling this method multiple times
 If the reference passed is null no action will be taken. Otherwise
 a new KeyEventHanlder will be generated for the Channel so that
 each Channel operates independently of the others.
 
 NOTE: This method must be called before this process is run otherwise
 it will not function correctly.
 
   
- 
    -  Parameters:
    
-  keyEvent - The channel to send key events down. If the Channel
 is to be shared with other events it should be a Many2OneChannel.
    
-  See Also:
    
-  KeyEventHandler
  
 
 addMouseEventChannel
addMouseEventChannel
 public void addMouseEventChannel(ChannelOutput mouseEvent)
  -  Add a new Channel to the Component which will be used to notify that
 a MouseEvent has occurred on the component. This should be used
 instead of registering a MouseListener with the component. It is
 possible to add more than one Channel by calling this method multiple times
 If the reference passed is null no action will be taken. Otherwise
 a new MouseEventHanlder will be generated for the Channel so that
 each Channel operates independently of the others.
 
 NOTE: This method must be called before this process is run otherwise
 it will not function correctly.
 
   
- 
    -  Parameters:
    
-  mouseEvent - The channel to send key events down. If the Channel
 is to be shared with other events it should be a Many2OneChannel.
    
-  See Also:
    
-  MouseEventHandler
  
 
 addMouseMotionEventChannel
addMouseMotionEventChannel
 public void addMouseMotionEventChannel(ChannelOutput mouseMotionEvent)
  -  Add a new Channel to the Component which will be used to notify that
 a MouseMotionEvent has occurred on the component. This should be used
 instead of registering a MouseMotionListener with the component. It is
 possible to add more than one Channel by calling this method multiple times
 If the reference passed is null no action will be taken. Otherwise
 a new MouseMotionEventHanlder will be generated for the Channel so that
 each Channel operates independently of the others.
 
 NOTE: This method must be called before this process is run otherwise
 it will not function correctly.
 
   
- 
    -  Parameters:
    
-  mouseMotionEvent - The channel to send key events down. If the Channel
 is to be shared with other events it should be a Many2OneChannel.
    
-  See Also:
    
-  MouseMotionEventHandler
  
 
 run
run
 public void run()
  -  The main body of this process.
 
 NOTE: This method should not be overridden, if extra functionality is required
 add an extra process to the par object.
 
 
All Packages  Class Hierarchy  This Package  Previous  Next  Index