org.epseelon.mobimap
Class MobiMap

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Canvas
          extended by org.epseelon.mobimap.MobiMap

public class MobiMap
extends javax.microedition.lcdui.Canvas

A tile oriented map component that can easily be used with tile sources on the web like Google and Yahoo maps.

Center properties

MobiMap has three center point properties.

The addressLocation property represents an abstract center of the map. This would usually be something like the first item in a search result. It is a GeoPosition.

The centerPosition property represents the current center point of the map. If the user pans the map then the centerPosition point will change but the addressLocation will not. Calling recenterToAddressLocation() will move the map back to that center address.

The center property represents the same point as the centerPosition property, but as a Point2D in pixel space instead of a GeoPosition in lat/long space. Note that the center property is a Point2D in the entire world bitmap, not in the portion of the map currently visible. You can use the getViewportBounds() method to find the portion of the map currently visible and adjust your calculations accordingly. Changing the center property will change the centerPosition property and vice versa.

All three properties are bound.

Zoom

The zoom works in a special way. In order to be independent of any specific zoom scale, this component defines a standard reference zoom scale based on the following principle: whatever the provider or tile size, at zoom level z, the entire world is represented on an image that is 2^z pixels on each side. For example, when z=0, the entire world is 1 pixel. When z=8, the entire world is 256x256 pixels.

This component supports zoom values from 0 to 31, and each provider supports a specific range. For example, Google Maps supports range from 8 to 25.

Note that zoom value increase with definition, 0 being maximum zoom out, 31 being maximum zoom in.


Field Summary
 org.epseelon.mobimap.MobiMap.Action FUNCTION_DESELECT_WAYPOINT
          Function to deselect currently selected waypoint if any
 org.epseelon.mobimap.MobiMap.Action FUNCTION_HELP
          Function to display a key help
 org.epseelon.mobimap.MobiMap.Action FUNCTION_NEXT_WAYPOINT
          Function to select the next waypoint
 org.epseelon.mobimap.MobiMap.Action FUNCTION_NO_FUNCTION
          Function that corresponds to no function.
 org.epseelon.mobimap.MobiMap.Action FUNCTION_PAN_DOWN
          Function to pan the map down
 org.epseelon.mobimap.MobiMap.Action FUNCTION_PAN_LEFT
          Function to pan the map on the left
 org.epseelon.mobimap.MobiMap.Action FUNCTION_PAN_RIGHT
          Function to pan the map on the right
 org.epseelon.mobimap.MobiMap.Action FUNCTION_PAN_UP
          Function to pan the map up
 org.epseelon.mobimap.MobiMap.Action FUNCTION_PREVIOUS_WAYPOINT
          Function to select the previous waypoint
 org.epseelon.mobimap.MobiMap.Action FUNCTION_SWITCH_MODE
          Function to switch the map mode for the current provider
 org.epseelon.mobimap.MobiMap.Action FUNCTION_SWITCH_PROVIDER
          Function to switch the map data provider
 org.epseelon.mobimap.MobiMap.Action FUNCTION_WAYPOINT_DETAILS
          Function to display waypoint details
 org.epseelon.mobimap.MobiMap.Action FUNCTION_ZOOM_IN
          Function to zoom in.
 org.epseelon.mobimap.MobiMap.Action FUNCTION_ZOOM_OUT
          Function to zoom out.
static java.lang.String IMAGE_EMPTY_TILE
           
static int KEY_ARROW_DOWN
          Constant identifying the down button on the phone.
static int KEY_ARROW_LEFT
          Constant identifying the left button on the phone.
static int KEY_ARROW_RIGHT
          Constant identifying the right button on the phone.
static int KEY_ARROW_UP
          Constant identifying the up button on the phone.
static int KEY_F_LEFT
          Constant identifying the left function button on most phones
static int KEY_F_RIGHT
          Constant identifying the right function button on most phones
static int KEY_OK_BUTTON
          Constant identifying the validation button on most phones
 
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
 
Fields inherited from class javax.microedition.lcdui.Displayable
ui
 
Constructor Summary
MobiMap()
          Creates a new MobiMap with an empty tile factory and recenterOnClickEnabled set to false;
 
