com.eightmotions.map
Class Marker

java.lang.Object
  extended by com.eightmotions.map.Marker
All Implemented Interfaces:
java.lang.Runnable

public class Marker
extends java.lang.Object
implements java.lang.Runnable

Manage a location in the map...
Typically, could be displayed as a marker, but is linked to several other functions

Each element can have a name, a description, and address, and eventually an icon.
Be carefull that the icon feature could take a lot of memory...

This class contains several public elements that can be modified (no getter and setter). But if you change the long/lat value directly, you must call "validate()" function.

Typical use is to create some Marker element, add them to the canvas in the listPlace vector and call recenterAroundSel()


Field Summary
 java.lang.String address
          Adress of this element.
static MarkerStyle defaultStyle
           
 java.lang.String description
          Description, but not the address.
 javax.microedition.lcdui.Image iconImage
           
 java.lang.String iconName
          URL of an icon to be displayed.
 int ima_offx
           
 int ima_offy
           
 java.lang.String imageName
           
 boolean isModeSat
           
 int m_category
           
 int m_col
           
 int m_colForeground
           
static int m_defaultHeight
           
static int m_defaultWidth
          Default width of the info window when the loc is selected This is recomputed at initialisation by the MapDisplay, but can be chaned later on.
 float m_lat
           
 float m_lon
           
 MarkerListener m_theListener
           
 int m_type
           
 java.lang.String name
          Name of this element.
 java.lang.String phoneNum
          Phone number of this element.
 int px
           
 int py
           
 MarkerStyle style
           
 java.lang.String URL
           
 int zoom
           
 
Constructor Summary
Marker()
           
Marker(float lon, float lat)
           
Marker(java.lang.String name, float lon, float lat, int preferredZoom, boolean isModeSat)
           
 
Method Summary
 Marker clone(float inlon, float inlat)
           
 void copyFrom(Marker in)
           
static Marker createFromString(java.lang.String in)
          Factory to create a location object from a string representation.
 int distFrom(int inpx, int inpy, int inzoom)
           
static int distFrom(int lp1x, int lp1y, int inpx, int inpy, int inzoom)
           
 boolean equals(java.lang.Object obj)
           
 void fireLoaded()
           
 java.util.Enumeration getKeys()
           
 java.lang.Object getValue(java.lang.String name)
           
 int getZoom()
           
 void init(java.lang.String name, float lon, float lat, int preferredZoom, boolean isModeSat)
           
 void paint(javax.microedition.lcdui.Graphics g, MapDisplay m)
          Paint the marker.
 void paintFull(javax.microedition.lcdui.Graphics g, MapDisplay m)
          Draw the infomrations when the icon has been selected....
 void run()
           
 java.lang.String saveToString()
          Put the content of the location into a string.
 void setListener(MarkerListener inListener)
          Set the listenr that will be called when an icon will be loaded.
 void setLonLat(float inLon, float inLat)
           
 void setPxPy(int inPx, int inPy)
          Set the location to a new postion in world pixel coordinates
 void setValue(java.lang.String name, java.lang.Object val)
           
 boolean validate()
          Validate the changes in lat/lon.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_lon

public float m_lon

m_lat

public float m_lat

px

public int px

py

public int py

m_defaultWidth

public static int m_defaultWidth
Default width of the info window when the loc is selected This is recomputed at initialisation by the MapDisplay, but can be chaned later on.


m_defaultHeight

public static int m_defaultHeight

name

public java.lang.String name
Name of this element. Will be displayed on screen.


description

public java.lang.String description
Description, but not the address. Will be displayed on screen if possible


phoneNum

public java.lang.String phoneNum
Phone number of this element. Won't be displayed on screen. can be null


address

public java.lang.String address
Adress of this element. USed by search functions. Displayed on screen


iconName

public java.lang.String iconName
URL of an icon to be displayed. Use PNG image if possible and avoid to use it "too much" due to limited memory...


iconImage

public javax.microedition.lcdui.Image iconImage

imageName

public java.lang.String imageName

m_theListener

public MarkerListener m_theListener

zoom

public int zoom

URL

public java.lang.String URL

isModeSat

public boolean isModeSat

ima_offx

public int ima_offx

ima_offy

public int ima_offy

m_category

public int m_category

m_col

public int m_col

m_colForeground

public int m_colForeground

m_type

public int m_type

style

public MarkerStyle style

defaultStyle

public static MarkerStyle defaultStyle
Constructor Detail

Marker

public Marker()

Marker

public Marker(java.lang.String name,
              float lon,
              float lat,
              int preferredZoom,
              boolean isModeSat)

Marker

public Marker(float lon,
              float lat)
Method Detail

init

public void init(java.lang.String name,
                 float lon,
                 float lat,
                 int preferredZoom,
                 boolean isModeSat)

getZoom

public int getZoom()

distFrom

public int distFrom(int inpx,
                    int inpy,
                    int inzoom)

distFrom

public static int distFrom(int lp1x,
                           int lp1y,
                           int inpx,
                           int inpy,
                           int inzoom)

paint

public void paint(javax.microedition.lcdui.Graphics g,
                  MapDisplay m)
Paint the marker.
Note that inpx and inpy are specified in "absolute maximum pixel coordiante"=coordinate in pixel at zoom factor == 0

Parameters:
g -
inpx - Current position of the screen in full size.
inpy -
w - Width of the screen
h - Height of the screen
zoom - Zoom factor

setListener

public void setListener(MarkerListener inListener)
Set the listenr that will be called when an icon will be loaded.
The only things to do is usually to repaint the icon.

Parameters:
inListener -

fireLoaded

public void fireLoaded()

paintFull

public void paintFull(javax.microedition.lcdui.Graphics g,
                      MapDisplay m)
Draw the infomrations when the icon has been selected....

Parameters:
g - Graphics context
m - The map to be displayed in Note: if you want to do your own rendering, it's better to subclass MarkerStyle and assign this style to your marker

validate

public boolean validate()
Validate the changes in lat/lon.
You need to call this function if you've made a change in lat or lon float fields, and you want to reflect this change

Returns:
always return true for now

setLonLat

public void setLonLat(float inLon,
                      float inLat)

setPxPy

public void setPxPy(int inPx,
                    int inPy)
Set the location to a new postion in world pixel coordinates


createFromString

public static Marker createFromString(java.lang.String in)
Factory to create a location object from a string representation.
The string representation has been obtained from the "saveToString()" function.
Internally, it's just a single string with name/value attributes, sepereted with the '!' charcters, that why avoid to use this caractere in comments.

Parameters:
in - The string representation
Returns:
a location object created with this string.

setValue

public void setValue(java.lang.String name,
                     java.lang.Object val)

getValue

public java.lang.Object getValue(java.lang.String name)

getKeys

public java.util.Enumeration getKeys()

saveToString

public java.lang.String saveToString()
Put the content of the location into a string. Usually used to save a specific location in a file for instance.
The location can be recreated in the same state using createFromString()

Returns:

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

clone

public Marker clone(float inlon,
                    float inlat)

copyFrom

public void copyFrom(Marker in)

run

public void run()
Specified by:
run in interface java.lang.Runnable