Class GUI

java.lang.Object
  extended byjavax.microedition.lcdui.Displayable
      extended byjavax.microedition.lcdui.Canvas
          extended byGUI
All Implemented Interfaces:
javax.microedition.lcdui.CommandListener, java.lang.Runnable

public class GUI
extends javax.microedition.lcdui.Canvas
implements java.lang.Runnable, javax.microedition.lcdui.CommandListener

Copyright (c) 2003 Sony Ericsson Mobile Communications AB
All Rights Reserved.

The GUI is the canvas the user sees. It provides graphics & sound for the user and handles user input on the screen or by buttons.

Version:
1.13
Author:
Christopher Wong, Åke Rydgren

Field Summary
 
Fields inherited from class javax.microedition.lcdui.Canvas
DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, RIGHT, UP
 
Constructor Summary
GUI(CarAPI carAPI, BluetoothCar bluetoothCar)
          Constructs a new GUI object.
 
Method Summary
 boolean allUpdated()
           
 void commandAction(javax.microedition.lcdui.Command c, javax.microedition.lcdui.Displayable d)
          Respond to menu commands.
protected  void hideNotify()
          Called by the system to notify us that the canvas is now at least partially obscured by another application window, when it previously has been completely visible.
protected  void keyPressed(int keyCode)
          Handles user input from the buttons.
protected  void keyReleased(int keyCode)
          Handles user input from the buttons.
protected  void keyRepeated(int keyCode)
          Handles user input from the buttons.
 void paint(javax.microedition.lcdui.Graphics g)
          Invoked by system to draw 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 by the system when the pointer is released.
 void run()
          The GUI-loop.
protected  void showNotify()
          Called by the system to notify us that the canvas is now completely visible, when it previously has been at least partially obscured by another application window.
protected  void sizeChanged(int w, int h)
          Called when the drawable area of the Canvas has been changed.
 void stopRecording()
           
 void stopReplaying()
           
 
Methods inherited from class javax.microedition.lcdui.Canvas
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, isDoubleBuffered, repaint, repaint, serviceRepaints, setFullScreenMode
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getHeight, getTicker, getTitle, getWidth, isShown, removeCommand, setCommandListener, setTicker, setTitle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GUI

public GUI(CarAPI carAPI,
           BluetoothCar bluetoothCar)
Constructs a new GUI object.

Parameters:
carAPI - the interface to control car and check car status.
Method Detail

run

public void run()
The GUI-loop. This loop updates the GUI when a changed has been made to the car's status, such as car connected, no link to the car, or car charging. It also initiates any sound FX. The loop will enter the wait state while the MIDlet is Paused or hidden.

Specified by:
run in interface java.lang.Runnable

allUpdated

public boolean allUpdated()

paint

public void paint(javax.microedition.lcdui.Graphics g)
Invoked by system to draw canvas.


sizeChanged

protected void sizeChanged(int w,
                           int h)
Called when the drawable area of the Canvas has been changed. Calles the loadImages() method if the width or height is different from what it was the last time loadImages() was executed. loadImages() will load all images if not already done and downscale any images as needed.

Parameters:
w - the new width in pixels of the drawable area of the Canvas
h - the new height in pixels of the drawable area of the Canvas

keyPressed

protected void keyPressed(int keyCode)
Handles user input from the buttons.

Parameters:
keyCode - the code for the key action generated by user.

keyRepeated

protected void keyRepeated(int keyCode)
Handles user input from the buttons.

Parameters:
keyCode - the code for the key action generated by user.

keyReleased

protected void keyReleased(int keyCode)
Handles user input from the buttons.

Parameters:
keyCode - the code for the key action generated by user.

pointerPressed

protected void pointerPressed(int x,
                              int y)
Called when the pointer is pressed. Changes speed and/or direction of the car. (direction is changed if the pointer is within the wheel sprite)

Parameters:
x - the horizontal location where the pointer was pressed (relative to the Canvas)
y - the vertical location where the pointer was pressed (relative to the Canvas)

pointerDragged

protected void pointerDragged(int x,
                              int y)
Called when the pointer is dragged. Changes speed and/or direction of the car. (direction is changed if the pointer was previously pressed within the wheel sprite)

Parameters:
x - the horizontal location where the pointer was dragged (relative to the Canvas)
y - the vertical location where the pointer was dragged (relative to the Canvas)

pointerReleased

protected void pointerReleased(int x,
                               int y)
Called by the system when the pointer is released. Changes speed and/or direction of the car. (direction is changed if the pointer was previously pressed within the wheel sprite)

Parameters:
x - the horizontal location where the pointer was released (relative to the Canvas)
y - the vertical location where the pointer was released (relative to the Canvas)

hideNotify

protected void hideNotify()
Called by the system to notify us that the canvas is now at least partially obscured by another application window, when it previously has been completely visible. Calls the carAPI.setAppActive(false).


showNotify

protected void showNotify()
Called by the system to notify us that the canvas is now completely visible, when it previously has been at least partially obscured by another application window. Calls the carAPI.setAppActive(true).


stopRecording

public void stopRecording()

stopReplaying

public void stopReplaying()

commandAction

public void commandAction(javax.microedition.lcdui.Command c,
                          javax.microedition.lcdui.Displayable d)
Respond to menu commands.

Specified by:
commandAction in interface javax.microedition.lcdui.CommandListener
Parameters:
c - the command triggering this action
d - the Displayable on which this event has occurred