|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.maryanovsky.map.client.projections.AbstractProjection
public abstract class AbstractProjection
A useful base class for Projection
implementations.
It divides the
responsibility of handling the projection itself and the zoom magnification
to two different objects. The projection at the native zoom is delegated to
the subclass using the abstract
fromPixelToLatLngImpl(double, double)
and
fromLatLngToPixelImpl(LatLng)
methods. The zoom magnification, on
the other hand, is delegated to a ZoomStrategy
. An implementation
of that interface defines the magnification between each two zooms.
Additionally, this class takes care of implementing the
Projection.getWrapSize(int)
method.
Field Summary | |
---|---|
protected boolean |
longitudeWraps
Whether the map wraps around the X (longitude) axis. |
protected int |
nativeZoom
The "native" zoom, at which world size is specified. |
protected double |
worldHeight
The height of the world, in pixels, at the native zoom. |
protected double |
worldWidth
The width of the world, in pixels, at the native zoom. |
protected ZoomStrategy |
zoomStrategy
The zoom magnification strategy. |
Constructor Summary | |
---|---|
AbstractProjection(ZoomStrategy zoomStrategy,
int nativeZoom,
SizeView worldSize,
boolean longitudeWraps)
Creates a new AbstractProjection with the specified arguments. |
Method Summary | |
---|---|
Point |
fromLatLngToPixel(LatLng latLng,
int zoom)
Delegates to fromLatLngToPixelImpl(LatLng) and then converts the
results to the actual zoom before returning. |
protected abstract double[] |
fromLatLngToPixelImpl(LatLng latLng)
Converts from latitude-longitude to pixel coordinates at the native zoom. |
LatLng |
fromPixelToLatLng(PointView pixel,
int zoom)
Converts the pixel coordinates to the native zoom and then delegates to fromPixelToLatLngImpl(double, double) . |
protected abstract LatLng |
fromPixelToLatLngImpl(double x,
double y)
Converts from pixel coordinates to latitude-longitude at the native zoom. |
SizeView |
getWrapSize(int zoom)
Delegates to getWrapSizeImpl(int) and caches the results. |
protected SizeView |
getWrapSizeImpl(int zoom)
Returns the wrap size at the specified zoom. |
double |
getZoomMagnification(int startZoom,
int endZoom)
Delegates to the ZoomStrategy given to us in the
constructor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final int nativeZoom
protected final double worldWidth
protected final double worldHeight
protected final boolean longitudeWraps
protected final ZoomStrategy zoomStrategy
Constructor Detail |
---|
public AbstractProjection(ZoomStrategy zoomStrategy, int nativeZoom, SizeView worldSize, boolean longitudeWraps)
AbstractProjection
with the specified arguments.
zoomStrategy
- The strategy that defines zoom magnification for us.nativeZoom
- The "native" zoom. There is no special meaning to this
zoom other than that worldSize
is given at that zoom.worldSize
- The size of the world, in pixels, at the native zoom.longitudeWraps
- Whether the map wraps around the X (longitude)
axis.Method Detail |
---|
public Point fromLatLngToPixel(LatLng latLng, int zoom)
fromLatLngToPixelImpl(LatLng)
and then converts the
results to the actual zoom before returning.
fromLatLngToPixel
in interface Projection
public LatLng fromPixelToLatLng(PointView pixel, int zoom)
fromPixelToLatLngImpl(double, double)
.
fromPixelToLatLng
in interface Projection
protected abstract double[] fromLatLngToPixelImpl(LatLng latLng)
[0, worldWidth or worldHeight]
.
protected abstract LatLng fromPixelToLatLngImpl(double x, double y)
[0, worldWidth or worldHeight]
.
public SizeView getWrapSize(int zoom)
getWrapSizeImpl(int)
and caches the results.
getWrapSize
in interface Projection
protected SizeView getWrapSizeImpl(int zoom)
public double getZoomMagnification(int startZoom, int endZoom)
ZoomStrategy
given to us in the
constructor.
getZoomMagnification
in interface Projection
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |