Low Level APIs - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

Low Level APIs

Description:

Canvas isn't a type of screen. Abstract must sub class it ... Drawing & filling of 2D geometric shapes. Lines. rectangles. Arcs. Text characters ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 8
Provided by: dg16
Category:
Tags: apis | geometric | level | low | shapes

less

Transcript and Presenter's Notes

Title: Low Level APIs


1
Low Level APIs
2
Low Level API
  • Canvas isnt a type of screen
  • Abstract must sub class it
  • Has command and event handling behaviour
    available in the sub classes

3
Low Level API
  • Event Notification methods
  • protected  void keyPressed(int keyCode)
              Called when a key is pressed.
  • protected  void keyReleased(int keyCode)
              Called when a key is released.
  • protected  void keyRepeated(int keyCode)
              Called when a key is repeated (held
    down).
  • protected abstract  voidpaint(Graphics g)
              Renders the Canvas.
  • protected  void pointerDragged(int x, int y)
              Called when the pointer is dragged.
  • protected  void pointerPressed(int x, int y)
              Called when the pointer is pressed.
  • protected  void pointerReleased(int x, int y)
              Called when the pointer is released. 
  • void repaint()           Requests a repaint for
    the entire Canvas. 
  • void repaint(int x, int y, int width,
    int height)           Requests a repaint for the
    specified region of the Canvas.

4
Low Level API
  • Field Summary
  • static int DOWN Constant for the DOWN
    game action.
  • static int FIRE Constant for the
    FIRE game action.
  • static int GAME_A Constant for the general
    purpose "A" game action.
  • static int GAME_B Constant for the general
    purpose "B" game action.
  • static int GAME_C Constant for the general
    purpose "C" game action.
  • static int GAME_D Constant for the general
    purpose "D" game action.
  • static int KEY_NUM0 keyCode for ITU-T key
    0.
  • static int KEY_NUM1 keyCode for ITU-T key
    1.
  • static int KEY_NUM9 keyCode for ITU-T key
    9.
  • static int KEY_POUND  keyCode for ITU-T key
    "pound" ().
  • static int KEY_STAR  keyCode for ITU-T key
    "star" ().
  • static int LEFT Constant for the
    LEFT game action.
  • static int RIGHT
    Constant for the RIGHT game action.
  • static int UP Constant for the UP
    game action. 

5
Low Level API
  • Graphics class supports
  • Drawing filling of 2D geometric shapes
  • Lines
  • rectangles
  • Arcs
  • Text characters
  • Color selection for the graphics pen
  • Selection of font for text drawing
  • Clipping
  • Translation of the Graphics co-ordinate system

2D grid
x increasing
y increasing
6
Low Level API
  • Canvas objects can display images
  • Offers the possibility for animating images
  • Supports double buffereing
  • MIDP only supports PNG image formats
  • Need to implement runnable interface
  • public class ThisClass extends Canvas implements
    Runnable
  • Supports multithreading in a class other than one
    is already derived from class Thread
  • Gives us the ability to treat our new class as a
    runnable object
  • Code that controls the thread is placed in the
    run method

7
Low Level API
  • showNotify method
  • protected void showNotify()
  • The implementation calls showNotify() immediately
    prior to this Canvas being made visible on the
    display. Canvas subclasses may override this
    method to perform tasks before being shown, such
    as setting up animations, starting timers, etc.
    The default implementation of this method in
    class Canvas is empty.
  • run() - Method in interface java.lang.Runnable
  • When an object implementing interface Runnable is
    used to create a thread, starting the thread
    causes the object's run method to be called in
    that separately executing thread.
Write a Comment
User Comments (0)
About PowerShow.com