com.AndrewGray.geoutils
Class MapPoint

java.lang.Object
  |
  +--com.AndrewGray.geoutils.MapPoint

public final class MapPoint
extends java.lang.Object

Class defines methods to manipulate points on a true mercator map using either their x,y (mercator) coordinates or LatLong.

By adding the new MapPoint to the MercatorMap any map resize operation will trigger the recomputation of the MapPoint's x,y coordinates. This addition may be done at creation time by using the ADD_TO_MAP option, or later via MercatorMap.addMapPoint(MapPoint). This recomputation may also be performed at any time via a call to MapPoint.reset();

Disclaimer & Warranty
The software is supplied as-is. No warranty, or statement of fitness of purpose is given.

All emphasis is on the user to verify values. In particular, this software should not be used for safety critical applications such as navigation, aeronautics, etc.

In obtaining this software you agree that liability of the copyright holder for damages, including any general, special, incidental or consequential damages arising out of the use or inability to use the software be limited to the purchase cost thereof. This includes but is not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a failure of the software to operate with any other software, even if such holder or other party has been advised of the possibility of such damages.

Copyright © 2004 by Andrew Gray

Author:
Andrew Gray
See Also:
MercatorMap.addMapPoint(MapPoint), MercatorMap

Field Summary
static int ADD_TO_MAP
          Constructor option flag indicating that this point should be added to the MercatorMap
static int NONE
          Constructor option flag when no setup options are required.
 
Constructor Summary
MapPoint(MercatorMap mercator)
          Create a new undefined MapPoint given the specified MercatorMap without adding it to the map.
MapPoint(MercatorMap mercator, int options)
          Create a new undefined MapPoint given the specified MercatorMap.
MapPoint(MercatorMap mercator, LatLong ll)
          Create a new MapPoint at the specified LatLong and given the specified MercatorMap.
MapPoint(MercatorMap mercator, LatLong ll, int options)
          Create a new MapPoint at the specified LatLong and given the specified MercatorMap.
MapPoint(MercatorMap mercator, java.awt.Point p)
          Create a new MapPoint at the specified x,y coordinate and given the specified MercatorMap.
MapPoint(MercatorMap mercator, java.awt.Point p, int options)
          Create a new MapPoint at the specified x,y coordinate and given the specified MercatorMap.
 
Method Summary
 void clear()
          clear this MapPoint back to undefined status
 boolean equalTo(MapPoint p)
          check whether this MapPoint represents the same point on the map as another.
 LatLong getLatLong()
          Get the LatLong of this MapPoint
 java.lang.String getLatLongRawString()
          return String representation of lat/long.
 java.awt.Point getPoint()
          get the x,y coordinates of this point
 java.lang.String getString()
          get the comment string associated with this MapPoint
 int getX()
          Get the x coordinate of this MapPoint
 int getY()
          Get the y coordinate of this MapPoint
 boolean isSet()
          Check whether this MapPoint is currently set
 void reset()
          recompute this MapPoint x,y coordinates based upon its LatLong.
 void set(LatLong ll)
          Set this MapPoint given its LatLong
 void set(java.awt.Point p)
          Set this MapPoint given its x,y mercator coordinates
 void set(java.lang.String raw)
          Set this map point given the raw string as produced by getLatLongRawString.
 void setString(java.lang.String s)
          set the comment string associated with this MapPoint
 java.lang.String toString()
          Produce a human readable representation of this MapPoint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ADD_TO_MAP

public static final int ADD_TO_MAP
Constructor option flag indicating that this point should be added to the MercatorMap

NONE

public static final int NONE
Constructor option flag when no setup options are required. This is the default for constructors without an option argument
Constructor Detail

MapPoint

public MapPoint(MercatorMap mercator)
Create a new undefined MapPoint given the specified MercatorMap without adding it to the map.
Parameters:
mercator - the MercatorMap on which to base this point
See Also:
MercatorMap.addMapPoint(MapPoint)

MapPoint

public MapPoint(MercatorMap mercator,
                int options)
Create a new undefined MapPoint given the specified MercatorMap.
Parameters:
mercator - the MercatorMap on which to base this point
options - which options should be used when creating this point.
See Also:
ADD_TO_MAP, NONE

MapPoint

public MapPoint(MercatorMap mercator,
                LatLong ll,
                int options)
Create a new MapPoint at the specified LatLong and given the specified MercatorMap.
Parameters:
mercator - the MercatorMap on which to base this point
ll - the LatLong to create this MapPoint at.
options - which options should be used when creating this point.
See Also:
ADD_TO_MAP, NONE

MapPoint

public MapPoint(MercatorMap mercator,
                LatLong ll)
Create a new MapPoint at the specified LatLong and given the specified MercatorMap.
Parameters:
mercator - the MercatorMap on which to base this point
ll - the LatLong to create this MapPoint at.

MapPoint

public MapPoint(MercatorMap mercator,
                java.awt.Point p,
                int options)
Create a new MapPoint at the specified x,y coordinate and given the specified MercatorMap.
Parameters:
mercator - the MercatorMap on which to base this point
p - the x,y coordinates to create this MapPoint at.
options - which options should be used when creating this point.
See Also:
ADD_TO_MAP, NONE

MapPoint

public MapPoint(MercatorMap mercator,
                java.awt.Point p)
Create a new MapPoint at the specified x,y coordinate and given the specified MercatorMap.
Parameters:
mercator - the MercatorMap on which to base this point
p - the x,y coordinates to create this MapPoint at.
Method Detail

equalTo

public boolean equalTo(MapPoint p)
check whether this MapPoint represents the same point on the map as another.
Parameters:
p - the other point to compare to
Returns:
true if the two points are on the same point of the map.

set

public final void set(java.awt.Point p)
Set this MapPoint given its x,y mercator coordinates
Parameters:
p - the Point to set this MapPoint to.

set

public final void set(LatLong ll)
Set this MapPoint given its LatLong
Parameters:
ll - the LatLong to set this point to.

set

public final void set(java.lang.String raw)

Set this map point given the raw string as produced by getLatLongRawString.

Parameters:
raw - the raw string as output by getLatLongRawString
Throws:
java.lang.IllegalArgumentException - if the supplied String was in the wrong format

reset

public final void reset()
recompute this MapPoint x,y coordinates based upon its LatLong. This is typically called if the MercatorMap that the point is based on changes after point is set. MercatorMap calls this method on all currently defined mappoints upon any resize operation.

clear

public final void clear()
clear this MapPoint back to undefined status

isSet

public final boolean isSet()
Check whether this MapPoint is currently set
Returns:
true if this MapPoint is currently set

getPoint

public final java.awt.Point getPoint()
get the x,y coordinates of this point
Returns:
the x,y coords of this MapPoint

getX

public final int getX()
Get the x coordinate of this MapPoint
Returns:
the x coordinate of this MapPoint

getY

public final int getY()
Get the y coordinate of this MapPoint
Returns:
the y coordinate of this MapPoint

getLatLong

public final LatLong getLatLong()
Get the LatLong of this MapPoint
Returns:
the LatLong of this point

getLatLongRawString

public java.lang.String getLatLongRawString()
return String representation of lat/long. Intended for external storage purposes

setString

public final void setString(java.lang.String s)
set the comment string associated with this MapPoint
Parameters:
the - new comment

getString

public final java.lang.String getString()
get the comment string associated with this MapPoint
Returns:
the comment string

toString

public final java.lang.String toString()
Produce a human readable representation of this MapPoint. Intended for diagnostic purposes
Overrides:
toString in class java.lang.Object
Returns:
a vagually human readable string representing this MapPoint