Method Summary
 void addRepeatedFunction(org.epseelon.mobimap.MobiMap.Action function)
           
 void addWaypoint(Waypoint waypoint)
          Adds a waypoint to be displayed over the map
 void calculateZoomFrom(GeoPosition[] positions)
          Calculates a zoom level so that all points in the specified set will be visible on screen.
 void deselectWaypoint()
          Deselects the selected waypoint if any
protected  void drawHelpBox(javax.microedition.lcdui.Graphics graphics)
           
protected  void drawMapTiles(javax.microedition.lcdui.Graphics g, int zoom, Rectangle viewportBounds)
          Draw the map tiles.
protected  void drawNavigationControls(javax.microedition.lcdui.Graphics g, Rectangle viewportBounds)
           
protected  void drawPanControls(javax.microedition.lcdui.Graphics g)
           
protected  void drawProviderControls(javax.microedition.lcdui.Graphics g)
           
protected  void drawWaypoints(javax.microedition.lcdui.Graphics g, int zoom, Rectangle viewportBounds)
          This function iterates over all the waypoints and draws them using the WaypointPainter that is set up on this map.
protected  void drawZoomControls(javax.microedition.lcdui.Graphics g, int zoom)
           
protected  void fireWaypointSelected()
          Triggers the action associated with waypoint selected
 GeoPosition getAddressLocation()
          Gets the current address location of the map.
 javax.microedition.lcdui.Image getBarBackgroundImage()
           
 Point2D getCenter()
          Gets the current pixel center of the map.
 GeoPosition getCenterPosition()
          A property indicating the center position of the map
 javax.microedition.lcdui.Image getLoadingImage()
          A property for an image which will be display when an image is still loading.
 javax.microedition.lcdui.Image getNextWaypointImage()
           
 int getPanSpeed()
           
 Waypoint getSelectedWaypoint()
           
 TileFactory getTileFactory()
          Get the current factory
 Rectangle getViewportBounds()
          Returns the bounds of the viewport in pixels.
 Waypoint[] getWaypoints()
           
 int getZoom()
          Gets the current zoom level
protected  boolean isDoubleClick(int x, int y)
          Utility method to determine if a pointerPressed call corresponds to a double click, based on DOUBLE_CLICK_TIME and DOUBLE_CLICK_DISTANCE.
 boolean isHelpBoxVisible()
           
 boolean isHorizontalWrapped()
          Indicates whether tiles start again on the left when we arrive on the right edge of the map, and vice-versa
 boolean isModeSwitchingEnabled()
           
 boolean isPanEnabled()
          A property indicating if the map should be pannable by the user using the mouse.
 boolean isProviderSwitchingEnabled()
           
 boolean isRecenterOnDoubleClickEnabled()
           
 boolean isRestrictOutsidePanning()
          A property indicating whether the user is restricted to pan over the viewport edges
 boolean isShowPanControls()
           
 boolean isShowProviderControls()
           
 boolean isShowWaypoints()
           
 boolean isShowZoomSlider()
           
 boolean isZooming()
           
 void keyPressed(int keyCode)
          Used to pan using the arrow keys
 void keyRepeated(int keyCode)
          This method is called when a key is pressed
protected  void paint(javax.microedition.lcdui.Graphics graphics)
           
 void pan(int dx, int dy)
          Move the map by dx pixels horizontally and dy pixels vertically.
protected  void pointerDragged(int x, int y)
          Only available on touch screen devices.
protected  void pointerPressed(int x, int y)
          Only available on touch screen devices.
