|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.microedition.lcdui.Displayable
javax.microedition.lcdui.Canvas
de.enough.polish.ui.Canvas
de.enough.polish.ui.ScreenChangeAnimation
public abstract class ScreenChangeAnimation
Paints a transition of two screens for a nice effect.
Using a screen change animation is easy:
Use the screen-change-animation CSS attribute for specifying which
animation you would like to have. You can also finetune some animations. Note
that some animations have certain conditions like support of the MIDP 2.0 profile.
screen-change-animation: left; left-screen-change-animation-speed: 5;
You can easily implement your own screen change animations by following these steps:
You can now use your animation by specifying the screen-change-animation CSS attribute
accordingly:
screen-change-animation: new com.company.ui.MyScreenChangeAnimation();
You can also ease the usage by registering your animation in ${polish.home}/custom-css-attributes:
<attribute name="screen-change-animation">
<mapping from="myanimation" to="com.company.ui.MyScreenChangeAnimation()" />
</attribute>
Now your animation is easier to use:
screen-change-animation: myanimation;
Copyright (c) Enough Software 2005 - 2009
history
27-May-2005 - rob creation
onShow(Style, Display, int, int, Displayable, Displayable, boolean),
animate()| Field Summary | |
|---|---|
protected boolean |
abort
|
protected Display |
display
|
protected boolean |
isForwardAnimation
|
protected Image |
lastCanvasImage
|
protected int[] |
lastCanvasRgb
|
protected int |
lastContentX
|
protected int |
lastContentY
|
protected Canvas |
nextCanvas
|
protected Image |
nextCanvasImage
|
protected int[] |
nextCanvasRgb
|
protected int |
nextContentX
|
protected int |
nextContentY
|
protected Displayable |
nextDisplayable
|
protected int |
screenHeight
|
protected int |
screenWidth
|
protected boolean |
supportsDifferentScreenSizes
|
protected boolean |
useLastCanvasRgb
set to true in subclasses for populating lastCanvasRgb |
protected boolean |
useNextCanvasRgb
set to true in subclasses for populating nextCanvasRgb |
| Fields inherited from class de.enough.polish.ui.Canvas |
|---|
_commands, DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, RIGHT, UP |
| Constructor Summary | |
|---|---|
ScreenChangeAnimation()
Creates a new ScreenChangeAnimation. |
|
| Method Summary | |
|---|---|
void |
abort()
Aborts this screen change animation by setting the abort flag which is checked for in the run() method. |
protected abstract boolean |
animate()
Animates this animation. |
void |
hideNotify()
Notifies this animation that it will be hidden shortly. |
void |
keyPressed(int keyCode)
Handles key pressed events. |
void |
keyReleased(int keyCode)
Handles key released events. |
void |
keyRepeated(int keyCode)
Handles key repeat events. |
protected void |
onShow(Style style,
Display dsplay,
int width,
int height,
Displayable lstDisplayable,
Displayable nxtDisplayable,
boolean isForward)
Starts the animation. |
void |
paint(Graphics g)
Renders the Canvas. |
protected abstract void |
paintAnimation(Graphics g)
Paints the animation. |
void |
pointerDragged(int x,
int y)
Forwards pointer dragged events to the next screen. |
void |
pointerPressed(int x,
int y)
Forwards pointer pressed events to the next screen. |
void |
pointerReleased(int x,
int y)
Forwards pointer pressed events to the next screen. |
void |
run()
Runs this animation - subclasses need to ensure to call this.display.callSerially( this ); at the end of the paint method. |
protected void |
setStyle(Style style)
Sets the style for this animation. |
void |
showNotify()
Notifies this animation that it will be shown shortly. |
void |
sizeChanged(int width,
int height)
Notifies this animation that the screen space has been changed. |
protected Image |
toImage(Displayable displayable,
Screen nextScreen,
Screen lastScreen,
int width,
int height)
|
protected void |
updateNextScreen(Canvas next,
Image nextImage,
int[] rgb)
Updates the image and possibly the RGB data of the next screen. |
| Methods inherited from class de.enough.polish.ui.Canvas |
|---|
_hideNotify, _hideNotifyExternal, _showNotify, addCommand, getCommandListener, getCommands, getGameAction, getHeight, getKeyCode, getKeyName, getPolishTicker, getTitle, getWidth, handlePointerTouchDown, handlePointerTouchUp, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, hideNotifyExternal, isDoubleBuffered, isShown, removeCommand, setCommandListener, setFullScreenMode, setTicker, setTitle |
| Methods inherited from class javax.microedition.lcdui.Canvas |
|---|
repaint, repaint, serviceRepaints |
| Methods inherited from class javax.microedition.lcdui.Displayable |
|---|
addCommand, getTicker, removeCommand, setCommandListener, setTicker |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Display display
protected Canvas nextCanvas
protected Image lastCanvasImage
protected int[] lastCanvasRgb
protected boolean useLastCanvasRgb
protected Image nextCanvasImage
protected int[] nextCanvasRgb
protected boolean useNextCanvasRgb
protected int screenWidth
protected int screenHeight
protected Displayable nextDisplayable
protected boolean isForwardAnimation
protected int nextContentX
protected int nextContentY
protected int lastContentX
protected int lastContentY
protected boolean supportsDifferentScreenSizes
protected boolean abort
| Constructor Detail |
|---|
public ScreenChangeAnimation()
| Method Detail |
|---|
protected void onShow(Style style,
Display dsplay,
int width,
int height,
Displayable lstDisplayable,
Displayable nxtDisplayable,
boolean isForward)
style - the associated style.dsplay - the display, which is used for setting this animationwidth - the screen's widthheight - the screen's heightlstDisplayable - the screen that has been shown until nownxtDisplayable - the next screen that should be displayed when this animation finishes (as a Displayable)isForward - true when the animation should run in the normal direction/mode - false if it should run backwards
protected Image toImage(Displayable displayable,
Screen nextScreen,
Screen lastScreen,
int width,
int height)
protected void setStyle(Style style)
style - the styleprotected abstract boolean animate()
protected abstract void paintAnimation(Graphics g)
g - the graphics contextpublic final void paint(Graphics g)
CanvasCanvas. The application must implement
this method in
order to paint any graphics.
The Graphics object's clip region defines the
area of the screen
that is considered to be invalid. A correctly-written
paint() routine
must paint every pixel within this region. This is necessary
because the implementation is not required to clear the region prior to
calling paint() on it. Thus, failing to paint
every pixel may result
in a portion of the previous screen image remaining visible.
Applications must not assume that
they know the underlying source of the paint()
call and use this
assumption
to paint only a subset of the pixels within the clip region. The
reason is
that this particular paint() call may have
resulted from multiple
repaint()
requests, some of which may have been generated from outside the
application. An application that paints only what it thinks is
necessary to
be painted may display incorrectly if the screen contents had been
invalidated by, for example, an incoming telephone call.
Operations on this graphics object after the paint()
call returns are
undefined. Thus, the application must not cache this
Graphics
object for later use or use by another thread. It must only be
used within
the scope of this method.
The implementation may postpone visible effects of graphics operations until the end of the paint method.
The contents of the Canvas are never saved if
it is hidden and then
is made visible again. Thus, shortly after
showNotify() is called,
paint() will always be called with a
Graphics object whose clip region
specifies the entire displayable area of the
Canvas. Applications
must not rely on any contents being preserved from a previous
occasion when the Canvas was current. This call to
paint() will not
necessarily occur before any other key or pointer
methods are called on the Canvas. Applications
whose repaint
recomputation is expensive may create an offscreen
Image, paint into it,
and then draw this image on the Canvas when
paint() is called.
The application code must never call paint();
it is called only by
the implementation.
The Graphics object passed to the
paint() method has the following
properties:
Canvas;Font.getDefaultFont();SOLID;Canvas; andCanvas is visible, that is, a call to
isShown() will return
true.
paint in class Canvasg - - the Graphics object to be used for rendering the Canvas
public void pointerPressed(int x,
int y)
pointerPressed in class Canvasx - the horizontal coordinate of the clicked pixely - the vertical coordinate of the clicked pixelupdateNextScreen(Canvas, Image, int[])
public void pointerReleased(int x,
int y)
pointerReleased in class Canvasx - the horizontal coordinate of the clicked pixely - the vertical coordinate of the clicked pixelupdateNextScreen(Canvas, Image, int[])
public void pointerDragged(int x,
int y)
pointerDragged in class Canvasx - the horizontal coordinate of the clicked pixely - the vertical coordinate of the clicked pixelupdateNextScreen(Canvas, Image, int[])public void showNotify()
showNotify in class Canvaspublic void hideNotify()
hideNotify in class Canvas
public void sizeChanged(int width,
int height)
sizeChanged in interface DisplayablesizeChanged in class Canvaswidth - the widthheight - the heightin class Displayablepublic void keyRepeated(int keyCode)
keyRepeated in class CanvaskeyCode - the code of the keynextCanvasImage,
updateNextScreen(Canvas, Image, int[])public void keyReleased(int keyCode)
keyReleased in class CanvaskeyCode - the code of the keynextCanvasImage,
updateNextScreen(Canvas, Image, int[])public void keyPressed(int keyCode)
keyPressed in class CanvaskeyCode - the code of the keynextCanvasImage,
updateNextScreen(Canvas, Image, int[])
protected void updateNextScreen(Canvas next,
Image nextImage,
int[] rgb)
next - the next screennextImage - the image to which the screen should be paintedrgb - the RGB data, can be nullpublic void abort()
public void run()
run in interface RunnableRunnable.run()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||