| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.nokia.mid.ui.frameanimator.FrameAnimator
public class FrameAnimator
A FrameAnimator is a class that can be used to create linear or decelerated
 animations. A common use for it is to realize scrolling in UI-components. An
 application can create an instance of FrameAnimator,
 activate it by specifying a FrameAnimatorListener, and then trigger an
 animation by feeding movement-data (coordinates or a direction and speed) into it. 
 Subsequently, the platform will ensure that
 FrameAnimatorListener.animate(FrameAnimator animator, int x, int y, short delta, short delta, short deltaY, boolean lastFrame)
 is called (possibly repeatedly) to describe the resulting animation.
 
 An animation is described by the FrameAnimator via a single coordinate A
 (x,y). An application that uses the FrameAnimator has to specify an
 initial value for A in
 register(int x, int y, short maxFps, short maxPps, FrameAnimatorListener listener). 
 Then, after the application has triggered an animation via
 drag(int x, int y) or
 kineticScroll(int startSpeed, int direction, int friction, float angle), A is updated by
 the platform and fed back to the application in
 FrameAnimatorListener.animate(FrameAnimator animator, int x, int y, short delta, short delta, short deltaY, boolean lastFrame)
 An ongoing animation can be interrupted at any time by the application by
 calling stop().
 
The properties of animations can be controlled in the following ways:
FrameAnimatorListener.animate(FrameAnimator animator, int x, int y, short delta, short delta, short deltaY, boolean lastFrame)
 is being called during an animation, by specifying the number of frames per
 second via maxFps in register(int x, int y, short maxFps, short maxPps, FrameAnimatorListener listener)
 kineticScroll(int startSpeed, int direction, int friction, float angle). Additionally, it is possible to specify
 an upper limit for this delta with the maxPps parameter in
 register(int x, int y, short maxFps, short maxPps, FrameAnimatorListener listener).
 
 The number of FrameAnimators that can be active at a time is limited to
 FRAME_ANIMATOR_MAX_CONCURRENT. If an
 application tries to register a FrameAnimator while the maximum number of
 concurrent FrameAnimators has been reached, register(int x, int y, short maxFps, short maxPps, FrameAnimatorListener listener)
 will return false. The application must then first call
 unregister() on one of its other active FrameAnimators.
 An application can query the number of its currently registered FrameAnimators with
 getNumRegisteredFrameAnimators()
| Field Summary | |
|---|---|
| protected  int | actionID | 
| protected  int | actionType | 
| static int | FRAME_ANIMATOR_FREE_ANGLEConstant to describe movement in any given direction | 
| static int | FRAME_ANIMATOR_FRICTION_HIGHConstant to describe high friction | 
| static int | FRAME_ANIMATOR_FRICTION_LOWConstant to describe low friction | 
| static int | FRAME_ANIMATOR_FRICTION_MEDIUMConstant to describe medium friction | 
| static int | FRAME_ANIMATOR_HORIZONTALConstant to describe horizontal movement | 
| static int | FRAME_ANIMATOR_MAX_CONCURRENTConstant that specifies that maximum number of FrameAnimators that can be registered concurrently | 
| static int | FRAME_ANIMATOR_VERTICALConstant to describe vertical movement | 
| Constructor Summary | |
|---|---|
| FrameAnimator()Creates a new FrameAnimator-instance | |
| Method Summary | |
|---|---|
|  void | drag(int x,
     int y)Method to issue a linear drag-movement. | 
| static int | getNumRegisteredFrameAnimators()Gets the number of currently registered FrameAnimators | 
|  boolean | isRegistered()Returns whether this FrameAniamtor is currently registered | 
|  void | kineticScroll(int speed,
              int direction,
              int friction,
              float angle)Initiates a step-by-step kinetic animation, moving A from the current (x,y) coordinate to a new position, which is described by a direction, speed and friction, according to the frame rate and max-pixels-per-second specified by the MIDlet in the register(int x, int y, short maxFps, short maxPps, FrameAnimatorListener listener)method. | 
|  void | limitedKineticScroll(int speed,
                     int direction,
                     int friction,
                     float angle,
                     int limitUp,
                     int limitDown) | 
|  boolean | register(int x,
         int y,
         short maxFps,
         short maxPps,
         FrameAnimatorListener listener)Registers this FrameAnimator as active. | 
|  void | stop()Aborts an ongoing movement. | 
|  void | unregister()Deactivates this FrameAnimator immediately. | 
| Methods inherited from class java.lang.Object | 
|---|
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final int FRAME_ANIMATOR_MAX_CONCURRENT
public static final int FRAME_ANIMATOR_VERTICAL
public static final int FRAME_ANIMATOR_HORIZONTAL
public static final int FRAME_ANIMATOR_FREE_ANGLE
public static final int FRAME_ANIMATOR_FRICTION_LOW
public static final int FRAME_ANIMATOR_FRICTION_MEDIUM
public static final int FRAME_ANIMATOR_FRICTION_HIGH
protected int actionType
protected int actionID
| Constructor Detail | 
|---|
public FrameAnimator()
| Method Detail | 
|---|
public boolean register(int x,
                        int y,
                        short maxFps,
                        short maxPps,
                        FrameAnimatorListener listener)
