|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.microedition.lcdui.Displayable
javax.microedition.lcdui.Canvas
org.epseelon.mobimap.MobiMap
public class MobiMap
A tile oriented map component that can easily be used with tile sources on the web like Google and Yahoo maps.
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.
| 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 |
|---|
public static final int KEY_ARROW_LEFT
public static final int KEY_ARROW_RIGHT
public static final int KEY_ARROW_UP
public static final int KEY_ARROW_DOWN
public static final int KEY_F_LEFT
public static final int KEY_F_RIGHT
public static final int KEY_OK_BUTTON
public final org.epseelon.mobimap.MobiMap.Action FUNCTION_NO_FUNCTION
public final org.epseelon.mobimap.MobiMap.Action FUNCTION_ZOOM_IN
public final org.epseelon.mobimap.MobiMap.Action FUNCTION_ZOOM_OUT
public final org.epseelon.mobimap.MobiMap.Action FUNCTION_PREVIOUS_WAYPOINT
public final org.epseelon.mobimap.MobiMap.Action FUNCTION_NEXT_WAYPOINT
public final org.epseelon.mobimap.MobiMap.Action FUNCTION_PAN_LEFT
public final org.epseelon.mobimap.MobiMap.Action FUNCTION_PAN_RIGHT
public final org.epseelon.mobimap.MobiMap.Action FUNCTION_PAN_UP
public final org.epseelon.mobimap.MobiMap.Action FUNCTION_PAN_DOWN
public final org.epseelon.mobimap.MobiMap.Action FUNCTION_SWITCH_PROVIDER
public final org.epseelon.mobimap.MobiMap.Action FUNCTION_SWITCH_MODE
public final org.epseelon.mobimap.MobiMap.Action FUNCTION_HELP
public final org.epseelon.mobimap.MobiMap.Action FUNCTION_WAYPOINT_DETAILS
public final org.epseelon.mobimap.MobiMap.Action FUNCTION_DESELECT_WAYPOINT
public static final java.lang.String IMAGE_EMPTY_TILE
| Constructor Detail |
|---|
public MobiMap()
| Method Detail |
|---|
public void setKeyFunction(int key,
org.epseelon.mobimap.MobiMap.Action function)
key - The key code that triggers the functionfunction - The function that will be run when this key is pressedpublic void addRepeatedFunction(org.epseelon.mobimap.MobiMap.Action function)
function - Function that should be repeated when a key mapped
on it is kept pressedpublic void removeRepeatedFunction(org.epseelon.mobimap.MobiMap.Action function)
function - Function that should not be repeated when a key mapped
on it is kept pressedpublic final void switchProvider()
public boolean isProviderSwitchingEnabled()
public void setProviderSwitchingEnabled(boolean providerSwitchingEnabled)
providerSwitchingEnabled - true if it's possible to switch provider, false otherwisepublic final void switchMode()
public boolean isModeSwitchingEnabled()
public void setModeSwitchingEnabled(boolean modeSwitchingEnabled)
modeSwitchingEnabled - true if it's possible to switch map mode, false otherwisepublic final GeoPosition getAddressLocation()
public final void setAddressLocation(GeoPosition addressLocation)
addressLocation - the new address locationpublic final void setCenter(Point2D center)
center - the new center of the map in pixel coordinatespublic final Point2D getCenter()
public final void setZoom(int zoom)
zoom - the new zoom levelpublic final int getZoom()
public final boolean isPanEnabled()
public final void setPanEnabled(boolean panEnabled)
panEnabled - new property valuepublic final boolean isRecenterOnDoubleClickEnabled()
public final void setRecenterOnDoubleClickEnabled(boolean recenterOnDoubleClickEnabled)
recenterOnDoubleClickEnabled - true if the map should recenter on a point when this point is
double-clicked, false otherwisepublic final TileFactory getTileFactory()
public final void setTileFactory(TileFactory factory)
factory - the new property valuepublic final javax.microedition.lcdui.Image getLoadingImage()
public final void setLoadingImage(javax.microedition.lcdui.Image loadingImage)
loadingImage - the new property valuepublic boolean isRestrictOutsidePanning()
public void setRestrictOutsidePanning(boolean restrictOutsidePanning)
restrictOutsidePanning - true if the user can pan over the edges, false otherwisepublic boolean isHorizontalWrapped()
public void setHorizontalWrapped(boolean horizontalWrapped)
horizontalWrapped - true if tiles wrap horizontally, false otherwisepublic boolean isShowZoomSlider()
public void setShowZoomSlider(boolean showZoomSlider)
showZoomSlider - true if you want the zoom slider to be displayed on top of the map, false otherwisepublic boolean isShowPanControls()
public void setShowPanControls(boolean showPanControls)
showPanControls - true if pan controls should be displayed on screen, false otherwisepublic boolean isShowProviderControls()
public void setShowProviderControls(boolean showProviderControls)
showProviderControls - true if provider controls should be displayed on screen, false otherwisepublic void addWaypoint(Waypoint waypoint)
waypoint - Waypoint to be displayed on top of the mappublic void removeWaypoint(Waypoint waypoint)
waypoint - Waypoint that should not be displayed anymorepublic Waypoint[] getWaypoints()
public void selectNextWaypoint()
public void selectPreviousWaypoint()
public Waypoint getSelectedWaypoint()
public void deselectWaypoint()
public boolean isShowWaypoints()
public void setShowWaypoints(boolean showWaypoints)
showWaypoints - true if waypoints should be displayed, false otherwisepublic void setWaypointPainter(WaypointPainter waypointPainter)
waypointPainter - The custom painter responsible for drawing waypoints.public void setWaypointSelectionListener(WaypointSelectionListener waypointSelectionListener)
waypointSelectionListener - A waypoint selection event handler whose waypointSelected method
will be called when a waypoint is selected and the OK button is clickedprotected void fireWaypointSelected()
public void setZoomSliderTopImage(javax.microedition.lcdui.Image zoomSliderTopImage)
zoomSliderTopImage - the image at the top of the zoom sliderpublic void setZoomSliderBottomImage(javax.microedition.lcdui.Image zoomSliderBottomImage)
zoomSliderBottomImage - the image at the bottom of the zoom sliderpublic void setZoomSliderMiddleImage(javax.microedition.lcdui.Image zoomSliderMiddleImage)
zoomSliderMiddleImage - The image that is repeated to draw the middle area of the sliderpublic void setZoomCursorImage(javax.microedition.lcdui.Image zoomCursorImage)
zoomCursorImage - The image for the zoom cursorpublic boolean isZooming()
public javax.microedition.lcdui.Image getNextWaypointImage()
public javax.microedition.lcdui.Image getBarBackgroundImage()
public void setBarBackgroundImage(javax.microedition.lcdui.Image barBackgroundImage)
public boolean isHelpBoxVisible()
public void setHelpBoxVisible(boolean helpBoxVisible)
helpBoxVisible - true to show the help box, false to hide itpublic void toggleHelpBoxVisible()
public int getPanSpeed()
public void setPanSpeed(int panSpeed)
panSpeed - Number of pixels to move the map of on each call of the pan functionprotected void paint(javax.microedition.lcdui.Graphics graphics)
paint in class javax.microedition.lcdui.Canvasprotected void drawHelpBox(javax.microedition.lcdui.Graphics graphics)
public void setCenterPosition(GeoPosition geoPosition)
geoPosition - the new property valuepublic GeoPosition getCenterPosition()
public Rectangle getViewportBounds()
protected void drawMapTiles(javax.microedition.lcdui.Graphics g,
int zoom,
Rectangle viewportBounds)
g - Graphicszoom - zoom level to draw atviewportBounds - the bounds to draw within
protected void drawWaypoints(javax.microedition.lcdui.Graphics g,
int zoom,
Rectangle viewportBounds)
g - The graphics context to draw tozoom - The current zoom levelviewportBounds - The bounds of the screen related to the whole map in pixelsprotected void drawProviderControls(javax.microedition.lcdui.Graphics g)
protected void drawZoomControls(javax.microedition.lcdui.Graphics g,
int zoom)
protected void drawNavigationControls(javax.microedition.lcdui.Graphics g,
Rectangle viewportBounds)
protected void drawPanControls(javax.microedition.lcdui.Graphics g)
public void recenterToAddressLocation()
public void keyPressed(int keyCode)
keyPressed in class javax.microedition.lcdui.Canvaspublic void keyRepeated(int keyCode)
keyRepeated in class javax.microedition.lcdui.CanvaskeyCode - public void zoomIn()
public void zoomOut()
public void calculateZoomFrom(GeoPosition[] positions)
positions - A set of GeoPositions to calculate the new zoom from
public void pan(int dx,
int dy)
dx - Number of clicks to move horizontallydy - Number of clicks to move verticallypublic void showAllWaypoints()
protected void sizeChanged(int width,
int height)
sizeChanged in class javax.microedition.lcdui.Canvaswidth - new width of the mapheight - new height of the map
protected void pointerPressed(int x,
int y)
pointerPressed in class javax.microedition.lcdui.Canvasx - abscissa where the map has been touchedy - ordinate where the map has been touched
protected void pointerDragged(int x,
int y)
pointerDragged in class javax.microedition.lcdui.Canvasx - abscissa where the map was draggedy - ordinate where the map was dragged
protected boolean isDoubleClick(int x,
int y)
x - abscissa of the last clicky - ordinate of the last click
protected void recenterMap(int x,
int y)
x - abscissa to recenter the map ony - ordinated to recenter the map on
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||