Session8 J2ME Low Level User Interface

3,168 views

Published on

Session8 J2ME Low Level User Interface

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,168
On SlideShare
0
From Embeds
0
Number of Embeds
12
Actions
Shares
0
Downloads
102
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Session8 J2ME Low Level User Interface

  1. 1. Outline-session 8 (09-April-2009) <ul><li>>> Low-Level User Interface </li></ul><ul><li>-Introduction </li></ul><ul><li>-Canvas </li></ul><ul><li>-Graphics </li></ul>
  2. 2. Introduction <ul><li>>>Two key classes make up the low-level API, Canvas and Graphics. </li></ul><ul><li>Canvas : </li></ul><ul><li>>>it has a specific height and width and is drawn onto to create what the end user will see. </li></ul><ul><li>>> Whatever is drawn becomes visible on the display. </li></ul><ul><li>>>The canvas class also provides methods for low-level event handling </li></ul><ul><li>Graphics: </li></ul><ul><li>>>We draw onto a canvas with a Graphics object. </li></ul><ul><li>>>This class has methods for drawing lines, arcs, rectangles and text. </li></ul><ul><li>>>This class also includes methods to specify color as well as font preferences. </li></ul>
  3. 3. Canvas <ul><li>>> Canvas is a subclass of Displayable </li></ul><ul><li>Creating Canvas: </li></ul><ul><li>>> create a subclass of Canvas, and ask that object be set as the current Displayable. </li></ul>
  4. 4. Canvas <ul><li>>> Coordinate System </li></ul><ul><li>--The origin for drawing begins in the upper left corner of the display, location 0,0 </li></ul><ul><li>--x values increase heading to the right, y values increase heading down </li></ul><ul><li>-- When drawing a line or shape (arc, rectangle, etc.), the thickness (known as the pen) is always 1 pixel wide </li></ul><ul><li>-- if you request to start a line at 1,1 </li></ul><ul><li>--How many pixels will be &quot;filled&quot; for the entire line segment 1,1 to 3,1? </li></ul>
  5. 5. Canvas <ul><li>>>Canvas Width and Height </li></ul><ul><li>>> Painting on a Canvas: </li></ul><ul><li>-What differs between a Canvas and the other Displayable objects (Form, TextBox, List and Alert) is where the drawing of the component takes place and who is responsible for the drawing. </li></ul>
  6. 6. Canvas <ul><li>>>Canvas Paint Methods: </li></ul><ul><li>. </li></ul>
  7. 7. Canvas <ul><li>>> Communication with Application Manager : </li></ul><ul><li>-- When the application manager is about to make a Canvas visible on the display, it will call the method showNotify(). </li></ul><ul><li>-- When the Canvas has been removed from the display, the method hideNotify() is called </li></ul><ul><li>. </li></ul>
  8. 8. Canvas <ul><li>>> Communication with Application Manager : </li></ul><ul><li>-- When the application manager is about to make a Canvas visible on the display, it will call the method showNotify(). </li></ul><ul><li>-- When the Canvas has been removed from the display, the method hideNotify() is called </li></ul><ul><li>. </li></ul>
  9. 9. Canvas <ul><li>>> Event Handling : </li></ul><ul><li>--The low-level interface, consisting of key codes, game actions and pointer events. </li></ul><ul><li>Commands: </li></ul><ul><li>• addCommand(Command) </li></ul><ul><li>• isShown() </li></ul><ul><li>• removeCommand(Command) </li></ul><ul><li>• setCommandListener(CommandListener) </li></ul><ul><li>. </li></ul>
  10. 10. Canvas <ul><li>>> Key Codes : </li></ul><ul><li>--Key codes are numeric values that map directly to specific keys on a mobile device. </li></ul><ul><li>--These codes correspond to the ITU-T keypad (0–9, *, #) the standard telephone keypad </li></ul><ul><li>. </li></ul>
  11. 11. Canvas <ul><li>>> Key Codes : </li></ul><ul><li>. </li></ul>
  12. 12. Canvas <ul><li>>> Game Actions: </li></ul><ul><li>--MIDP defines a set of constants, referred to as game actions, to facilitate event handling for game related events. </li></ul><ul><li>--You are assured that each game action will be assigned a key code by the implementation </li></ul><ul><li>Sample:GameAction.java </li></ul><ul><li>. </li></ul>
  13. 13. Canvas
  14. 14. Canvas <ul><li>>> pointer events: </li></ul><ul><li>-- The MID Profile includes a set of methods to interact with pointer devices such as a mouse or touch screen. </li></ul><ul><li>. </li></ul>

×