|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.eightmotions.map.MapDisplay
public class MapDisplay
This is the main interface to display a Map from Google...
The basic usage is quite simple. Just create a mapCanvas and display it...
Extended usage include usage of marker ( element of type Marker)
In the following example, a canvas is created with two markers,
and the display is centered around it...
MIDP1.1 version
mapCanvas c=new mapCanvas();
c.listPlaces.addElement(new Marker(-37.12 , 2.12 ));
c.listPlaces.addElement(new Marker(-35.12 , 4.12 ));
c.recenterMapAroundSel();
| Field Summary | |
|---|---|
Marker |
currentSel
This is the currently selected location... |
Track |
curSavedTrack
|
static javax.microedition.lcdui.Font |
fontm
|
protected int |
height
|
int |
id
User id in server base...Do not use it directly... |
static java.util.Vector |
listOfMaps
|
javax.microedition.lcdui.List |
listOfMapsScreen
|
java.util.Vector |
listPlaces
List of places to display // |
boolean |
m_autoPositionningEnabeld
True is map follow the last GPS position automatically... |
boolean |
m_autoTrack
if true indicate that the map is automatically centered to the last GPS position |
boolean |
m_displayCenterArrow
True to display a square in the center of the screen... |
boolean |
m_displaySize
true if display the scale size marker when repainting the screen. |
boolean |
m_drawConsumption
|
boolean |
m_drawLon
True if the latitude and longitude needs to be displayed |
Marker |
m_gpsMarker
If not null, this Marker is used to display last gps position. |
int[] |
m_gpsSegments
Used by GPS positionning.... |
oneGPSPos |
m_lastLocation
last |
java.util.Vector |
m_listMyPlaces
The list of user places (MyPlaces) draw on top of the screen in green... |
boolean |
m_modeShortkey
|
java.lang.String |
m_moreInfo
|
boolean |
m_pause
true if you want to pause the record, during track recording... |
boolean |
m_record
boolean that tell if we are recording (true) or not the current GPS path... |
int[] |
m_segments
The segments to be displayed if any. |
static int |
m_state
|
boolean |
m_useResampledImages
This mode enable resampled image when zooming in This might be CPU costly and can be disabeld. |
boolean |
m_useUSMetrics
true is use metric are used, false for meters (default) |
static int |
MAX_ZOOM
|
protected java.lang.String[] |
menus
|
protected int |
offx
|
protected int |
offy
|
protected int |
px
|
protected int |
py
|
protected static int |
size
|
protected static int |
sizeScr
|
static int |
ST_MOVE_PIN
|
static int |
ST_NORMAL
internal states ... for now, do not use them directly |
static int |
ST_ZOOM
|
javax.microedition.lcdui.Canvas |
theTarget
|
Marker |
wayPoint
Current waypoint (or null if no way point). |
protected int |
width
|
| Constructor Summary | |
|---|---|
MapDisplay()
Constructor of the canvas. |
|
MapDisplay(javax.microedition.lcdui.Canvas target)
|
|
| Method Summary | |
|---|---|
void |
addCommand(javax.microedition.lcdui.Command inCmd)
|
void |
addListener(MapDisplayListener inListener)
Set the listener to be called when the fire is pressed on a selected item... |
static void |
addMap(MapOverlay ov)
|
protected void |
checkMove()
|
void |
clear()
Remove all markers, segments, etc.... |
void |
commandAction(javax.microedition.lcdui.Command a,
javax.microedition.lcdui.Displayable d)
|
java.lang.String |
convertDisToString(int inDist)
Convert a distance into a string. |
static float |
convLat(int fromY)
|
static float |
convLon(int fromX)
Concert a pixel position into a Latitude Usfull for on-screen operation... |
void |
displayTrack(Track track,
boolean doRecenter)
Display a track on the map. |
void |
drawArrow(javax.microedition.lcdui.Graphics g,
oneGPSPos pos,
int x,
int y,
int col)
|
void |
drawBottomIndicators(javax.microedition.lcdui.Graphics g,
int posy)
|
void |
drawDirectiontoWayPoint(javax.microedition.lcdui.Graphics g)
Draw the arrow who represent the direction to the current waypoint from the current visible area |
protected void |
drawInfo(javax.microedition.lcdui.Graphics g,
java.lang.String s,
int px,
int py,
int col,
int bcol)
|
void |
drawSegment(javax.microedition.lcdui.Graphics g,
int[] segment,
int lpx,
int lpy,
int div,
int color)
Draw a segement on screen...Usually you don't need to use this directly ase ou should set up the variable m_segment, but could be usefull for some experiementations |
void |
drawString(javax.microedition.lcdui.Graphics g,
java.lang.String toDisp,
int x,
int y)
Utility function to display a shadowed string.... |
void |
drawTopIndicators(javax.microedition.lcdui.Graphics g,
int posy)
|
float |
getAlt()
|
int |
getBufferSize()
|
javax.microedition.lcdui.Canvas |
getCanvas()
|
static java.lang.String |
getCoordAsString(boolean isLon,
float theVal,
boolean decimalMode)
Create a string from a coordinate value (lon/lat) in decimal or degree minut form... |
double |
getCourseToTarget()
Return the course from the current position to the current waypoint, -1 if no waypoint is currently selected... |
MapOverlay |
getCurMap()
Return the current mapping provider used (google,msn,ask) |
Track |
getCurrentTrack()
Return the current Track |
float |
getDir()
|
int |
getDist()
Give the distance from the current location to the current waypoint... |
int |
getDist(boolean doConvertInMeters)
|
int |
getHeight()
|
float |
getLat()
|
int |
getLatPy()
Return the current latitude (px) |
float |
getLon()
Provide current Longitude, in Float |
int |
getLonPx()
Return the current position, in pixels, of the center of the screen... |
static MapOverlay |
getMap(int idx)
|
MapOverlay |
getMapByName(java.lang.String inName)
|
java.lang.String[] |
getMenusItem()
|
boolean |
getModeProxy()
|
MapOverlay |
getOverlay()
|
int |
getScreenXFromLon(int inpx)
Get real screen position from pixel pos |
int |
getScreenYFromLat(int inpy)
get real screen position from pixel pos (lat) |
Marker |
getSelectedItem(javax.microedition.lcdui.Graphics g,
int inpx,
int inpy,
int zoom,
int dist,
boolean onlyRepaint)
|
int |
getSize(int inOff)
Return the size (in meter) of an element defined in pixel in the current view |
float |
getSpeed()
|
int |
getWidth()
|
int |
getZoom()
Provide current Zoom Factor 0 is the minimum, MAX_ZOOM is the maximum... |
void |
goTo(Marker place)
A variant of previous method, with a location. |
void |
goTo(java.lang.String inPlace)
Goto a specific location |
void |
gotoLonLat(float lon,
float lat)
|
void |
gotoLonLat(float lon,
float lat,
int zoom)
|
void |
gotoLonLat(java.lang.Float lon,
java.lang.Float lat,
int zoom)
Move the map to a specific location |
void |
iconDownloaded(Marker theLoc)
|
void |
imageLoaded(BufferImage ima)
|
void |
init()
Initialise the map ... |
boolean |
isTrackDisplayed(Track track)
Return true if the track given as a parameter is currently displayed on screen |
void |
keyPressed(int keyCode)
|
void |
keyPressedImpl(int keyCode)
Provide default behavior of the canvas: up,down,right,left move the canvas fire switch from map to zoom if no location is selected fire generate an event to the external listener if a location is selected GAME_A and GAME_B increase/decrease zoom factor GAME_C and GAME_D go to next marker |
void |
keyRepeated(int keyCode)
|
java.lang.String |
locateURL(java.lang.String theUrl)
Transform an URL in a "located" URL, by checking the following carcharcter, and replacing then with the specific value: ! |
boolean |
onMenuSelected(int idx)
|
void |
paint(javax.microedition.lcdui.Graphics g)
* * Repaint the screen....The repaint process use the buffer thread Note that various adaptation to screen size are made.... |
void |
paintGPSPos(javax.microedition.lcdui.Graphics g,
oneGPSPos pos,
int inpx,
int inpy,
int w,
int h,
int zoom)
|
void |
paintIcons(javax.microedition.lcdui.Graphics g)
Function calld on touchScreen handsets to disraw icons |
protected void |
paintMenu(javax.microedition.lcdui.Graphics g,
java.lang.String[] menu)
|
void |
pointerDragged(int x,
int y)
|
void |
pointerPressed(int x,
int y)
|
static double |
realDist(float inLat,
float inLon,
Marker toMark)
|
void |
recenterMapAroundSel()
Recenter and rescale the map, in a way that all places are visibles...Usefull to set initial setting |
void |
recenterMapAroundSel(int percentage)
Equivalent to recenterMapAroundSel but with a user defined percentage of visibility For instanve, 80 means that there is 20 percent of margin of visibility. |
void |
removeCommand(javax.microedition.lcdui.Command inCmd)
|
void |
removeListener(MapDisplayListener inListener)
|
static void |
removeMap(MapOverlay ov)
|
void |
removeTrack(Track track)
Remove the track given as a paramter from the list of currently displayed track |
void |
repaint()
|
void |
run()
|
void |
saveRecords()
|
void |
selNewMap()
|
boolean |
selNext(int dir)
|
void |
setBufferSize(int inSize)
|
void |
setClipRect(int inMinx,
int inMiny,
int inWidth,
int inHeight)
|
void |
setCommandListener(javax.microedition.lcdui.CommandListener inListener)
|
void |
setCurMap(MapOverlay inCurrent)
|
void |
setExtendedMenu(ExtendedMenu m)
The "extended menu" is the one displayed when you press the * key. |
void |
setInfoOnScreen(java.lang.String inInfo)
|
void |
setLoc(oneGPSPos newLoc)
|
void |
setMapProvider(int idx,
MapOverlay provider)
|
void |
setMode(int inMode)
|
void |
setModeProxy(boolean useProxy)
|
void |
setOverlay(MapOverlay inOverlay)
|
protected void |
setSelectedLoc(Marker loc)
|
void |
setTileSize(int inSize)
Set the size of the tiles. |
void |
setZoom(int inZoom)
Change the zoom factor... |
void |
sizeChanged(int w,
int h)
|
void |
stop()
|
void |
stopZooming()
|
static int |
xFromLon(float inLon)
Convert a Float in longitude to the full pixel number in "google map" coordinate, at the maximum zoom factor level (to get the equivalent at any zoom level, divide by (1< |
static int |
yFromLat(float inLat)
Same for latitude |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int offx
protected int offy
protected int width
protected int height
public int[] m_segments
public int[] m_gpsSegments
public Marker currentSel
public java.util.Vector listPlaces
public java.util.Vector m_listMyPlaces
protected int px
protected int py
protected static final int size
protected static int sizeScr
public boolean m_drawLon
public boolean m_displayCenterArrow
public boolean m_displaySize
public boolean m_useUSMetrics
public oneGPSPos m_lastLocation
public Marker m_gpsMarker
public boolean m_autoPositionningEnabeld
public boolean m_useResampledImages
public Marker wayPoint
public boolean m_modeShortkey
public boolean m_autoTrack
public boolean m_record
public boolean m_pause
public static javax.microedition.lcdui.Font fontm
public static final int ST_NORMAL
public static final int ST_ZOOM
public static final int ST_MOVE_PIN
public static int m_state
public Track curSavedTrack
public java.lang.String m_moreInfo
public boolean m_drawConsumption
public int id
public javax.microedition.lcdui.Canvas theTarget
public static final int MAX_ZOOM
protected java.lang.String[] menus
public javax.microedition.lcdui.List listOfMapsScreen
public static java.util.Vector listOfMaps
| Constructor Detail |
|---|
public MapDisplay()
public MapDisplay(javax.microedition.lcdui.Canvas target)
| Method Detail |
|---|
public int getWidth()
public int getHeight()
public javax.microedition.lcdui.Canvas getCanvas()
public void repaint()
public void addCommand(javax.microedition.lcdui.Command inCmd)
public void removeCommand(javax.microedition.lcdui.Command inCmd)
public void setCommandListener(javax.microedition.lcdui.CommandListener inListener)
public void setExtendedMenu(ExtendedMenu m)
public void init()
public int getLonPx()
public int getLatPy()
getLonPxpublic int getScreenXFromLon(int inpx)
px -
public int getScreenYFromLat(int inpy)
py -
public void setClipRect(int inMinx,
int inMiny,
int inWidth,
int inHeight)
public int getZoom()
public void setZoom(int inZoom)
inZoom - : the new zoom factor, between 0 and MAX_ZOOM included.public int getBufferSize()
public void setTileSize(int inSize)
public void setMode(int inMode)
public void setModeProxy(boolean useProxy)
public boolean getModeProxy()
public void setBufferSize(int inSize)
public void setOverlay(MapOverlay inOverlay)
public MapOverlay getOverlay()
public void run()
run in interface java.lang.Runnablepublic void stop()
public void clear()
public Marker getSelectedItem(javax.microedition.lcdui.Graphics g,
int inpx,
int inpy,
int zoom,
int dist,
boolean onlyRepaint)
public void sizeChanged(int w,
int h)
public void paint(javax.microedition.lcdui.Graphics g)
paint in interface BaseCanvas
public void drawTopIndicators(javax.microedition.lcdui.Graphics g,
int posy)
public void drawBottomIndicators(javax.microedition.lcdui.Graphics g,
int posy)
public int getSize(int inOff)
inPixelWidth -
public static double realDist(float inLat,
float inLon,
Marker toMark)
public void drawSegment(javax.microedition.lcdui.Graphics g,
int[] segment,
int lpx,
int lpy,
int div,
int color)
g - segment - lpx - lpy - div - color -
protected void drawInfo(javax.microedition.lcdui.Graphics g,
java.lang.String s,
int px,
int py,
int col,
int bcol)
public static java.lang.String getCoordAsString(boolean isLon,
float theVal,
boolean decimalMode)
isLon - theVal - decimalMode -
public int getDist()
public int getDist(boolean doConvertInMeters)
public double getCourseToTarget()
public java.lang.String convertDisToString(int inDist)
inDist -
public void drawDirectiontoWayPoint(javax.microedition.lcdui.Graphics g)
g -
protected void paintMenu(javax.microedition.lcdui.Graphics g,
java.lang.String[] menu)
public java.lang.String[] getMenusItem()
getMenusItem in interface ExtendedMenupublic boolean onMenuSelected(int idx)
onMenuSelected in interface ExtendedMenupublic void recenterMapAroundSel()
public void recenterMapAroundSel(int percentage)
percentage - Define margins (100=no margin, 80 means 20% of margin)
public void drawString(javax.microedition.lcdui.Graphics g,
java.lang.String toDisp,
int x,
int y)
g - Graphics displaytoDisp - String to be displayedx - Location on screeny - public void goTo(java.lang.String inPlace)
inPlace - contains the location in the form longitute latitude zoom_factor satmode
Example:
goTo("-122.2 37.1 10 true");
will display the satellite map of -122.2,37.1 with a zoom
factor of 10 and in statellite mode (false for street mode)public void goTo(Marker place)
place - public static int xFromLon(float inLon)
inLon - the longitude in Float
public static int yFromLat(float inLat)
inLat -
public void gotoLonLat(java.lang.Float lon,
java.lang.Float lat,
int zoom)
lon - lat - zoom - 0 is maximum factor, 16 is minimumisSatellite - true if display satellite maps, false for stree map
public void gotoLonLat(float lon,
float lat)
public void gotoLonLat(float lon,
float lat,
int zoom)
public float getLon()
public static float convLon(int fromX)
fromX - pixel position (maximum zoom factor)
public float getLat()
public float getSpeed()
public float getDir()
public float getAlt()
public static float convLat(int fromY)
fromY - pixel
public boolean selNext(int dir)
public void setInfoOnScreen(java.lang.String inInfo)
public void paintIcons(javax.microedition.lcdui.Graphics g)
public void pointerPressed(int x,
int y)
pointerPressed in interface BaseCanvasprotected void checkMove()
protected void setSelectedLoc(Marker loc)
public void pointerDragged(int x,
int y)
pointerDragged in interface BaseCanvaspublic void keyRepeated(int keyCode)
keyRepeated in interface BaseCanvaspublic void keyPressed(int keyCode)
keyPressed in interface BaseCanvaspublic void keyPressedImpl(int keyCode)
Canvas.keyPressed(int)public void stopZooming()
public MapOverlay getCurMap()
public void setCurMap(MapOverlay inCurrent)
public void addListener(MapDisplayListener inListener)
inListener - public void removeListener(MapDisplayListener inListener)
public void iconDownloaded(Marker theLoc)
iconDownloaded in interface MarkerListener
public void drawArrow(javax.microedition.lcdui.Graphics g,
oneGPSPos pos,
int x,
int y,
int col)
public void paintGPSPos(javax.microedition.lcdui.Graphics g,
oneGPSPos pos,
int inpx,
int inpy,
int w,
int h,
int zoom)
public void setLoc(oneGPSPos newLoc)
public void saveRecords()
public void imageLoaded(BufferImage ima)
imageLoaded in interface BufferImageListener
public void displayTrack(Track track,
boolean doRecenter)
track: - th track to be displayeddoRecenter - true if we need to recenter the view around the content of the trackpublic boolean isTrackDisplayed(Track track)
public Track getCurrentTrack()
public void removeTrack(Track track)
public java.lang.String locateURL(java.lang.String theUrl)
public MapOverlay getMapByName(java.lang.String inName)
public void selNewMap()
public void setMapProvider(int idx,
MapOverlay provider)
idx - : index in the list of map providerprovider - : a MapOverlay object
public void commandAction(javax.microedition.lcdui.Command a,
javax.microedition.lcdui.Displayable d)
commandAction in interface javax.microedition.lcdui.CommandListenerpublic static void addMap(MapOverlay ov)
public static void removeMap(MapOverlay ov)
public static MapOverlay getMap(int idx)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||