All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class demo.jcsp.ActiveImageAnimator

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----jcsp.awt.ActiveCanvas
                           |
                           +----demo.jcsp.ActiveImageAnimator

public class ActiveImageAnimator
extends ActiveCanvas

Process Diagram

External View

             _______________________
  configure |                       | event
 ------>----|  ActiveImageAnimator  |-->----
            |_______________________|
 

Internal View

             _______________________________________
            |  ___________     ___________________  |
  configure | |           |   |                   | | event
 ------>------| Configure |   | MouseEventHandler |---->----
            | |___________|   |___________________| |
            |                                       |
            |                   ActiveImageAnimator |
            |_______________________________________|
 

Description

The ActiveImageAnimator process provides a Channel interface to controlling an animation of images. The process does not automatically advance the animation it just provides a Channel that can be used to advance the animation.

The process has two CSProcess executing in Parallel, the first is the Configure process that will change the current frame depending on the Object sent down the configure Channel, the second is a MouseEventHandler that will send MouseEvents down the event Channel when the mouse is clicked etc on the component.

Channel Protocols

Input Channels
configure java.lang.Boolean If the booleanValue() of the Object is true the animation will be advanced to the next frame otherwise it will be moved back to the previous frame. If wrap was true when the index hits 0 or images.length-1 the frame index will be adjusted to wrap the animation, otherwise nothing will happen.
java.lang.Integer Sets the index of the current frame to the value of the Integer. The index will be adjusted so it is within 0..images.length-1. If wrap was false the index will be set to 0 if it was less than 0 or images.length-1 if it was greater than images.length-1 otherwise modulo arithmatic will be used to ensure it is in the right range.
Output Channels
event jcsp.awt.event.MouseEvent The MouseEvent that was generated.

Author:
P.D.Austin

Constructor Index

 o ActiveImageAnimator(ChannelInput, ChannelOutput, Image[], int, int)
Construct a new ActiveImageAnimator that will cycle.
 o ActiveImageAnimator(ChannelInput, ChannelOutput, Image[], int, int, boolean)
Construct a new ActiveImageAnimator that will cycle if wrap is true.

Method Index

 o getMinimumSize()
Gets the mininimum size of this component.
 o getPreferredSize()
Gets the preferred size of this component.
 o loadImages(URL, String, String, String, int)
Loads an array of images using the parameters specified.
 o loadImages(URL, String, String, String, int, int)
Loads an array of images using the parameters specified.
 o paint(Graphics)
Called to update the image.

Constructors

 o ActiveImageAnimator
 public ActiveImageAnimator(ChannelInput configure,
                            ChannelOutput event,
                            Image images[],
                            int width,
                            int height)
Construct a new ActiveImageAnimator that will cycle.

Parameters:
configure - the channel used to configure the animation
event - the channel used to notify any mouse events that occur on the component
images - the array of images to be displayed on the animation
width - the initial width of the images
height - the initial height of the images
 o ActiveImageAnimator
 public ActiveImageAnimator(ChannelInput configure,
                            ChannelOutput event,
                            Image images[],
                            int width,
                            int height,
                            boolean wrap)
Construct a new ActiveImageAnimator that will cycle if wrap is true.

Parameters:
configure - the channel used to configure the animation
event - the channel used to notify any mouse events that occur on the component
images - the array of images to be displayed on the animation
width - the initial width of the images
height - the initial height of the images
wrap - if true the animation will wrap

Methods

 o paint
 public void paint(Graphics g)
Called to update the image. Displays the current frame of the Animation.

Parameters:
g - The GraphicsContext to draw the frame onto.
Overrides:
paint in class Canvas
 o getMinimumSize
 public Dimension getMinimumSize()
Gets the mininimum size of this component.

Returns:
A dimension object indicating this component's minimum size.
Overrides:
getMinimumSize in class Component
 o getPreferredSize
 public Dimension getPreferredSize()
Gets the preferred size of this component.

Returns:
A dimension object indicating this component's preferred size.
Overrides:
getPreferredSize in class Component
 o loadImages
 public static Image[] loadImages(URL base,
                                  String path,
                                  String fileName,
                                  String fileExtension,
                                  int numFrames)
Loads an array of images using the parameters specified.

Parameters:
base - The base URL used to find the images
path - The path from the base URL the images are in.
fileName - The fileName prefix of the image files.
fileExtension - The fileExtension of the image files.
numFrames - The number of images.
numPadding - The number of digits for the image number. Wsed to pad the image number with 0's if it is less than this number. If it
 o loadImages
 public static Image[] loadImages(URL base,
                                  String path,
                                  String fileName,
                                  String fileExtension,
                                  int numFrames,
                                  int numPadding)
Loads an array of images using the parameters specified.

Parameters:
base - The base URL used to find the images
path - The path from the base URL the images are in.
fileName - The fileName prefix of the image files.
fileExtension - The fileExtension of the image files.
numFrames - The number of images.
numPadding - The number of digits for the image number. Wsed to pad the image number with 0's if it is less than this number. If it was to image 1 would be padded to 01.

All Packages  Class Hierarchy  This Package  Previous  Next  Index