|
||||||||||
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
mome.keyb.XCanvas
public class XCanvas
A Canvas
subclass that translates key events
to commands and issues them to commands execution thread and implements
double buffering.
KeyProcessor
to map key (game action) or sequence
of keys and/or game actions to command. KeyProcessor
can be
set and returned by setKeyProcessor(KeyProcessor)
,
getKeyProcessor()
methods respectively. It also uses
Executor
to issue found command to the commands execution
thread. Executor
can be set and returned by
setExecutor(Executor)
, getExecutor()
methods respectively.
To realize double buffering it contains methods
getGraphics()
to get
Graphics
instance associated with buffer.
and flushGraphics()
to flush contents of the
buffer.
Field Summary |
---|
Fields inherited from class javax.microedition.lcdui.Canvas |
---|
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 | |
---|---|
XCanvas()
Instantiates XCanvas with initial not full screen mode, null
KeyProcessor and null Executor . |
|
XCanvas(boolean fullScreen)
Instantiates XCanvas with null KeyProcessor and
null Executor . |
Method Summary | |
---|---|
void |
flushGraphics()
Flushes buffer. |
Object |
getCommand(int key)
Returns command associated with given key game action mapped to given key or given game action constant. |
protected Executor |
getExecutor()
Returns Executor invoked for processing commands. |
Graphics |
getGraphics()
Returns Graphics instance associated with buffer. |
protected KeyProcessor |
getKeyProcessor()
Returns KeyProcessor invoked to map keys or sequences of keys
pressed to commands. |
protected void |
keyPressed(int key)
Looks up the command associated with key or sequence of keys pressed and if found, issues it to the executor. |
protected void |
keyReleased(int key)
Sets last found command to null . |
protected void |
keyRepeated(int key)
Issues the last found command. |
protected void |
paint(Graphics g)
Draws rendered buffer. |
void |
setExecutor(Executor executor)
Sets Executor to be used for processing commands. |
void |
setKeyProcessor(KeyProcessor keyProc)
Sets KeyProcessor to be used to map keys or sequences of keys
pressed to commands. |
protected void |
sizeChanged(int width,
int height)
Adjusts buffers |
Methods inherited from class javax.microedition.lcdui.Canvas |
---|
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, hideNotify, isDoubleBuffered, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, serviceRepaints, setFullScreenMode, showNotify |
Methods inherited from class javax.microedition.lcdui.Displayable |
---|
addCommand, getHeight, getTicker, getTitle, getWidth, isShown, removeCommand, setCommandListener, setTicker, setTitle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XCanvas(boolean fullScreen)
null
KeyProcessor
and
null
Executor
.
fullScreen
- if true Xcanvas will start with full-screen mode.public XCanvas()
null
KeyProcessor
and null
Executor
.
Method Detail |
---|
public Graphics getGraphics()
Graphics
instance associated with buffer.
Graphics
instance associated with buffer.public void setExecutor(Executor executor)
Executor
to be used for processing commands.
executor
- the executor to be used for processing commands.protected Executor getExecutor()
Executor
invoked for processing commands.
public void setKeyProcessor(KeyProcessor keyProc)
KeyProcessor
to be used to map keys or sequences of keys
pressed to commands.
keyProc
- KeyProcessor
to be invoked.protected KeyProcessor getKeyProcessor()
KeyProcessor
invoked to map keys or sequences of keys
pressed to commands.
KeyProcessor
invoked to map keys or sequences of keys
pressed to commands.public Object getCommand(int key)
key
- key code or game action constant based on which to look up a
command.
protected void keyPressed(int key)
null
.
keyPressed
in class Canvas
Canvas.keyPressed(int)
protected void keyReleased(int key)
null
.
keyReleased
in class Canvas
Canvas.keyReleased(int)
protected void keyRepeated(int key)
keyRepeated
in class Canvas
Canvas.keyRepeated(int)
protected void sizeChanged(int width, int height)
sizeChanged
in class Canvas
Canvas.sizeChanged(int, int)
protected void paint(Graphics g)
paint
in class Canvas
Canvas.paint(javax.microedition.lcdui.Graphics)
public void flushGraphics()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |