Top Banner
Outline-session 8 (09-April- 2009) >> Low-Level User Interface -Introduction -Canvas -Graphics
14

Session8 J2ME Low Level User Interface

Dec 04, 2014

Download

Documents

muthusvm

Session8 J2ME Low Level User Interface
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Session8 J2ME Low Level User Interface

Outline-session 8 (09-April-2009)

>> Low-Level User Interface-Introduction-Canvas-Graphics

Page 2: Session8 J2ME Low Level User Interface

Introduction

>>Two key classes make up the low-level API, Canvas and Graphics.Canvas :

>>it has a specific height and width and is drawn onto to create what the end user will see.>> Whatever is drawn becomes visible on the display. >>The canvas class also provides methods for low-level event handling

Graphics:>>We draw onto a canvas with a Graphics object.>>This class has methods for drawing lines, arcs, rectangles and text. >>This class also includes methods to specify color as well as font preferences.

Page 3: Session8 J2ME Low Level User Interface

Canvas

>> Canvas is a subclass of DisplayableCreating Canvas:

>> create a subclass of Canvas, and ask that object be set as the current Displayable.

Page 4: Session8 J2ME Low Level User Interface

Canvas

>> Coordinate System--The origin for drawing begins in the upper left corner of the display, location 0,0--x values increase heading to the right, y values increase heading down-- When drawing a line or shape (arc, rectangle, etc.), the thickness (known as the pen) is always 1 pixel wide-- if you request to start a line at 1,1--How many pixels will be "filled" for the entire line segment 1,1 to 3,1?

Page 5: Session8 J2ME Low Level User Interface

Canvas

>>Canvas Width and Height

>> Painting on a Canvas:-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.

Page 6: Session8 J2ME Low Level User Interface

Canvas

>>Canvas Paint Methods:

.

Page 7: Session8 J2ME Low Level User Interface

Canvas

>> Communication with Application Manager :-- When the application manager is about to make a Canvas visible on the display, it will call the method showNotify().-- When the Canvas has been removed from the display, the method hideNotify() is called

.

Page 8: Session8 J2ME Low Level User Interface

Canvas

>> Communication with Application Manager :-- When the application manager is about to make a Canvas visible on the display, it will call the method showNotify().-- When the Canvas has been removed from the display, the method hideNotify() is called

.

Page 9: Session8 J2ME Low Level User Interface

Canvas

>> Event Handling:--The low-level interface, consisting of key codes, game actions and pointer events.Commands:• addCommand(Command)• isShown()• removeCommand(Command)• setCommandListener(CommandListener)

.

Page 10: Session8 J2ME Low Level User Interface

Canvas

>> Key Codes:--Key codes are numeric values that map directly to specific keys on a mobile device.--These codes correspond to the ITU-T keypad (0–9, *, #) the standard telephone keypad

.

Page 11: Session8 J2ME Low Level User Interface

Canvas

>> Key Codes:

.

Page 12: Session8 J2ME Low Level User Interface

Canvas

>> Game Actions:--MIDP defines a set of constants, referred to as game actions, to facilitate event handling for game related events.--You are assured that each game action will be assigned a key code by the implementationSample:GameAction.java

.

Page 13: Session8 J2ME Low Level User Interface

Canvas

Page 14: Session8 J2ME Low Level User Interface

Canvas

>> pointer events:-- The MID Profile includes a set of methods to interact with pointer devices such as a mouse or touch screen.

.