public class CoordinateConverter
extends java.lang.Object
| Constructor and Description |
|---|
CoordinateConverter(int screenWidth,
int screenHeight,
double centerX,
double centerY,
double mapWidth)
The default constructor of the coordinate convertor.
|
| Modifier and Type | Method and Description |
|---|---|
double |
dxScreenToMap(int dx)
Converts an x distance from the screen reference to the map reference (the only difference with
xScreenToMap is that it does not take into account the origin of the map reference.
|
double |
dyScreenToMap(int dy)
Converts a y distance from the screen reference to the map reference (the only difference with
yScreenToMap is that it does not take into account the origin of the map reference.
|
int |
xMapToScreen(double x)
Converts an x coordinate from the map reference to the screen reference
|
double |
xScreenToMap(int x)
Converts an x coordinate from the screen reference to the map reference
|
int |
yMapToScreen(double y)
Converts a y coordinate from the map reference to the screen reference
|
double |
yScreenToMap(int y)
Converts a y coordinate from the screen reference to the map reference
|
public CoordinateConverter(int screenWidth,
int screenHeight,
double centerX,
double centerY,
double mapWidth)
screenWidth - the screen widthscreenHeight - the screen heightcenterX - the x coordinate of the map center.centerY - the y coordinate of the map center.mapWidth - the map width (the map height is fixed to mapWidth × screenHeight / screenWidth, provided that
we do not want the map to be deformed by the transformation).public int xMapToScreen(double x)
x - the x coordinate in the map reference to convert.public int yMapToScreen(double y)
y - the y coordinate in the map reference to convert.public double xScreenToMap(int x)
x - the x coordinate in the screen reference to convert.public double yScreenToMap(int y)
y - the y coordinate in the screen reference to convert.public double dxScreenToMap(int dx)
dx - the distance to convert (in the screen reference)public double dyScreenToMap(int dy)
dy - the distance to convert (in the screen reference)