protected  void recenterMap(int x, int y)
          Recenters the map on given x and y.
 void recenterToAddressLocation()
          Re-centers the map to have the current address location be at the center of the map, accounting for the map's width and height.
 void removeRepeatedFunction(org.epseelon.mobimap.MobiMap.Action function)
           
 void removeWaypoint(Waypoint waypoint)
          Removes a waypoint from the list of points to be displayed over the map
 void selectNextWaypoint()
          Switches waypoint selection to the next one.
 void selectPreviousWaypoint()
          Switches waypoint selection to the next one.
 void setAddressLocation(GeoPosition addressLocation)
          Gets the current address location of the map
 void setBarBackgroundImage(javax.microedition.lcdui.Image barBackgroundImage)
           
 void setCenter(Point2D center)
          Sets the new center of the map in pixel coordinates.
 void setCenterPosition(GeoPosition geoPosition)
          A property indicating the center position of the map
 void setHelpBoxVisible(boolean helpBoxVisible)
           
 void setHorizontalWrapped(boolean horizontalWrapped)
          Indicates whether tiles start again on the left when we arrive on the right edge of the map, and vice-versa
 void setKeyFunction(int key, org.epseelon.mobimap.MobiMap.Action function)
          Valid values for key include all constants starting with KEY_ Valid values for function include all constants starting with FUNCTION_
 void setLoadingImage(javax.microedition.lcdui.Image loadingImage)
          A property for an image which will be display when an image is still loading.
 void setModeSwitchingEnabled(boolean modeSwitchingEnabled)
           
 void setPanEnabled(boolean panEnabled)
          A property indicating if the map should be pannable by the user using the mouse.
 void setPanSpeed(int panSpeed)
           
 void setProviderSwitchingEnabled(boolean providerSwitchingEnabled)
           
 void setRecenterOnDoubleClickEnabled(boolean recenterOnDoubleClickEnabled)
           
 void setRestrictOutsidePanning(boolean restrictOutsidePanning)
          A property indicating whether the user is restricted to pan over the viewport edges
 void setShowPanControls(boolean showPanControls)
           
 void setShowProviderControls(boolean showProviderControls)
           
 void setShowWaypoints(boolean showWaypoints)
           
 void setShowZoomSlider(boolean showZoomSlider)
           
 void setTileFactory(TileFactory factory)
          Set the current tile factory
 void setWaypointPainter(WaypointPainter waypointPainter)
          Use this method to customize waypoint drawing.
 void setWaypointSelectionListener(WaypointSelectionListener waypointSelectionListener)
           
 void setZoom(int zoom)
          Set the current zoom level and leaves the map centered on the same location as before.
 void setZoomCursorImage(javax.microedition.lcdui.Image zoomCursorImage)
           
 void setZoomSliderBottomImage(javax.microedition.lcdui.Image zoomSliderBottomImage)
           
 void setZoomSliderMiddleImage(javax.microedition.lcdui.Image zoomSliderMiddleImage)
           
 void setZoomSliderTopImage(javax.microedition.lcdui.Image zoomSliderTopImage)
           
 void showAllWaypoints()
          Recenters the map and changes the zoom so that all waypoints are visible
protected  void sizeChanged(int width, int height)
          Called when the map changes size, for example when the full screen mode is modified or when the user switches from portrait to landscape mode or vice versa
 void switchMode()
          This function switches to the next available mode for the current provider.
 void switchProvider()
          This function allows to switch to the next map provider and resets the mode to the first one available for the new provider.
 void toggleHelpBoxVisible()
          If help box is displayed, it gets hidden, and vice-versa
 void zoomIn()
          Increases the zoom level by one
 void zoomOut()
          Decreases the zoom level by one
 
Methods inherited from class javax.microedition.lcdui.Canvas
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, hideNotify, isDoubleBuffered, keyReleased, pointerReleased, repaint, repaint, serviceRepaints, setFullScreenMode, showNotify
 
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
 

Field Detail

KEY_ARROW_LEFT

public static final int KEY_ARROW_LEFT
Constant identifying the left button on the phone. It's not the same as Canvas.LEFT

See Also:
Constant Field Values

KEY_ARROW_RIGHT

public static final int KEY_ARROW_RIGHT
Constant identifying the right button on the phone. It's not the same as Canvas.RIGHT

See Also:
Constant Field Values

KEY_ARROW_UP

public static final int KEY_ARROW_UP
Constant identifying the up button on the phone. It's not the same as Canvas.UP

See Also:
Constant Field Values

KEY_ARROW_DOWN

public static final int KEY_ARROW_DOWN
Constant identifying the down button on the phone. It's not the same as Canvas.DOWN

See Also:
Constant Field Values

KEY_F_LEFT

public static final int KEY_F_LEFT
Constant identifying the left function button on most phones

See Also:
Constant Field Values

KEY_F_RIGHT

public static final int KEY_F_RIGHT
Constant identifying the right function button on most phones

See Also:
Constant Field Values

KEY_OK_BUTTON

public static final int KEY_OK_BUTTON
Constant identifying the validation button on most phones

See Also:
Constant Field Values

FUNCTION_NO_FUNCTION

public final org.epseelon.mobimap.MobiMap.Action FUNCTION_NO_FUNCTION
Function that corresponds to no function. Useful for unmapping a key.


