Class MyCanvas

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Canvas
          extended by MyCanvas
All Implemented Interfaces:
javax.microedition.lcdui.CommandListener

public class MyCanvas
extends javax.microedition.lcdui.Canvas
implements javax.microedition.lcdui.CommandListener

MyCanvas

Author:
Rune Romundstad

Field Summary
 int[] apartmentsX
           
 int[] apartmentsY
           
 java.lang.String imageString
           
 int imgX
           
 int imgY
           
 java.lang.String link
           
 
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
MyCanvas(mobileClient midlet)
          constructor makes sure it's only one instance of the midlet object.
 
Method Summary
 void commandAction(javax.microedition.lcdui.Command c, javax.microedition.lcdui.Displayable d)
          commandAction listen as in the other class on the commands.
 void paint(javax.microedition.lcdui.Graphics g)
          paint takes care of all the drawing to screen.
 void pointerPressed(int x, int y)
          pointerPressed listens if something is pressed at the screen.
 
Methods inherited from class javax.microedition.lcdui.Canvas
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, isDoubleBuffered, repaint, repaint, serviceRepaints, setCommandListener, setFullScreenMode
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getHeight, getTicker, getTitle, getWidth, isShown, removeCommand, setTicker, setTitle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

imageString

public java.lang.String imageString

link

public java.lang.String link

apartmentsX

public int[] apartmentsX

apartmentsY

public int[] apartmentsY

imgX

public int imgX

imgY

public int imgY
Constructor Detail

MyCanvas

public MyCanvas(mobileClient midlet)
constructor makes sure it's only one instance of the midlet object. It also creates and add the commands used.

Parameters:
midlet - is a object of mobileClient.
Method Detail

paint

public void paint(javax.microedition.lcdui.Graphics g)
paint takes care of all the drawing to screen. Both the images/maps and the drawing on the map.

Specified by:
paint in class javax.microedition.lcdui.Canvas

commandAction

public void commandAction(javax.microedition.lcdui.Command c,
                          javax.microedition.lcdui.Displayable d)
commandAction listen as in the other class on the commands. If 'exit' is pressed it calls the exitMidlet in the mobileClient class. If 'locate' is pressed it clears the display, sets the showFacilities true, sets the imageString and the explanation text and calls repaint to draw it all. If 'openBrowser' is pressed it calls the openBrowser function with the link set below in the pointerPressed function, as parameter.

Specified by:
commandAction in interface javax.microedition.lcdui.CommandListener

pointerPressed

public void pointerPressed(int x,
                           int y)
pointerPressed listens if something is pressed at the screen. And it gets where in the screen it have been pressed through the x and y inparameters. The functions then checks if the user have pressed at one of the apartments, and if it displays short information about the apartment below the map, and sets the link variable to the apartments prospect.

Overrides:
pointerPressed in class javax.microedition.lcdui.Canvas