org.kalmeo.kuix.core
Class KuixCanvas

java.lang.Object
  extended by GameCanvas
      extended by org.kalmeo.kuix.core.KuixCanvas

public final class KuixCanvas
extends GameCanvas

This is the Kuix implementation of the J2ME GameCanvas. This canvas intercept all user events (keyboard and pointer)

Author:
bbeaulant

Constructor Summary
KuixCanvas(KuixInitializer initializer, boolean fullscreen)
          Construct a KuixCanvas.
 
Method Summary
 void addUnpaintableWidget(Widget widget)
          Add a new unpaintable widget to the unpaintableWidgets list.
 int adoptKeyCode(int keyCode)
          Used to adopt key code to predefined constances, which are platform independent.
 void clearUnpaintableWidgets()
          Remove all unpaintable widgets.
protected  void drawDebugInfos(Graphics g)
          Draw debugInfos to the given Graphics
 java.lang.String getDebugInfos()
          Returns a String representation of the debug infos.
 Desktop getDesktop()
          Returns the Desktop instance.
 KuixInitializer getInitializer()
          Returns the KuixInitializer instance.
 java.lang.String getPlatformName()
          name of curent platform
protected  void hideNotify()
           
protected  void initialize()
          Initialize the Canvas
 boolean isDebugInfosEnabled()
           
protected  void keyPressed(int keyCode)
           
protected  void keyReleased(int keyCode)
           
protected  void keyRepeated(int keyCode)
           
 void paint(Graphics g)
           
protected  void pointerDragged(int x, int y)
           
protected  void pointerPressed(int x, int y)
           
protected  void pointerReleased(int x, int y)
           
protected  void processKeyEvent(byte type, int keyCode)
          Process the key events
protected  void processPointerEvent(byte type, int x, int y)
          Common process for pointer events
 void removeUnpaintableWidget(Widget widget)
          Add a widget from the unpaintableWidgets list.
 void repaintAsSoonAsPossible()
          Repaint the desktop as soon as possible.
 void repaintNextFrame()
          Repaint through the Worker task
 void repaintNextFrame(int x, int y, int width, int height)
          Repaint through the Worker task
 void revalidateAsSoonAsPossible()
          Revalidate (and repaint) the desktop as soon as possible.
 void revalidateNextFrame()
          Revalidate the desktop throught the Worker task.
 void setDebugInfosEnabled(boolean debugInfosEnabled)
           
protected  void setDebugInfosKuixKeyCode(int debugInfosKuixKeyCode)
          Define the key that the user need to press 3 consecutive times to display on screen debug infos.
 void setTransition(Transition transition)
          Define the next repaint transition.
protected  void showNotify()
           
protected  void sizeChanged(int w, int h)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KuixCanvas

public KuixCanvas(KuixInitializer initializer,
                  boolean fullscreen)
Construct a KuixCanvas. By default the canvas is auto created by the KuixMIDlet. But if you create it manualy @se KuixInitializer.

Parameters:
initializer -
fullscreen -
Method Detail

getInitializer

public KuixInitializer getInitializer()
Returns the KuixInitializer instance.

Returns:
the initializer instance

getDesktop

public Desktop getDesktop()
Returns the Desktop instance.

Returns:
the desktop instance.

setDebugInfosKuixKeyCode

protected void setDebugInfosKuixKeyCode(int debugInfosKuixKeyCode)
Define the key that the user need to press 3 consecutive times to display on screen debug infos. This value define one or more keys (ex: KuixConstants.KUIX_KEY_STAR | KuixConstants.KUIX_KEY_POUND, press * or # to activete debug onfos display)
By default the value si set to KuixConstants.KUIX_KEY_STAR.

Parameters:
debugInfosKuixKeyCode - the debugInfosKuixKeyCode to set

isDebugInfosEnabled

public boolean isDebugInfosEnabled()
Returns:
the debugInfosEnabled

setDebugInfosEnabled

public void setDebugInfosEnabled(boolean debugInfosEnabled)
Parameters:
debugInfosEnabled - the debugInfosEnabled to set

setTransition

public void setTransition(Transition transition)
Define the next repaint transition. The transition delay depends on the transition implementation.

Parameters:
transition -

initialize

protected void initialize()
Initialize the Canvas


paint

public void paint(Graphics g)

sizeChanged

protected void sizeChanged(int w,
                           int h)

hideNotify

protected void hideNotify()

showNotify

protected void showNotify()

repaintNextFrame

public void repaintNextFrame()
Repaint through the Worker task


repaintNextFrame

public void repaintNextFrame(int x,
                             int y,
                             int width,
                             int height)
Repaint through the Worker task

Parameters:
x - x coordinate of the repaint region
y - y coordinate of the repaint region
width - width of the repaint region
height - height of the repaint region

revalidateNextFrame

public void revalidateNextFrame()
Revalidate the desktop throught the Worker task. repaintNextFrame is automaticaly call.


revalidateAsSoonAsPossible

public void revalidateAsSoonAsPossible()
Revalidate (and repaint) the desktop as soon as possible. If the current thread is the worker thread the task is done immedialty else it is deferred to the next frame.


repaintAsSoonAsPossible

public void repaintAsSoonAsPossible()
Repaint the desktop as soon as possible. If the current thread is the worker thread the task is done immedialty else it is deferred to the next frame.


addUnpaintableWidget

public void addUnpaintableWidget(Widget widget)
Add a new unpaintable widget to the unpaintableWidgets list.
Caution that adding a widget to this list mask a region of the display event if the given widget is not on top : popup over this region may be masked and invisible.
The unpaintableWidgets list is cleared before each repaint.

Parameters:
widget -

removeUnpaintableWidget

public void removeUnpaintableWidget(Widget widget)
Add a widget from the unpaintableWidgets list.

Parameters:
widget -

clearUnpaintableWidgets

public void clearUnpaintableWidgets()
Remove all unpaintable widgets.


drawDebugInfos

protected void drawDebugInfos(Graphics g)
Draw debugInfos to the given Graphics

Parameters:
g -

getDebugInfos

public java.lang.String getDebugInfos()
Returns a String representation of the debug infos. Override this method to add your own debug infos. Use the \n character to have a multiline text.

Returns:
a String representation of the debug infos

keyPressed

protected void keyPressed(int keyCode)

keyReleased

protected void keyReleased(int keyCode)

keyRepeated

protected void keyRepeated(int keyCode)

processKeyEvent

protected void processKeyEvent(byte type,
                               int keyCode)
Process the key events

Parameters:
type -
keyCode -

pointerDragged

protected void pointerDragged(int x,
                              int y)

pointerPressed

protected void pointerPressed(int x,
                              int y)

pointerReleased

protected void pointerReleased(int x,
                               int y)

processPointerEvent

protected void processPointerEvent(byte type,
                                   int x,
                                   int y)
Common process for pointer events

Parameters:
type -
x -
y -

getPlatformName

public java.lang.String getPlatformName()
name of curent platform

Returns:
PLATFORM_NAME

adoptKeyCode

public int adoptKeyCode(int keyCode)
Used to adopt key code to predefined constances, which are platform independent.

Parameters:
keyCode - This code is sent by platform to canvas and redirected here
Returns:
this keycode is equal to one of our constants declared in this class


Copyright © 2007-2008 Kalmeo. All Rights Reserved.