examples.cityguide
Class CityMap

java.lang.Object
  extended by examples.cityguide.CityMap
All Implemented Interfaces:
javax.microedition.location.LocationListener

public class CityMap
extends java.lang.Object
implements javax.microedition.location.LocationListener

This class represents a map with a visitor and landmarks. It allows registration of a map listener which gets information about position changes of the visitor, activations and de-activations of the landmarks and changes of the whole landmark set. A class instance registers itself as a location listener and registers each landmark as a proximity listener, so it is notified about position change and proximity events from a location provider. After getting a notification from the location provider it updates its internal state and delegates the notification to its own listeners.


Field Summary
static int IMAGE_LAST
           
static int IMAGE_MAP
           
static int IMAGE_VISITOR_OFF
           
static int IMAGE_VISITOR_ON
           
static int X
           
static int Y
           
 
Constructor Summary
CityMap(java.lang.String[] imageNames, javax.microedition.location.Coordinates topLeftCoordinates, javax.microedition.location.Coordinates bottomRightCoordinates, javax.microedition.location.Coordinates visitorCoordinates, java.util.Vector categories, ImageManager imageManager, javax.microedition.location.LandmarkStore landmarkStore, javax.microedition.location.LocationProvider locationProvider)
          Creates a new instance of CityMap
 
Method Summary
(package private)  void addMapListener(MapListener listener)
          Registers a map listener.
 void cleanup()
          The final unregistration.
 int[] convertCoordinatesToXY(int[] dest, javax.microedition.location.Coordinates coords)
          Converts from the given latitude / longitude coordinates to the map xy coordinates.
 javax.microedition.location.Coordinates convertXYToCoordinates(javax.microedition.location.Coordinates dest, int[] xy)
          Converts from the given map xy coordinates to the latitude / longitude coordinates.
 void disable()
          Sets the city map to the disabled state.
 void enable()
          Sets the city map to the enabled state.
 javax.microedition.lcdui.Image getMapImage()
          Returns the map image.
 MapLandmark[] getMapLandmarks()
          Returns the set of the map landmarks.
 javax.microedition.lcdui.Image getVisitorImage()
          Returns the visitor icon based on his state.
 int[] getVisitorXY(int[] dest)
          Returns the xy coordinates of the visitor.
 void locationUpdated(javax.microedition.location.LocationProvider provider, javax.microedition.location.Location location)
          A method which is called by the location provider when the current location is changed.
 void providerStateChanged(javax.microedition.location.LocationProvider provider, int newState)
          A method which is called by the location provider when its state changes (for example, when its services are temporary unavailable).
(package private)  void removeMapListener(MapListener listener)
          Unregisters a map listener.
 void setCategories(java.util.Vector categories)
          Changes the landmark set to contain only landmarks of the given categories.
 void setVisitorActive(boolean active)
          Changes the state of the visitor.
 void setVisitorCoordinates(javax.microedition.location.Coordinates newCoordinates)
          Changes the coordinates of the visitor and notifies the listeners about it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X

public static int X

Y

public static int Y

IMAGE_MAP

public static int IMAGE_MAP

IMAGE_VISITOR_ON

public static int IMAGE_VISITOR_ON

IMAGE_VISITOR_OFF

public static int IMAGE_VISITOR_OFF

IMAGE_LAST

public static int IMAGE_LAST
Constructor Detail

CityMap

public CityMap(java.lang.String[] imageNames,
               javax.microedition.location.Coordinates topLeftCoordinates,
               javax.microedition.location.Coordinates bottomRightCoordinates,
               javax.microedition.location.Coordinates visitorCoordinates,
               java.util.Vector categories,
               ImageManager imageManager,
               javax.microedition.location.LandmarkStore landmarkStore,
               javax.microedition.location.LocationProvider locationProvider)
Creates a new instance of CityMap

Method Detail

setCategories

public void setCategories(java.util.Vector categories)
Changes the landmark set to contain only landmarks of the given categories.


setVisitorCoordinates

public void setVisitorCoordinates(javax.microedition.location.Coordinates newCoordinates)
Changes the coordinates of the visitor and notifies the listeners about it.


setVisitorActive

public void setVisitorActive(boolean active)
Changes the state of the visitor. A deactivated visitor doesn't change his position.


getVisitorXY

public int[] getVisitorXY(int[] dest)
Returns the xy coordinates of the visitor.


getVisitorImage

public javax.microedition.lcdui.Image getVisitorImage()
Returns the visitor icon based on his state.


getMapImage

public javax.microedition.lcdui.Image getMapImage()
Returns the map image.


getMapLandmarks

public MapLandmark[] getMapLandmarks()
Returns the set of the map landmarks.


addMapListener

void addMapListener(MapListener listener)
Registers a map listener.


removeMapListener

void removeMapListener(MapListener listener)
Unregisters a map listener.


convertCoordinatesToXY

public int[] convertCoordinatesToXY(int[] dest,
                                    javax.microedition.location.Coordinates coords)
Converts from the given latitude / longitude coordinates to the map xy coordinates.


convertXYToCoordinates

public javax.microedition.location.Coordinates convertXYToCoordinates(javax.microedition.location.Coordinates dest,
                                                                      int[] xy)
Converts from the given map xy coordinates to the latitude / longitude coordinates.


locationUpdated

public void locationUpdated(javax.microedition.location.LocationProvider provider,
                            javax.microedition.location.Location location)
A method which is called by the location provider when the current location is changed.

Specified by:
locationUpdated in interface javax.microedition.location.LocationListener

providerStateChanged

public void providerStateChanged(javax.microedition.location.LocationProvider provider,
                                 int newState)
A method which is called by the location provider when its state changes (for example, when its services are temporary unavailable).

Specified by:
providerStateChanged in interface javax.microedition.location.LocationListener

disable

public void disable()
Sets the city map to the disabled state. In the disabled state it ignores all notifications from the location provider.


enable

public void enable()
Sets the city map to the enabled state.


cleanup

public void cleanup()
The final unregistration.