FUNCTION_ZOOM_IN

public final org.epseelon.mobimap.MobiMap.Action FUNCTION_ZOOM_IN
Function to zoom in.


FUNCTION_ZOOM_OUT

public final org.epseelon.mobimap.MobiMap.Action FUNCTION_ZOOM_OUT
Function to zoom out.


FUNCTION_PREVIOUS_WAYPOINT

public final org.epseelon.mobimap.MobiMap.Action FUNCTION_PREVIOUS_WAYPOINT
Function to select the previous waypoint


FUNCTION_NEXT_WAYPOINT

public final org.epseelon.mobimap.MobiMap.Action FUNCTION_NEXT_WAYPOINT
Function to select the next waypoint


FUNCTION_PAN_LEFT

public final org.epseelon.mobimap.MobiMap.Action FUNCTION_PAN_LEFT
Function to pan the map on the left


FUNCTION_PAN_RIGHT

public final org.epseelon.mobimap.MobiMap.Action FUNCTION_PAN_RIGHT
Function to pan the map on the right


FUNCTION_PAN_UP

public final org.epseelon.mobimap.MobiMap.Action FUNCTION_PAN_UP
Function to pan the map up


FUNCTION_PAN_DOWN

public final org.epseelon.mobimap.MobiMap.Action FUNCTION_PAN_DOWN
Function to pan the map down


FUNCTION_SWITCH_PROVIDER

public final org.epseelon.mobimap.MobiMap.Action FUNCTION_SWITCH_PROVIDER
Function to switch the map data provider


FUNCTION_SWITCH_MODE

public final org.epseelon.mobimap.MobiMap.Action FUNCTION_SWITCH_MODE
Function to switch the map mode for the current provider


FUNCTION_HELP

public final org.epseelon.mobimap.MobiMap.Action FUNCTION_HELP
Function to display a key help


FUNCTION_WAYPOINT_DETAILS

public final org.epseelon.mobimap.MobiMap.Action FUNCTION_WAYPOINT_DETAILS
Function to display waypoint details


FUNCTION_DESELECT_WAYPOINT

public final org.epseelon.mobimap.MobiMap.Action FUNCTION_DESELECT_WAYPOINT
Function to deselect currently selected waypoint if any


IMAGE_EMPTY_TILE

public static final java.lang.String IMAGE_EMPTY_TILE
See Also:
Constant Field Values
Constructor Detail

MobiMap

public MobiMap()
Creates a new MobiMap with an empty tile factory and recenterOnClickEnabled set to false;

Method Detail

setKeyFunction

public void setKeyFunction(int key,
                           org.epseelon.mobimap.MobiMap.Action function)
Valid values for key include all constants starting with KEY_ Valid values for function include all constants starting with FUNCTION_

Parameters:
key - The key code that triggers the function
function - The function that will be run when this key is pressed

addRepeatedFunction

public void addRepeatedFunction(org.epseelon.mobimap.MobiMap.Action function)
Parameters:
function - Function that should be repeated when a key mapped on it is kept pressed

removeRepeatedFunction

public void removeRepeatedFunction(org.epseelon.mobimap.MobiMap.Action function)
Parameters:
function - Function that should not be repeated when a key mapped on it is kept pressed

switchProvider

public final void switchProvider()
This function allows to switch to the next map provider and resets the mode to the first one available for the new provider. It goes back to the first provider after the last one.


isProviderSwitchingEnabled

public boolean isProviderSwitchingEnabled()
Returns:
true if it's possible to switch provider, false otherwise

setProviderSwitchingEnabled

public void setProviderSwitchingEnabled(boolean providerSwitchingEnabled)
Parameters:
providerSwitchingEnabled - true if it's possible to switch provider, false otherwise

switchMode

public final void switchMode()
This function switches to the next available mode for the current provider. It goes back to the first mode when the last one is reached.


isModeSwitchingEnabled

public boolean isModeSwitchingEnabled()
Returns:
true if it's possible to switch map mode, false otherwise

setModeSwitchingEnabled

public void setModeSwitchingEnabled(boolean modeSwitchingEnabled)
Parameters:
modeSwitchingEnabled - true if it's possible to switch map mode, false otherwise

getAddressLocation

