站内搜索: 请输入搜索关键词
当前页面: 图书首页 > MIDP Style Guide for the Java 2 Platform, Micro Edition

MIDP Style Guide for the Java 2 Platform, Micro Edition

[ directory ] Previous Section Next Section

Chapter 10. Canvas Screens

A canvas provides access to low-level input mechanisms, such as key presses and low-level graphics calls, such as drawing simple shapes. A canvas can be useful to an application that needs full control of the screen. It can be used as a way to edit or display a custom item off the form, for example. SmartTicket uses a canvas, shown in Figure 10.1, for the screen that enables a user to choose a seat in the theater. The canvas displays a graphic of a floor plan.

Figure 10.1. SmartTicket's Canvas Screen

graphics/10fig01.gif

MIDP 2.0 also provides an extension to Canvas screens, called a game canvas. The game canvas has additional features such as sprites, background panning, layers, and an offscreen buffer. The advice in this chapter also applies to the games canvas (except for the discussion on creating your own offscreen buffer); additional advice, specific to the game canvas, is covered in Chapter 11.

Application Developer Responsibilities

MIDP Implementor Responsibilities

  • Drawing the screen

  • Updating the screen as necessary (for example, in response to key presses)

  • Abstract commands for the screen

  • Mapping game actions to the device

  • Support for phone keypad keys

  • Touch input support (if available on the device)

  • Informing the application of user input (key input, touch input, abstract command use)

Because a canvas provides access to lower-level functionality, an application developer can create a screen that is tuned for a particular device. It is also possible, by following the guidelines in this chapter, to create portable applications that use a canvas screen. The advice will also help in creating canvas screens that integrate well with high-level screens in an application.

    [ directory ] Previous Section Next Section