jme3tools.navigation
Class MapModel2D

java.lang.Object
  extended by jme3tools.navigation.MapModel2D

public class MapModel2D
extends java.lang.Object

A representation of the actual map in terms of lat/long and x,y co-ordinates. The Map class contains various helper methods such as methods for determining the pixel positions for lat/long co-ordinates and vice versa.

Since:
1.0

Field Summary
static int DEFAULT_MAP_WIDTH_LONGITUDE
           
 
Constructor Summary
MapModel2D(int viewportWidth)
          Constructor
 
Method Summary
 void calculateMinutesPerPixel(double mapWidthInLongitude)
          Calculates the number of minutes per pixels using a given map width in longitude
 Position getCentre()
          Returns the Position centre of the map
 double getMetersPerPixel()
           
 double getMinutesPerPixel()
          Returns the number of minutes there are per pixel
 java.awt.Point getPixelCentre()
          Returns the pixel (x,y) centre of the map
 int getViewportPixelHeight()
          Returns the height of the viewport in pixels
 int getViewportPixelWidth()
          Returns the width of the viewport in pixels
 void setCentre(java.awt.Point p)
          Defines the centre of the map in pixels
 void setCentre(Position centre)
           
 void setMinutesPerPixel(double minutesPerPixel)
           
 void setViewportHeight(int viewportHeight)
           
 void setViewportWidth(int viewportWidth)
           
 void setXCentre(int xCentre)
          Sets the map's xCentre
 void setYCentre(int yCentre)
          Sets the map's yCentre
 java.awt.Point toPixel(Position position)
          Converts a latitude/longitude position into a pixel co-ordinate
 Position toPosition(java.awt.Point p)
          Converts a pixel position into a mercator position
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAP_WIDTH_LONGITUDE

public static final int DEFAULT_MAP_WIDTH_LONGITUDE
See Also:
Constant Field Values
Constructor Detail

MapModel2D

public MapModel2D(int viewportWidth)
Constructor

Parameters:
viewportWidth - the pixel width of the viewport (component) in which the map is displayed
Since:
1.0
Method Detail

getViewportPixelHeight

public int getViewportPixelHeight()
Returns the height of the viewport in pixels

Returns:
the height of the viewport in pixels
Since:
0.1

calculateMinutesPerPixel

public void calculateMinutesPerPixel(double mapWidthInLongitude)
Calculates the number of minutes per pixels using a given map width in longitude

Parameters:
mapWidthInLongitude -
Since:
1.0

getViewportPixelWidth

public int getViewportPixelWidth()
Returns the width of the viewport in pixels

Returns:
the width of the viewport in pixels
Since:
0.1

setViewportWidth

public void setViewportWidth(int viewportWidth)

setViewportHeight

public void setViewportHeight(int viewportHeight)

setCentre

public void setCentre(Position centre)

getMinutesPerPixel

public double getMinutesPerPixel()
Returns the number of minutes there are per pixel

Returns:
the number of minutes per pixel
Since:
1.0

getMetersPerPixel

public double getMetersPerPixel()

setMinutesPerPixel

public void setMinutesPerPixel(double minutesPerPixel)

toPixel

public java.awt.Point toPixel(Position position)
Converts a latitude/longitude position into a pixel co-ordinate

Parameters:
position - the position to convert
Returns:
Point a pixel co-ordinate
Since:
1.0

toPosition

public Position toPosition(java.awt.Point p)
Converts a pixel position into a mercator position

Parameters:
p - Point object that you wish to convert into longitude / latiude
Returns:
the converted Position object
Since:
1.0

setCentre

public void setCentre(java.awt.Point p)
Defines the centre of the map in pixels

Parameters:
p - Point object denoting the map's new centre
Since:
1.0

setXCentre

public void setXCentre(int xCentre)
Sets the map's xCentre

Parameters:
xCentre -
Since:
1.0

setYCentre

public void setYCentre(int yCentre)
Sets the map's yCentre

Parameters:
yCentre -
Since:
1.0

getPixelCentre

public java.awt.Point getPixelCentre()
Returns the pixel (x,y) centre of the map

Returns:
Point object marking the map's (x,y) centre
Since:
1.0

getCentre

public Position getCentre()
Returns the Position centre of the map

Returns:
Position object marking the map's (lat, long) centre
Since:
1.0