public final GeoPosition getAddressLocation()
Gets the current address location of the map. This property does not change when the user pans the map. This property is bound.

Returns:
the current map location (address)

setAddressLocation

public final void setAddressLocation(GeoPosition addressLocation)
Gets the current address location of the map

Parameters:
addressLocation - the new address location

setCenter

public final void setCenter(Point2D center)
Sets the new center of the map in pixel coordinates.

Parameters:
center - the new center of the map in pixel coordinates

getCenter

public final Point2D getCenter()
Gets the current pixel center of the map. This point is in the global bitmap coordinate system, not as lat/longs.

Returns:
the current center of the map as a pixel value

setZoom

public final void setZoom(int zoom)
Set the current zoom level and leaves the map centered on the same location as before.

If zoom is greater than the maximum zoom level for the current provider, it is set to the maximum zoom level for the current provider.

If zoom is less that the minimum zoom level for the current provider, it is set to the minimum zoom level for the current provider.

Parameters:
zoom - the new zoom level

getZoom

public final int getZoom()
Gets the current zoom level

Returns:
the current zoom level

isPanEnabled

public final boolean isPanEnabled()
A property indicating if the map should be pannable by the user using the mouse.

Returns:
property value

setPanEnabled

public final void setPanEnabled(boolean panEnabled)
A property indicating if the map should be pannable by the user using the mouse.

Parameters:
panEnabled - new property value

isRecenterOnDoubleClickEnabled

public final boolean isRecenterOnDoubleClickEnabled()
Returns:
true if the map should recenter on a point when this point is double-clicked, false otherwise

setRecenterOnDoubleClickEnabled

public final void setRecenterOnDoubleClickEnabled(boolean recenterOnDoubleClickEnabled)
Parameters:
recenterOnDoubleClickEnabled - true if the map should recenter on a point when this point is double-clicked, false otherwise

getTileFactory

public final TileFactory getTileFactory()
Get the current factory

Returns:
the current property value

setTileFactory

public final void setTileFactory(TileFactory factory)
Set the current tile factory

Parameters:
factory - the new property value

getLoadingImage

public final javax.microedition.lcdui.Image getLoadingImage()
A property for an image which will be display when an image is still loading.

Returns:
the current property value

setLoadingImage

public final void setLoadingImage(javax.microedition.lcdui.Image loadingImage)
A property for an image which will be display when an image is still loading.

Parameters:
loadingImage - the new property value

isRestrictOutsidePanning

public boolean isRestrictOutsidePanning()
A property indicating whether the user is restricted to pan over the viewport edges

Returns:
true if the user can pan over the edges, false otherwise

setRestrictOutsidePanning

public void setRestrictOutsidePanning(boolean restrictOutsidePanning)
A property indicating whether the user is restricted to pan over the viewport edges

Parameters:
restrictOutsidePanning - true if the user can pan over the edges, false otherwise

isHorizontalWrapped

public boolean isHorizontalWrapped()
Indicates whether tiles start again on the left when we arrive on the right edge of the map, and vice-versa

Returns:
true if tiles wrap horizontally, false otherwise

setHorizontalWrapped

public void setHorizontalWrapped(boolean horizontalWrapped)
Indicates whether tiles start again on the left when we arrive on the right edge of the map, and vice-versa

Parameters:
horizontalWrapped - true if tiles wrap horizontally, false otherwise

isShowZoomSlider

public boolean isShowZoomSlider()
Returns:
true if the zoom slider is to be displayed over the map, false otherwise

setShowZoomSlider

public void setShowZoomSlider(boolean showZoomSlider)
Parameters:
showZoomSlider - true if you want the zoom slider to be displayed on top of the map, false otherwise

isShowPanControls

public boolean isShowPanControls()
Returns:
true if pan controls should be displayed on screen, false otherwise

setShowPanControls

public void setShowPanControls(boolean showPanControls)
Parameters:
showPanControls - true if pan controls should be displayed on screen, false otherwise

isShowProviderControls

public boolean isShowProviderControls()
Returns:
true if provider controls should be displayed on screen, false otherwise

setShowProviderControls

public void setShowProviderControls(boolean showProviderControls)
Parameters:
showProviderControls - true if provider controls should be displayed on screen, false otherwise

addWaypoint

public void addWaypoint(Waypoint waypoint)
Adds a waypoint to be displayed over the map

