public class GeoMapHelper extends java.lang.Object implements GeoMapPositioned, GeoMapHelperListener
License is EPL (Eclipse Public License) http://www.eclipse.org/legal/epl-v10.html. Contact at stepan.rutz@gmx.de
Modifier and Type | Field and Description |
---|---|
(package private) java.util.Map<TileRef,AsyncImage> |
cache |
(package private) java.util.concurrent.ThreadPoolExecutor |
executor |
static int |
TILE_SIZE
basically not be changed, must be the same as GeoMapUtil's TILE_SIZE
|
(package private) java.util.concurrent.atomic.AtomicLong |
zoomStamp |
Constructor and Description |
---|
GeoMapHelper(org.eclipse.swt.widgets.Display display,
org.eclipse.swt.graphics.Point mapPosition,
int zoom,
int cacheSize)
Initializes a new
GeoMapHelper for a specific display,
position, zoom level and cache size. |
Modifier and Type | Method and Description |
---|---|
void |
addGeoMapHelperListener(GeoMapHelperListener listener)
Adds a GeoMapHelperListener that will be notified about tile updates
|
void |
addInternalGeoMapListener(InternalGeoMapListener listener)
Adds an InternalGeoMapListener that will be notified about painting and
cache updates
|
void |
dispose()
Dispose internal data
|
(package private) org.eclipse.swt.widgets.Display |
getDisplay() |
org.eclipse.swt.graphics.Point |
getMapPosition()
Gets the position of the upper left corner of the map.
|
int |
getMaxZoom()
Gets the maximum supported zoom level
|
int |
getNumberOfTiles() |
TileServer |
getTileServer()
Gets the tile server used for fetching tiles
|
int |
getZoom()
Gets the current zoom level
|
void |
paint(org.eclipse.swt.graphics.GC gc,
org.eclipse.swt.graphics.Rectangle clip,
org.eclipse.swt.graphics.Point size)
Points the map to the provided graphics context (GC), which could be the
one provided in an SWT control paint request or one created for rendering
an SWT Image
|
(package private) void |
paintTile(org.eclipse.swt.graphics.GC gc,
int dx,
int dy,
int x,
int y) |
void |
removeGeoMapHelperListener(GeoMapHelperListener listener)
Removes a GeoMapHelperListener
|
void |
removeInternalGeoMapListener(InternalGeoMapListener listener)
Removes an InternalGeoMapListener
|
void |
setMapPosition(int x,
int y)
Sets the position of the upper left corner of the map.
|
void |
setTileServer(TileServer tileServer)
Sets the tile server used for fetching tiles
|
void |
setZoom(int zoom)
Sets the current zoom level
|
void |
tileUpdated(TileRef tileRef)
Notifies listener that a tile has been updated and may need (re)painting
|
public static final int TILE_SIZE
java.util.concurrent.atomic.AtomicLong zoomStamp
java.util.Map<TileRef,AsyncImage> cache
java.util.concurrent.ThreadPoolExecutor executor
public GeoMapHelper(org.eclipse.swt.widgets.Display display, org.eclipse.swt.graphics.Point mapPosition, int zoom, int cacheSize)
GeoMapHelper
for a specific display,
position, zoom level and cache size.display
- the Display
to create images for.mapPosition
- initial mapPosition.zoom
- initial map zoomcacheSize
- initial cache size, eg number of tile-images that are kept in
cache to prevent reloading from the network.org.eclipse.swt.widgets.Display getDisplay()
public void paint(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle clip, org.eclipse.swt.graphics.Point size)
gc
- the graphics contextclip
- the area that needs updating, could be nullsize
- the size of the map areavoid paintTile(org.eclipse.swt.graphics.GC gc, int dx, int dy, int x, int y)
public void dispose()
public TileServer getTileServer()
public void setTileServer(TileServer tileServer)
tileServer
- the new tile server to usepublic org.eclipse.swt.graphics.Point getMapPosition()
GeoMapPositioned
getMapPosition
in interface GeoMapPositioned
GeoMapPositioned.getMapPosition()
public void setMapPosition(int x, int y)
GeoMapPositioned
setMapPosition
in interface GeoMapPositioned
x
- the x coordinatey
- the y coordinateGeoMapPositioned.setMapPosition(int, int)
public int getMaxZoom()
GeoMapPositioned
getMaxZoom
in interface GeoMapPositioned
GeoMapPositioned.getMaxZoom()
public int getZoom()
GeoMapPositioned
getZoom
in interface GeoMapPositioned
GeoMapPositioned.getZoom()
public void setZoom(int zoom)
GeoMapPositioned
setZoom
in interface GeoMapPositioned
zoom
- the new zoom levelGeoMapPositioned.setZoom(int)
public void tileUpdated(TileRef tileRef)
GeoMapHelperListener
tileUpdated
in interface GeoMapHelperListener
tileRef
- the reference to the updated tilepublic void addGeoMapHelperListener(GeoMapHelperListener listener)
listener
- the GeoMapHelperListenerpublic void removeGeoMapHelperListener(GeoMapHelperListener listener)
listener
- the GeoMapHelperListenerpublic void addInternalGeoMapListener(InternalGeoMapListener listener)
listener
- the InternalGeoMapListenerpublic void removeInternalGeoMapListener(InternalGeoMapListener listener)
listener
- the InternalGeoMapListenerpublic int getNumberOfTiles()