Implementation of Image Viewer

The following UML diagram shows the classes and interfaces used in the Image Viewer MIDlet.

Figure: Image Viewer MIDlet class diagram

Image Viewer classes

The Image Viewer MIDlet consists of the following classes:

  • ImageViewerMIDlet

    This is the main class of the MIDlet. It controls the display and handles the transitions between the different screens.

  • FileSelector

    This class contains the bulk of the MIDlet. It creates the UI for navigating the device file system and selecting images to display. It also provides support for file management operations such as delete, rename, and directory creation.

    FileSelector checks whether the fileconn.dir.photos system property is specified and, if specified, opens the file browser in that directory. If the system property is not specified, FileSelector displays a list of available roots instead.

  • ImageCanvas

    This class displays the selected image on the screen and allows the user to return to the file browser (FileSelector).

  • OperationsQueue

    An important consideration in designing the Image Viewer MIDlet is that I/O operations must be executed in a separate thread. The OperationsQueue class accomplishes this by executing commands serially in a separate thread.

  • Operation

    This class defines the Operation interface used by OperationsQueue.

  • InputScreen

    This class is a simple Form used for prompting the user to enter text. This is used when creating a new directory or when renaming a file.

  • ErrorScreen

    This class is used for reporting runtime errors to the user.

Image Viewer UI

The UI of the Image Viewer MIDlet consists of a simple file browser that:

  • Displays the contents of the current directory

  • Allows the user to navigate up and down the directory tree

  • Allows the user to select an image to display

  • Allows the user to perform file management operations

The following figure shows how to use the Image Viewer MIDlet to navigate the device file system and select an image to display.

Figure: Navigating the device file system and viewing an image