Parameters:
waypoint - Waypoint to be displayed on top of the map

removeWaypoint

public void removeWaypoint(Waypoint waypoint)
Removes a waypoint from the list of points to be displayed over the map

Parameters:
waypoint - Waypoint that should not be displayed anymore

getWaypoints

public Waypoint[] getWaypoints()
Returns:
the list of waypoints currently displayed on the maps

selectNextWaypoint

public void selectNextWaypoint()
Switches waypoint selection to the next one. If no waypoint was selected, the first one gets selected. If the last one was selected, the first one gets selected. If there is no waypoint on this map, then nothing happens.


selectPreviousWaypoint

public void selectPreviousWaypoint()
Switches waypoint selection to the next one. If no waypoint was selected, the first one gets selected. If the first one was selected, the last one gets selected. If there is no waypoint on this map, then nothing happens.


getSelectedWaypoint

public Waypoint getSelectedWaypoint()
Returns:
The currently selected waypoint if any, otherwise null.

deselectWaypoint

public void deselectWaypoint()
Deselects the selected waypoint if any


isShowWaypoints

public boolean isShowWaypoints()
Returns:
true if waypoints should be displayed, false otherwise

setShowWaypoints

public void setShowWaypoints(boolean showWaypoints)
Parameters:
showWaypoints - true if waypoints should be displayed, false otherwise

setWaypointPainter

public void setWaypointPainter(WaypointPainter waypointPainter)
Use this method to customize waypoint drawing. The default painter paints a simple spot for all waypoints and adds an info window for the selected waypoint.

Parameters:
waypointPainter - The custom painter responsible for drawing waypoints.

setWaypointSelectionListener

public void setWaypointSelectionListener(WaypointSelectionListener waypointSelectionListener)
Parameters:
waypointSelectionListener - A waypoint selection event handler whose waypointSelected method will be called when a waypoint is selected and the OK button is clicked

fireWaypointSelected

protected void fireWaypointSelected()
Triggers the action associated with waypoint selected


setZoomSliderTopImage

public void setZoomSliderTopImage(javax.microedition.lcdui.Image zoomSliderTopImage)
Parameters:
zoomSliderTopImage - the image at the top of the zoom slider

setZoomSliderBottomImage

public void setZoomSliderBottomImage(javax.microedition.lcdui.Image zoomSliderBottomImage)
Parameters:
zoomSliderBottomImage - the image at the bottom of the zoom slider

setZoomSliderMiddleImage

public void setZoomSliderMiddleImage(javax.microedition.lcdui.Image zoomSliderMiddleImage)
Parameters:
zoomSliderMiddleImage - The image that is repeated to draw the middle area of the slider

setZoomCursorImage

public void setZoomCursorImage(javax.microedition.lcdui.Image zoomCursorImage)
Parameters:
zoomCursorImage - The image for the zoom cursor

isZooming

public boolean isZooming()
Returns:
true if the user is currently dragging the zoom cursor, false otherwise

getNextWaypointImage

public javax.microedition.lcdui.Image getNextWaypointImage()
Returns:
Next waypoint icon

getBarBackgroundImage

public javax.microedition.lcdui.Image getBarBackgroundImage()

setBarBackgroundImage

public void setBarBackgroundImage(javax.microedition.lcdui.Image barBackgroundImage)

isHelpBoxVisible

public boolean isHelpBoxVisible()
Returns:
true if help box is visible, false otherwise

setHelpBoxVisible

public void setHelpBoxVisible(boolean helpBoxVisible)
Parameters:
helpBoxVisible - true to show the help box, false to hide it

toggleHelpBoxVisible

public void toggleHelpBoxVisible()
If help box is displayed, it gets hidden, and vice-versa


getPanSpeed

public int getPanSpeed()
Returns:
Number of pixels to move the map of on each call of the pan function

setPanSpeed

public void setPanSpeed(int panSpeed)
Parameters:
panSpeed - Number of pixels to move the map of on each call of the pan function

paint

protected void paint(javax.microedition.lcdui.Graphics graphics)
Specified by:
paint in class javax.microedition.lcdui.Canvas

drawHelpBox

protected void drawHelpBox(javax.microedition.lcdui.Graphics graphics)

setCenterPosition

public void setCenterPosition(GeoPosition geoPosition)
A property indicating the center position of the map

