|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.fhpotsdam.unfolding.UnfoldingMap
public class UnfoldingMap
An interactive map. Uses the MapDisplay, and handles hit test, active status, as well as all interactions such as panning, zooming, and rotating (with or without tweening). Acts as facade for the map interactions, e.g. using innerScale for zooming, and outerRotate for rotating.
Field Summary | |
---|---|
protected boolean |
active
Indicates whether this map is currently active. |
static boolean |
DEFAULT_TWEENING
UnfoldingMap do not use tweened animation by default. |
static int |
DEFAULT_ZOOM_LEVEL
The default zoom level of an UnfoldingMap shows the whole world. |
static java.lang.String |
GREETING_MESSAGE
|
protected java.lang.String |
id
The ID of this map. |
static org.apache.log4j.Logger |
log
|
AbstractMapDisplay |
mapDisplay
The display of the map. |
protected float |
maxPanningDistance
The maximum distance to the center location of the restricted pan area. |
float |
maxScale
The maximum scale. |
float |
minScale
The minimum scale. |
protected processing.core.PApplet |
p
The Processing applet. |
static Location |
PRIME_MERIDIAN_EQUATOR_LOCATION
|
protected Location |
restrictedPanLocation
The center location of the restricted pan area. |
static float |
SCALE_DELTA_IN
|
static float |
SCALE_DELTA_OUT
|
Integrator |
scaleIntegrator
Tweens the scale. |
static int |
TILE_HEIGHT
The default tile height of 256px. |
static int |
TILE_WIDTH
The default tile width of 256px. |
Constructor Summary | |
---|---|
UnfoldingMap(processing.core.PApplet p)
Creates a new full canvas map with a generated ID. |
|
UnfoldingMap(processing.core.PApplet p,
AbstractMapProvider provider)
Creates a new full canvas map with tiles from the given provider. |
|
UnfoldingMap(processing.core.PApplet p,
float x,
float y,
float width,
float height)
Creates a new map with specific position and dimension. |
|
UnfoldingMap(processing.core.PApplet p,
float x,
float y,
float width,
float height,
AbstractMapProvider provider)
Creates a new map with specific position and dimension. |
|
UnfoldingMap(processing.core.PApplet p,
float x,
float y,
float width,
float height,
AbstractMapProvider provider,
java.lang.String renderer)
|
|
UnfoldingMap(processing.core.PApplet p,
float x,
float y,
float width,
float height,
java.lang.String renderer)
|
|
UnfoldingMap(processing.core.PApplet p,
java.lang.String id)
Creates a new full canvas map with the given ID. |
|
UnfoldingMap(processing.core.PApplet p,
java.lang.String id,
AbstractMapProvider provider)
Creates a new full canvas map with given ID, and with tiles from the given provider. |
|
UnfoldingMap(processing.core.PApplet p,
java.lang.String id,
float x,
float y,
float width,
float height)
Creates a new map with specific position and dimension. |
|
UnfoldingMap(processing.core.PApplet p,
java.lang.String id,
float x,
float y,
float width,
float height,
boolean useDistortion)
|
|
UnfoldingMap(processing.core.PApplet p,
java.lang.String id,
float x,
float y,
float width,
float height,
boolean useMask,
boolean useDistortion,
AbstractMapProvider provider)
|
|
UnfoldingMap(processing.core.PApplet p,
java.lang.String id,
float x,
float y,
float width,
float height,
boolean useMask,
boolean useDistortion,
AbstractMapProvider provider,
java.lang.String renderer)
Creates a new map with specific position and dimension. |
|
UnfoldingMap(processing.core.PApplet p,
java.lang.String id,
float x,
float y,
float width,
float height,
boolean useDistortion,
java.lang.String renderer)
|
|
UnfoldingMap(processing.core.PApplet p,
java.lang.String id,
float x,
float y,
float width,
float height,
java.lang.String renderer)
|
Method Summary | |
---|---|
protected void |
addInnerOffset(float dx,
float dy)
|
void |
addMarker(Marker marker)
Adds a marker to the map. |
void |
addMarkerManager(MarkerManager<Marker> markerManager)
Add a MarkerManager to the map. |
void |
addMarkers(java.util.List<Marker> markers)
Adds multiple markers to the map. |
void |
addMarkers(Marker... marker)
Adds one or multiple markers to the map. |
protected void |
addOffset(float dx,
float dy)
Moves the offset of the map. |
boolean |
allTilesLoaded()
Check whether all currently visible tiles have been loaded. |
void |
draw()
Updates and draws the map. |
protected static java.lang.String |
generateId()
|
Location |
getBottomRightBorder()
Returns the bottom right corner of the visible map. |
Location |
getCenter()
Returns the center location of the visible map. |
MarkerManager<Marker> |
getDefaultMarkerManager()
Returns the default MarkerManager, i.e. |
Marker |
getFirstHitMarker(float checkX,
float checkY)
Checks whether a marker got hit with the given screen coordinates. |
float |
getHeight()
Returns the height of this map. |
java.util.List<Marker> |
getHitMarker(float checkX,
float checkY)
Deprecated. Use getHitMarkers(float, float) instead. |
java.util.List<Marker> |
getHitMarkers(float checkX,
float checkY)
Checks whether multiple markers got hit with the given screen coordinates. |
java.lang.String |
getId()
Returns the ID of this map. |
MarkerManager<Marker> |
getLastMarkerManager()
Returns the lastly added MarkerManager. |
Location |
getLocation(float x,
float y)
Converts a position on the screen to a geographic location. |
Location |
getLocation(ScreenPosition screenPosition)
Converts a position on the screen to a geographic location. |
Location |
getLocationFromScreenPosition(float x,
float y)
Deprecated. |
MarkerManager<Marker> |
getMarkerManager(int index)
Returns the MarkerManager at the given index position. |
java.util.List<MarkerManager<Marker>> |
getMarkerManagerList()
|
java.util.List<Marker> |
getMarkers()
Gets markers of the map. |
static float |
getScaleFromZoom(float zoom)
Converts zoom to scale. |
ScreenPosition |
getScreenPosition(Location location)
Converts the geographic location to a position on the screen. |
float[] |
getScreenPositionFromLocation(Location location)
Deprecated. |
Location |
getTopLeftBorder()
Returns the top left corner of the visible map. |
float |
getWidth()
Returns the width of this map. |
float |
getZoom()
Gets the current zoom of the map. |
static float |
getZoomFromScale(double scale)
Converts scale to zoom. |
int |
getZoomLevel()
Gets the current zoom level of the map. |
static int |
getZoomLevelFromScale(double scale)
Converts scale to zoom level. |
void |
innerRotate(float angle)
Deprecated. Use rotate(float) instead. |
void |
innerScale(float scale)
|
boolean |
isActive()
Indicates whether this map is currently active. |
boolean |
isHit(float checkX,
float checkY)
Checks whether the given screen coordinates are on this Map. |
boolean |
isHit(ScreenPosition screenPosition)
Checks whether the given screen coordinates are on this Map. |
boolean |
isTweening()
Indicates whether the map currently animates between different states. |
void |
move(float x,
float y)
Moves the map to the given position. |
void |
move(ScreenPosition screenPosition)
Moves the map to the given ScreenPosition. |
void |
moveBy(float dx,
float dy)
Moves the map by the given screen coordinates. |
void |
onManipulation(MapEvent mapEvent)
Internal method to listens to mapDisplay events. |
void |
outerRotate(float angle)
Rotates the map container. |
protected void |
outerScale(float scale)
|
void |
pan(float x1,
float y1,
float x2,
float y2)
Pans from point1 to point 2, given in screen coordinates. |
void |
pan(Location fromLocation,
Location toLocation)
Pans from one location to another one. |
void |
pan(ScreenPosition from,
ScreenPosition to)
Pans between two ScreenPosition. |
void |
panBy(float dx,
float dy)
Pans by distance in screen coordinates. |
void |
panDown()
Pans one tile down. |
void |
panLeft()
Pans one tile to the left. |
protected void |
panObjectPositionToObjectCenter(float x,
float y)
Pans object center to given object position. |
void |
panRight()
Pans one tile to the right. |
void |
panTo(float x,
float y)
Pans to the given position. |
void |
panTo(Location location)
Pans to the given Location. |
void |
panTo(ScreenPosition screenPosition)
Pans to the given screen position. |
void |
panUp()
Pans one tile up. |
protected void |
prepareMapChangedMethod()
Internal method to call listening methods in your application for map changes. |
void |
removeMarkerManager(int i)
|
void |
removeMarkerManager(MarkerManager<Marker> markerManager)
|
void |
resetPanningRestriction()
Frees this map from any panning restriction. |
void |
rotate(float angle)
Rotates the map by given angle. |
void |
rotateTo(float angle)
Rotates the map to the given angle, that is it is rotated to the target angle. |
void |
setActive(boolean active)
Sets the active flag of this map. |
void |
setBackgroundColor(java.lang.Integer bgColor)
Sets the background color of this map. |
protected void |
setInnerOffset(float x,
float y)
|
protected void |
setInnerRotate(float angle)
|
void |
setInnerScale(float scale)
|
protected void |
setOffset(float x,
float y)
Sets the offset of the map. |
protected void |
setOuterRotate(float angle)
|
protected void |
setOuterScale(float scale)
|
void |
setPanningRestriction(Location location,
float maxPanningDistance)
Restricts the area this map can pan to in a radial fashion. |
void |
setScaleRange(float minScale,
float maxScale)
Sets the range of map scale factors. |
void |
setTweening(boolean tweening)
Sets the tweening flag, i.e. |
void |
setZoomRange(float minZoomLevel,
float maxZoomLevel)
Sets the range of map zoom levels. |
void |
switchTweening()
Switches the tweening flag. |
void |
updateMap()
Updates the integrators for tweening. |
void |
zoom(float scaleDelta)
Zooms in or out. |
void |
zoom(int levelDelta)
Deprecated. Replaced by zoomLevel(int) |
void |
zoomAndPanTo(float x,
float y,
int level)
Zooms in around position, and pans to it. |
void |
zoomAndPanTo(int zoomLevel,
Location location)
Zooms in around position, and pans to it. |
void |
zoomAndPanTo(int level,
ScreenPosition screenPosition)
Zooms in around position, and pans to it. |
void |
zoomAndPanTo(Location location,
int zoomLevel)
Deprecated. Use zoomAndPanTo(int, Location) . |
void |
zoomAndPanTo(ScreenPosition screenPosition,
int level)
Deprecated. Use zoomAndPanTo(int, ScreenPosition) . |
void |
zoomAndPanToFit(java.util.List<Location> locations)
|
void |
zoomIn()
Zooms into the map less than a full level. |
void |
zoomLevel(int levelDelta)
Zooms in or out one or more levels. |
void |
zoomLevelIn()
Zooms in a level. |
void |
zoomLevelOut()
Zooms out a level. |
void |
zoomOut()
Zooms out of the map less than a full level. |
void |
zoomTo(float zoom)
|
void |
zoomToFit(java.util.List<Location> locations)
|
void |
zoomToFit(Location[] boundingBox)
|
void |
zoomToLevel(int level)
Zooms to the given level. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String GREETING_MESSAGE
public static final float SCALE_DELTA_IN
public static final float SCALE_DELTA_OUT
public static final int TILE_WIDTH
public static final int TILE_HEIGHT
public static final boolean DEFAULT_TWEENING
setTweening(boolean)
to switch it on.
public static final Location PRIME_MERIDIAN_EQUATOR_LOCATION
public static final int DEFAULT_ZOOM_LEVEL
public float minScale
setZoomRange(float, float)
.
public float maxScale
setZoomRange(float, float)
.
protected Location restrictedPanLocation
protected float maxPanningDistance
public static org.apache.log4j.Logger log
protected processing.core.PApplet p
public AbstractMapDisplay mapDisplay
protected java.lang.String id
protected boolean active
public Integrator scaleIntegrator
Constructor Detail |
---|
public UnfoldingMap(processing.core.PApplet p, java.lang.String id)
p
- The main applet.id
- The ID of this map.public UnfoldingMap(processing.core.PApplet p)
p
- The main applet.public UnfoldingMap(processing.core.PApplet p, AbstractMapProvider provider)
p
- The main applet.provider
- The map tiles provider to use.public UnfoldingMap(processing.core.PApplet p, java.lang.String id, AbstractMapProvider provider)
p
- The main applet.id
- The ID of this map.provider
- The map tiles provider to use.public UnfoldingMap(processing.core.PApplet p, float x, float y, float width, float height)
p
- The main applet.x
- The x position of this map.y
- The y position of this map.width
- The width of this map.height
- The height of this map.public UnfoldingMap(processing.core.PApplet p, float x, float y, float width, float height, java.lang.String renderer)
public UnfoldingMap(processing.core.PApplet p, java.lang.String id, float x, float y, float width, float height)
p
- The main applet.id
- The ID of this map.x
- The x position of this map.y
- The y position of this map.width
- The width of this map.height
- The height of this map.public UnfoldingMap(processing.core.PApplet p, java.lang.String id, float x, float y, float width, float height, java.lang.String renderer)
public UnfoldingMap(processing.core.PApplet p, java.lang.String id, float x, float y, float width, float height, boolean useDistortion)
public UnfoldingMap(processing.core.PApplet p, java.lang.String id, float x, float y, float width, float height, boolean useDistortion, java.lang.String renderer)
public UnfoldingMap(processing.core.PApplet p, float x, float y, float width, float height, AbstractMapProvider provider)
p
- The main applet.x
- The x position of this map.y
- The y position of this map.width
- The width of this map.height
- The height of this map.provider
- The map tiles provider to use.public UnfoldingMap(processing.core.PApplet p, float x, float y, float width, float height, AbstractMapProvider provider, java.lang.String renderer)
public UnfoldingMap(processing.core.PApplet p, java.lang.String id, float x, float y, float width, float height, boolean useMask, boolean useDistortion, AbstractMapProvider provider)
public UnfoldingMap(processing.core.PApplet p, java.lang.String id, float x, float y, float width, float height, boolean useMask, boolean useDistortion, AbstractMapProvider provider, java.lang.String renderer)
p
- The main applet.id
- The ID of this map.x
- The x position of this map.y
- The y position of this map.width
- The width of this map.height
- The height of this map.useMask
- Whether this map enables using masks (test)useDistortion
- Whether this map enables using distortion (test)provider
- The map tiles provider to use.Method Detail |
---|
protected void prepareMapChangedMethod()
public boolean allTilesLoaded()
protected static java.lang.String generateId()
public boolean isHit(float checkX, float checkY)
checkX
- The vertical position to check.checkY
- The horizontal position to check.
public boolean isHit(ScreenPosition screenPosition)
screenPosition
- The position to check.
public boolean isActive()
public void setActive(boolean active)
active
- True if this map is active, false otherwise.public java.lang.String getId()
getId
in interface MapEventListener
public void draw()
public void onManipulation(MapEvent mapEvent)
onManipulation
in interface MapEventListener
public void updateMap()
AbstractMapDisplay.draw()
.
public Location getTopLeftBorder()
public Location getBottomRightBorder()
public Location getCenter()
@Deprecated public Location getLocationFromScreenPosition(float x, float y)
public Location getLocation(ScreenPosition screenPosition)
screenPosition
- The position in screen coordinates.
public Location getLocation(float x, float y)
x
- The x position in screen coordinates.y
- The y position in screen coordinates.
@Deprecated public float[] getScreenPositionFromLocation(Location location)
public ScreenPosition getScreenPosition(Location location)
location
- The geographic location with latitude and longitude.
public void rotate(float angle)
Use outerRotate(float)
to rotate the map container. Check RotatableMapApp in examples for a comparison.
angle
- The angle to rotate the map by.public void rotateTo(float angle)
angle
- The angle to rotate the map to.public void zoomToLevel(int level)
level
- The level to zoom to.public void zoomTo(float zoom)
public void zoomLevel(int levelDelta)
levelDelta
- The number of levels to zoom in or out.@Deprecated public void zoom(int levelDelta)
zoomLevel(int)
levelDelta
- The number of levels to zoom in or out.public void zoomLevelIn()
public void zoomLevelOut()
public void zoom(float scaleDelta)
scaleDelta
- The scale to zoom by.public void zoomIn()
public void zoomOut()
public void zoomAndPanTo(float x, float y, int level)
x
- X position to zoom around and pan to (in screen coordinates).y
- Y position to zoom around and pan to (in screen coordinates).level
- Zoom level to zoom to.public void zoomAndPanTo(ScreenPosition screenPosition, int level)
zoomAndPanTo(int, ScreenPosition)
.
screenPosition
- ScreenPosition to zoom around and pan to.level
- Zoom level to zoom to.public void zoomAndPanTo(int level, ScreenPosition screenPosition)
level
- Zoom level to zoom to.screenPosition
- ScreenPosition to zoom around and pan to.public void zoomAndPanTo(Location location, int zoomLevel)
zoomAndPanTo(int, Location)
.
location
- The Location to zoom around and pan to.zoomLevel
- Zoom level to zoom to.public void zoomAndPanTo(int zoomLevel, Location location)
zoomLevel
- Zoom level to zoom to.location
- The Location to zoom around and pan to.public void panTo(float x, float y)
x
- X of the position to pan to, in screen coordinates.y
- Y of the position to pan to, in screen coordinates.public void panTo(ScreenPosition screenPosition)
screenPosition
- the position to pan to.public void panTo(Location location)
location
- The Location to pan to.public void pan(float x1, float y1, float x2, float y2)
public void pan(ScreenPosition from, ScreenPosition to)
from
- ScreenPosition to start from.to
- ScreenPosition to pan to.public void pan(Location fromLocation, Location toLocation)
fromLocation
- Origin location to pan from.toLocation
- Destination location to pan to.public void panBy(float dx, float dy)
dx
- Horizontal distance in pixel.dy
- Vertical distance in pixel.public void panLeft()
public void panRight()
public void panUp()
public void panDown()
public void move(float x, float y)
The whole map container is moved. Use one of the panning methods to pan the geographical map.
x
- X position in screen coordinates.y
- Y position in screen coordinates.public void move(ScreenPosition screenPosition)
screenPosition
- the ScreenPosition to move to.public void moveBy(float dx, float dy)
dx
- The x distance to move by.dy
- The y distance to move by.public void zoomAndPanToFit(java.util.List<Location> locations)
public void zoomToFit(java.util.List<Location> locations)
public void zoomToFit(Location[] boundingBox)
public void addMarkerManager(MarkerManager<Marker> markerManager)
Use this if you want to handle multiple independent marker groups. Otherwise, simply use UnfoldingMap's marker
methods directly (such as addMarker(Marker)
) which handles this internally with the default
MarkerManager.
markerManager
- The MarkerManager to add.public MarkerManager<Marker> getLastMarkerManager()
public MarkerManager<Marker> getDefaultMarkerManager()
public java.util.List<MarkerManager<Marker>> getMarkerManagerList()
public void removeMarkerManager(MarkerManager<Marker> markerManager)
public void removeMarkerManager(int i)
public MarkerManager<Marker> getMarkerManager(int index)
index
- The index to get.
public void addMarkers(Marker... marker)
Note: Uses the default marker manager. If you have more than one marker manager, use
MarkerManager.addMarker(Marker)
instead.
marker
- The marker or markers to add.public void addMarker(Marker marker)
Note: Uses the default marker manager. If you have more than one marker manager, use
MarkerManager.addMarker(Marker)
instead.
marker
- The marker to add.public void addMarkers(java.util.List<Marker> markers)
Note: Uses the default marker manager. If you have more than one marker manager, use
MarkerManager.addMarkers(List)
instead.
markers
- The markers to add.public java.util.List<Marker> getMarkers()
Note: Returns only the markers of the default marker manager. If you have more than one marker manager,
use MarkerManager.addMarkers(List)
instead.
public Marker getFirstHitMarker(float checkX, float checkY)
getHitMarker(float, float)
to get all hit markers.
Note: Returns only the markers of the default marker manager. If you have more than one marker manager,
use MarkerManager.getFirstHitMarker(float, float)
instead.
public java.util.List<Marker> getHitMarkers(float checkX, float checkY)
getFirstHitMarker(float, float)
to get only one marker.
Note: Returns only the markers of the default marker manager. If you have more than one marker manager,
use MarkerManager.getHitMarkers(float, float)
instead.
public java.util.List<Marker> getHitMarker(float checkX, float checkY)
getHitMarkers(float, float)
instead.
protected void setOuterRotate(float angle)
public void outerRotate(float angle)
protected void setInnerRotate(float angle)
public void innerRotate(float angle)
rotate(float)
instead.
angle
- The angle to rotate by.protected void outerScale(float scale)
protected void setOuterScale(float scale)
public void innerScale(float scale)
public void setInnerScale(float scale)
public int getZoomLevel()
public float getZoom()
getZoomFromScale(double)
to convert to floating zoom level.
public void setScaleRange(float minScale, float maxScale)
public void setZoomRange(float minZoomLevel, float maxZoomLevel)
minZoomLevel
- The lower zoom level boundary.maxZoomLevel
- The upper zoom level boundary.public void setPanningRestriction(Location location, float maxPanningDistance)
location
- The center location of the circular restriction area.maxPanningDistance
- The radius of the circular restriction area in kilometers.public void resetPanningRestriction()
protected void panObjectPositionToObjectCenter(float x, float y)
x
- X in object coordinates.y
- Y in object coordinates.protected void addInnerOffset(float dx, float dy)
protected void setInnerOffset(float x, float y)
protected void setOffset(float x, float y)
x
- The x of the screen position.y
- The y of the screen position.protected void addOffset(float dx, float dy)
dx
- The x distance in screen coordinates.dy
- The y distance in screen coordinates.public static float getScaleFromZoom(float zoom)
zoom
- The zoom value (between 0 and typically 20+).
public static float getZoomFromScale(double scale)
scale
- The scale value (between 0 and 2zoom).
public static int getZoomLevelFromScale(double scale)
getZoomFromScale(double)
but with integer values.
public void switchTweening()
public boolean isTweening()
public void setTweening(boolean tweening)
tweening
- Whether or not the map shall animate.public void setBackgroundColor(java.lang.Integer bgColor)
bgColor
- The color in the current colorMode.public float getWidth()
public float getHeight()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |