examples.cityguide
Class MapCanvas

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Canvas
          extended by examples.cityguide.MapCanvas
All Implemented Interfaces:
MapListener

public class MapCanvas
extends javax.microedition.lcdui.Canvas
implements MapListener

This class represents a "view" of a city map. It shows a visitor and landmarks.


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
MapCanvas(CityMap cityMap)
          Creates a new instance of MapCanvas.
 
Method Summary
 void cleanup()
          The final unregistration.
protected  void hideNotify()
          Stops the animation timer when the canvas gets invisible and unregisters itself from receiving the notifications from the CityMap instance.
 void landmarksChanged(CityMap sender)
          A method which is called by the city map, when the whole set of landmarks changes.
 void landmarkStateChanged(CityMap sender, MapLandmark mapLandmark)
          A method which is called by the city map, when a landmark gets activated or deactivated.
 void paint(javax.microedition.lcdui.Graphics g)
           
protected  void showNotify()
          Starts an animation timer when the canvas gets visible and registers the canvas instance to get the notifications from the CityMap instance.
(package private)  void updateActivatedLandmarks()
          Updates the animation of active landmarks.
 void visitorPositionChanged(CityMap sender)
          A method which is called by the city map, when the visitor changes his position.
 void visitorStateChanged(CityMap sender)
          A method which is called by the city map, when the visitor changes his state.
 
Methods inherited from class javax.microedition.lcdui.Canvas
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, isDoubleBuffered, keyPressed, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, serviceRepaints, setFullScreenMode, sizeChanged
 
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

MapCanvas

public MapCanvas(CityMap cityMap)
Creates a new instance of MapCanvas. Register itself as a map listener to the given instance of the CityMap class.

Method Detail

updateActivatedLandmarks

void updateActivatedLandmarks()
Updates the animation of active landmarks.


paint

public void paint(javax.microedition.lcdui.Graphics g)
Specified by:
paint in class javax.microedition.lcdui.Canvas

visitorPositionChanged

public void visitorPositionChanged(CityMap sender)
A method which is called by the city map, when the visitor changes his position.

Specified by:
visitorPositionChanged in interface MapListener

visitorStateChanged

public void visitorStateChanged(CityMap sender)
A method which is called by the city map, when the visitor changes his state.

Specified by:
visitorStateChanged in interface MapListener

landmarkStateChanged

public void landmarkStateChanged(CityMap sender,
                                 MapLandmark mapLandmark)
A method which is called by the city map, when a landmark gets activated or deactivated.

Specified by:
landmarkStateChanged in interface MapListener

landmarksChanged

public void landmarksChanged(CityMap sender)
A method which is called by the city map, when the whole set of landmarks changes.

Specified by:
landmarksChanged in interface MapListener

showNotify

protected void showNotify()
Starts an animation timer when the canvas gets visible and registers the canvas instance to get the notifications from the CityMap instance.

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

hideNotify

protected void hideNotify()
Stops the animation timer when the canvas gets invisible and unregisters itself from receiving the notifications from the CityMap instance.

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

cleanup

public void cleanup()
The final unregistration.