Parameters:
geoPosition - the new property value

getCenterPosition

public GeoPosition getCenterPosition()
A property indicating the center position of the map

Returns:
the current center position

getViewportBounds

public Rectangle getViewportBounds()
Returns the bounds of the viewport in pixels. This can be used to transform points into the world bitmap coordinate space.

Returns:
the bounds in pixels of the "view" of this map

drawMapTiles

protected void drawMapTiles(javax.microedition.lcdui.Graphics g,
                            int zoom,
                            Rectangle viewportBounds)
Draw the map tiles. This method is for implementation use only.

Parameters:
g - Graphics
zoom - zoom level to draw at
viewportBounds - the bounds to draw within

drawWaypoints

protected void drawWaypoints(javax.microedition.lcdui.Graphics g,
                             int zoom,
                             Rectangle viewportBounds)
This function iterates over all the waypoints and draws them using the WaypointPainter that is set up on this map.

Parameters:
g - The graphics context to draw to
zoom - The current zoom level
viewportBounds - The bounds of the screen related to the whole map in pixels

drawProviderControls

protected void drawProviderControls(javax.microedition.lcdui.Graphics g)

drawZoomControls

protected void drawZoomControls(javax.microedition.lcdui.Graphics g,
                                int zoom)

drawNavigationControls

protected void drawNavigationControls(javax.microedition.lcdui.Graphics g,
                                      Rectangle viewportBounds)

drawPanControls

protected void drawPanControls(javax.microedition.lcdui.Graphics g)

recenterToAddressLocation

public void recenterToAddressLocation()
Re-centers the map to have the current address location be at the center of the map, accounting for the map's width and height.


keyPressed

public void keyPressed(int keyCode)
Used to pan using the arrow keys

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

keyRepeated

public void keyRepeated(int keyCode)
This method is called when a key is pressed

Overrides:
keyRepeated in class javax.microedition.lcdui.Canvas
Parameters:
keyCode -

zoomIn

public void zoomIn()
Increases the zoom level by one


zoomOut

public void zoomOut()
Decreases the zoom level by one


calculateZoomFrom

public void calculateZoomFrom(GeoPosition[] positions)
Calculates a zoom level so that all points in the specified set will be visible on screen. This is useful if you have a bunch of points in an area like a city and you want to zoom out so that the entire city and it's points are visible without panning.

Parameters:
positions - A set of GeoPositions to calculate the new zoom from

pan

public void pan(int dx,
                int dy)
Move the map by dx pixels horizontally and dy pixels vertically.

Parameters:
dx - Number of clicks to move horizontally
dy - Number of clicks to move vertically

showAllWaypoints

public void showAllWaypoints()
Recenters the map and changes the zoom so that all waypoints are visible


sizeChanged

protected void sizeChanged(int width,
                           int height)
Called when the map changes size, for example when the full screen mode is modified or when the user switches from portrait to landscape mode or vice versa

Overrides:
sizeChanged in class javax.microedition.lcdui.Canvas
Parameters:
width - new width of the map
height - new height of the map

pointerPressed

protected void pointerPressed(int x,
                              int y)
Only available on touch screen devices. Makes it possible to handle both recentering on double click and touch panning

Overrides:
pointerPressed in class javax.microedition.lcdui.Canvas
Parameters:
x - abscissa where the map has been touched
y - ordinate where the map has been touched

pointerDragged

protected void pointerDragged(int x,
                              int y)
Only available on touch screen devices. Makes it possible to handle touch panning.

Overrides:
pointerDragged in class javax.microedition.lcdui.Canvas
Parameters:
x - abscissa where the map was dragged
y - ordinate where the map was dragged

isDoubleClick

protected boolean isDoubleClick(int x,
                                int y)
Utility method to determine if a pointerPressed call corresponds to a double click, based on DOUBLE_CLICK_TIME and DOUBLE_CLICK_DISTANCE.

Parameters:
x - abscissa of the last click
y - ordinate of the last click
Returns:
true if the click corresponds to the second click in a double click, false otherwise

recenterMap

protected void recenterMap(int x,
                           int y)
Recenters the map on given x and y. It is used to recenter the map on double click when enabled.

Parameters:
x - abscissa to recenter the map on
y - ordinated to recenter the map on


Copyright © 2008 Epseelon. All Rights Reserved.