drag(int x, int y),
 kineticScroll(int startSpeed, int direction, int friction, float angle) and 
 stop() methods.
x - The initial x-valuey - The initial y-valuemaxFps - Percentage value, which is used to calculate the final max-frames-per-
            second value. This final value determines an upper limit
            for how often FrameAnimatorListener.animate(FrameAnimator animator, int x, int y, short delta, short delta, short deltaY, boolean lastFrame) 
            will be called per second. However the actual frame rate can be lower, depending
            on the performance of platform. 
            If set to 0, then the default-value will be used. Possible values: 1-200.maxPps - Percentage value, which is used to calculate the final maximum
            pixels per second value. If set to 0, then the default-value
            will be used. Possible values: 1-200listener - The FrameAnimatorListener to be notified as the animation progresses.
            It is possible to register the same listener with more than one FrameAnimator.
java.lang.IllegalStateException - if this FrameAnimator has already been registered.
java.lang.NullPointerException - if listener is null
java.lang.IllegalArgumentException - if coordinate is out of bounds (Less than -65535
            or greater than 65535)public void unregister()
drag(int x, int y) or
 kineticScroll(int startSpeed, int direction, int friction, float angle) methods until the FrameAnimator
 is registered again.
java.lang.IllegalStateException - if this FrameAnimator has not been registered
public void drag(int x,
                 int y)
FrameAnimatorListener.animate(FrameAnimator animator, int x, int y, short delta, short delta, short deltaY, boolean lastFrame)
 method to be called one or more times to describe the movement as it
 happens. The platform guarantees that those calls occur within the specified
 frame rate. If this method is called repeatedly, some intermediate drags might be
 skipped, so the last call may be fed back to FrameAnimatorListener.animate(FrameAnimator animator, int x, int y, short delta, short delta, short deltaY, boolean lastFrame).
x - The new x-coordinatey - The new y-coordinate
java.lang.IllegalStateException - if this FrameAnimator has not been registered
java.lang.IllegalArgumentException - if coordinate is out of bounds (Less than -65535
            or greater than 65535)
public void kineticScroll(int speed,
                          int direction,
                          int friction,
                          float angle)
register(int x, int y, short maxFps, short maxPps, FrameAnimatorListener listener) method. FRAME_ANIMATOR_HORIZONTAL or FRAME_ANIMATOR_VERTICAL
 are passed as direction. In this case, the value of angle will be ignored. If
 direction is set to FRAME_ANIMATOR_FREE_ANGLE, angle has to
 describe the direction of the interpolated animation in radians:
 
x = 0, y = 0 ->+------------------------ positive x
               |
               |        direction_angle_radians
               |        =======================
               |
               |                -pi/2
               |                  |
               |                  |
               |   pi or -pi -----+----- 0
               |                  |
               |                  |
               |                 pi/2
               |
           positive y
           
 Calling this method will cause FrameAnimatorListener.animate(FrameAnimator animator, int x, int y, short delta, short delta, short deltaY, boolean lastFrame)          
 to be called repeatedly until the interpolation completes, with each successive call 
 updating the (x,y) position in a kinetic fashion according to the speed and deceleration 
 specified by the MIDlet.stop() before
 kineticScroll(int startSpeed, int direction, int friction, float angle).
startSpeed - Initial speed of movement in pixels/second, before any deceleration
            is applied.direction - Direction of movement. Must be either
            FRAME_ANIMATOR_HORIZONTAL,
            FRAME_ANIMATOR_VERTICAL or
            FRAME_ANIMATOR_FREE_ANGLEfriction - Friction-value which affects the deceleration. Must be one of
            FRAME_ANIMATOR_FRICTION_LOW,
            FRAME_ANIMATOR_FRICTION_MEDIUM or
            FRAME_ANIMATOR_FRICTION_HIGHangle - Angle of direction in radians
java.lang.IllegalStateException - if this FrameAnimator has not been registered
public void limitedKineticScroll(int speed,
                                 int direction,
                                 int friction,
                                 float angle,
                                 int limitUp,
                                 int limitDown)
public void stop()
FrameAnimatorListener.animate(FrameAnimator animator, int x, int y, short delta, short delta, short deltaY, boolean lastFrame)
 method will occur after this method returns, until a new movement is
 triggered via drag(int x, int y) or
 kineticScroll(int startSpeed, int direction, int friction, float angle)
java.lang.IllegalStateException - if this FrameAnimator has not been registeredpublic boolean isRegistered()
public static int getNumRegisteredFrameAnimators()
| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||