|
||||||||||
| 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
javax.microedition.lcdui.game.GameCanvas
net.landspurg.map.MapCanvas
public class MapCanvas
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 oneLoc)
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 oneLoc(-37.12 , 2.12 ));
c.listPlaces.addElement(new oneLoc(-35.12 , 4.12 ));
c.recenterMapAroundSel();
| Field Summary | |
|---|---|
OneLoc |
currentSel
This is the currently selected location... |
protected int |
height
|
int |
id
User id in server base...Do not use it directly... |
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 |
protected static int |
m_curSat
|
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 |
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_modeSat
Current display mode. |
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) |
protected java.lang.String[] |
menus
|
protected int |
offx
|
protected int |
offy
|
protected int |
px
|
protected int |
py
|
static int |
SAT_ASK
|
static int |
SAT_GOOGLE
|
static int |
SAT_MSN
|
static int |
SAT_YAHOO
|
protected static int |
size
|
protected static int |
sizeScr
|
static int |
ST_MOVE_PIN
|
static int |
ST_NORMAL
|
static int |
ST_ZOOM
|
OneLoc |
wayPoint
Current waypoint (or null if no way point). |
protected int |
width
|
protected int |
zoom
|
| Fields inherited from class javax.microedition.lcdui.game.GameCanvas |
|---|
DOWN_PRESSED, FIRE_PRESSED, GAME_A_PRESSED, GAME_B_PRESSED, GAME_C_PRESSED, GAME_D_PRESSED, LEFT_PRESSED, RIGHT_PRESSED, UP_PRESSED |
| 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()
Constructor of the canvas. |
|
| Method Summary | |
|---|---|
boolean |
changeSatMode()
Switching between satellite/mapping mode.... |
protected void |
checkMove()
|
void |
clear()
Remove all markers, segments, etc.... |
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.... |
float |
getAlt()
|
int |
getBufferSize()
|
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... |
int |
getCurSat()
Return the current mapping provider used (google,msn,ask) |
float |
getDir()
|
int |
getDist()
Give the distance from the current location to the current waypoint... |
int |
getDist(boolean doConvertInMeters)
|
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... |
boolean |
getModeProxy()
|
OneLoc |
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 |
getZoom()
Provide current Zoom Factor 0 is the maximum, 17 is the minimum... |
void |
goTo(OneLoc 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,
int zoom,
boolean isSatellite)
|
void |
gotoLonLat(java.lang.Float lon,
java.lang.Float lat,
int zoom,
boolean isSatellite)
Move the map to a specific location |
void |
iconDownloaded(OneLoc theLoc)
|
void |
imageLoaded(BufferImage ima)
|
void |
init()
Initialise the map canvas thread Must be called at least one to enable the loading of the picture. |
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: ! |
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)
|
protected void |
paintMenu(javax.microedition.lcdui.Graphics g,
java.lang.String[] menu)
|
protected void |
pointerDragged(int x,
int y)
|
protected void |
pointerPressed(int x,
int y)
|
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 |
removeTrack(Track track)
Remove the track given as a paramter from the list of currently displayed track |
void |
run()
|
void |
saveRecords()
|
boolean |
selNext(int dir)
|
void |
setBufferSize(int inSize)
|
void |
setClipRect(int inMinx,
int inMiny,
int inWidth,
int inHeight)
|
void |
setCurSat(int inNumSat)
|
void |
setInfoOnScreen(java.lang.String inInfo)
|
void |
setListener(MapCanvasListener inListener)
Set the listener to be called when the fire is pressed on a selected item... |
void |
setLoc(oneGPSPos newLoc)
|
void |
setMode(int mode)
|
void |
setModeProxy(boolean useProxy)
|
void |
setOverlay(MapCustomOverlay inOverlay)
|
protected void |
setSelectedLoc(OneLoc 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 javax.microedition.lcdui.game.GameCanvas |
|---|
flushGraphics, flushGraphics, getGraphics, getKeyStates |
| 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 |
|---|
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 OneLoc 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
protected int zoom
public boolean m_modeSat
public boolean m_drawLon
public boolean m_displayCenterArrow
public boolean m_displaySize
public boolean m_useUSMetrics
public static final int SAT_GOOGLE
public static final int SAT_MSN
public static final int SAT_ASK
public static final int SAT_YAHOO
protected static int m_curSat
public oneGPSPos m_lastLocation
public boolean m_autoPositionningEnabeld
public boolean m_useResampledImages
public OneLoc wayPoint
public boolean m_modeShortkey
public boolean m_autoTrack
public boolean m_record
public boolean m_pause
public static final int ST_NORMAL
public static final int ST_ZOOM
public static final int ST_MOVE_PIN
public static int m_state
protected java.lang.String[] menus
public java.lang.String m_moreInfo
public boolean m_drawConsumption
public int id
| Constructor Detail |
|---|
public MapCanvas()
| Method Detail |
|---|
public void init()
public int getLonPx()
public int getLatPy()
getLonPx
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 17 included.public int getBufferSize()
public void setTileSize(int inSize)
public void setModeProxy(boolean useProxy)
public boolean getModeProxy()
public void setBufferSize(int inSize)
public void setOverlay(MapCustomOverlay inOverlay)
public void run()
run in interface java.lang.Runnablepublic void stop()
public void clear()
public OneLoc getSelectedItem(javax.microedition.lcdui.Graphics g,
int inpx,
int inpy,
int zoom,
int dist,
boolean onlyRepaint)
public void sizeChanged(int w,
int h)
sizeChanged in class javax.microedition.lcdui.Canvaspublic void paint(javax.microedition.lcdui.Graphics g)
paint in class javax.microedition.lcdui.game.GameCanvaspublic void setMode(int mode)
public void drawBottomIndicators(javax.microedition.lcdui.Graphics g,
int posy)
public int getSize(int inOff)
inPixelWidth -
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 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(OneLoc 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,
boolean isSatellite)
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,
int zoom,
boolean isSatellite)
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)
protected void pointerPressed(int x,
int y)
pointerPressed in class javax.microedition.lcdui.Canvasprotected void checkMove()
protected void setSelectedLoc(OneLoc loc)
protected void pointerDragged(int x,
int y)
pointerDragged in class javax.microedition.lcdui.Canvaspublic void keyRepeated(int keyCode)
keyRepeated in class javax.microedition.lcdui.Canvaspublic void keyPressed(int keyCode)
keyPressed in class javax.microedition.lcdui.Canvaspublic void keyPressedImpl(int keyCode)
Canvas.keyPressed(int)public void stopZooming()
public boolean changeSatMode()
public int getCurSat()
public void setCurSat(int inNumSat)
public void setListener(MapCanvasListener inListener)
inListener - public void iconDownloaded(OneLoc theLoc)
iconDownloaded in interface OneLocListener
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 rtecetner the view around the content of the trackpublic boolean isTrackDisplayed(Track track)
public void removeTrack(Track track)
public java.lang.String locateURL(java.lang.String theUrl)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||