net.landspurg.map
Class OneLoc

java.lang.Object
  extended by net.landspurg.map.OneLoc
All Implemented Interfaces:
java.lang.Runnable

public class OneLoc
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 oneLoc element, add them to the canvas in the listPlace vector and call recenterAroundSel()


Field Summary
 java.lang.String address
          Adress of this element.
 java.lang.String description
          Description, but not the address.
static int ICON_CIRCLE
           
static int ICON_DIAMOND
          Specifiy a marker of "type" ICON_DIAMOND.
static int ICON_IMAGE
           
static int ICON_INVISIBLE
          The marker won't be displayed at all
static int ICON_LOC_PIN
          The standard marker, and the default one.
static int ICON_PHOTO
           
static int ICON_SMALL_PIN
          Display a small "pin"
 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 MapCanvas, but can be chaned later on.
 float m_lat
           
 float m_lon
           
 OneLocListener 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
           
 java.lang.String URL
           
 int zoom
           
 
Constructor Summary
OneLoc()
           
OneLoc(float lon, float lat)
           
OneLoc(java.lang.String name, float lon, float lat, int preferredZoom, boolean isModeSat)
           
 
Method Summary
 OneLoc clone(float inlon, float inlat)
           
static OneLoc createFromString(java.lang.String in)
          Factory to create a location object from a string representation.
 int distFrom(int inpx, int inpy, int inzoom)
           
 boolean equals(java.lang.Object obj)
           
 void fireLoaded()
           
 java.lang.Object getValue(java.lang.String name)
           
 void init(java.lang.String name, float lon, float lat, int preferredZoom, boolean isModeSat)
           
 void paint(javax.microedition.lcdui.Graphics g, int inpx, int inpy, int offx, int offy, int w, int h, int zoom)
          Paint the marker.
 void paintFull(javax.microedition.lcdui.Graphics g, int inpx, int inpy, int offx, int offy, int w, int h, int zoom)
          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 setIconImage(javax.microedition.lcdui.Image icon, int offX, int offY)
           
 void setListener(OneLocListener 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 MapCanvas, 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 OneLocListener 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

ICON_LOC_PIN

public static final int ICON_LOC_PIN
The standard marker, and the default one.

See Also:
Constant Field Values

ICON_SMALL_PIN

public static final int ICON_SMALL_PIN
Display a small "pin"

See Also:
Constant Field Values

ICON_INVISIBLE

public static final int ICON_INVISIBLE
The marker won't be displayed at all

See Also:
Constant Field Values

ICON_DIAMOND

public static final int ICON_DIAMOND
Specifiy a marker of "type" ICON_DIAMOND. Usually used for direction displays

See Also:
Constant Field Values

ICON_CIRCLE

public static final int ICON_CIRCLE
See Also:
Constant Field Values

ICON_IMAGE

public static final int ICON_IMAGE
See Also:
Constant Field Values

ICON_PHOTO

public static final int ICON_PHOTO
See Also:
Constant Field Values

m_type

public int m_type

m_col

public int m_col

m_colForeground

public int m_colForeground
Constructor Detail

OneLoc

public OneLoc()

OneLoc

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

OneLoc

public OneLoc(float lon,
              float lat)
Method Detail

init

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

distFrom

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

paint

public void paint(javax.microedition.lcdui.Graphics g,
                  int inpx,
                  int inpy,
                  int offx,
                  int offy,
                  int w,
                  int h,
                  int zoom)
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(OneLocListener 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()

setIconImage

public void setIconImage(javax.microedition.lcdui.Image icon,
                         int offX,
                         int offY)

paintFull

public void paintFull(javax.microedition.lcdui.Graphics g,
                      int inpx,
                      int inpy,
                      int offx,
                      int offy,
                      int w,
                      int h,
                      int zoom)
Draw the infomrations when the icon has been selected....

Parameters:
g -
inpx -
inpy -
offx: - offset of the visible area
offy: - offset of the visible area
w -
h -
zoom -

run

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

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 OneLoc 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)

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 OneLoc clone(float inlon,
                    float inlat)