Class GeoMapHelper
java.lang.Object
org.eclipse.nebula.widgets.geomap.internal.GeoMapHelper
- All Implemented Interfaces:
GeoMapHelperListener
,GeoMapPositioned
public class GeoMapHelper extends java.lang.Object implements GeoMapPositioned, GeoMapHelperListener
License is EPL (Eclipse Public License) https://www.eclipse.org/legal/epl-v10.html. Contact at stepan.rutz@gmx.de
- Version:
- $Revision$
-
Field Summary
Fields Modifier and Type Field 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 Summary
Constructors Constructor Description GeoMapHelper(org.eclipse.swt.widgets.Display display, org.eclipse.swt.graphics.Point mapPosition, int zoom, int cacheSize)
Initializes a newGeoMapHelper
for a specific display, position, zoom level and cache size. -
Method Summary
Modifier and Type Method Description void
addGeoMapHelperListener(GeoMapHelperListener listener)
Adds a GeoMapHelperListener that will be notified about tile updatesvoid
addInternalGeoMapListener(InternalGeoMapListener listener)
Adds an InternalGeoMapListener that will be notified about painting and cache updatesvoid
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 levelint
getMinZoom()
Gets the minimum supported zoom levelint
getNumberOfTiles()
TileServer
getTileServer()
Gets the tile server used for fetching tilesint
getZoom()
Gets the current zoom levelvoid
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 GeoMapHelperListenervoid
removeInternalGeoMapListener(InternalGeoMapListener listener)
Removes an InternalGeoMapListenervoid
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 tilesvoid
setZoom(int zoom)
Sets the current zoom levelvoid
tileUpdated(TileRef tileRef)
Notifies listener that a tile has been updated and may need (re)painting
-
Field Details
-
TILE_SIZE
public static final int TILE_SIZEbasically not be changed, must be the same as GeoMapUtil's TILE_SIZE- See Also:
- Constant Field Values
-
zoomStamp
java.util.concurrent.atomic.AtomicLong zoomStamp -
cache
java.util.Map<TileRef,AsyncImage> cache -
executor
java.util.concurrent.ThreadPoolExecutor executor
-
-
Constructor Details
-
GeoMapHelper
public GeoMapHelper(org.eclipse.swt.widgets.Display display, org.eclipse.swt.graphics.Point mapPosition, int zoom, int cacheSize)Initializes a newGeoMapHelper
for a specific display, position, zoom level and cache size.- Parameters:
display
- theDisplay
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.
-
-
Method Details
-
getDisplay
org.eclipse.swt.widgets.Display getDisplay() -
paint
public 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- Parameters:
gc
- the graphics contextclip
- the area that needs updating, could be nullsize
- the size of the map area
-
paintTile
void paintTile(org.eclipse.swt.graphics.GC gc, int dx, int dy, int x, int y) -
dispose
public void dispose()Dispose internal data -
getTileServer
Gets the tile server used for fetching tiles- Returns:
- the tile server
-
setTileServer
Sets the tile server used for fetching tiles- Parameters:
tileServer
- the new tile server to use
-
getMapPosition
public org.eclipse.swt.graphics.Point getMapPosition()Description copied from interface:GeoMapPositioned
Gets the position of the upper left corner of the map. The resolution depends on the zoom level.- Specified by:
getMapPosition
in interfaceGeoMapPositioned
- Returns:
- the position of the upper left corner of the map
- See Also:
GeoMapPositioned.getMapPosition()
-
setMapPosition
public void setMapPosition(int x, int y)Description copied from interface:GeoMapPositioned
Sets the position of the upper left corner of the map. The resolution depends on the zoom level.- Specified by:
setMapPosition
in interfaceGeoMapPositioned
- Parameters:
x
- the x coordinatey
- the y coordinate- See Also:
GeoMapPositioned.setMapPosition(int, int)
-
getMinZoom
public int getMinZoom()Description copied from interface:GeoMapPositioned
Gets the minimum supported zoom level- Specified by:
getMinZoom
in interfaceGeoMapPositioned
- Returns:
- the minimum zoom level
- See Also:
GeoMapPositioned.getMinZoom()
-
getMaxZoom
public int getMaxZoom()Description copied from interface:GeoMapPositioned
Gets the maximum supported zoom level- Specified by:
getMaxZoom
in interfaceGeoMapPositioned
- Returns:
- the maximum zoom level
- See Also:
GeoMapPositioned.getMaxZoom()
-
getZoom
public int getZoom()Description copied from interface:GeoMapPositioned
Gets the current zoom level- Specified by:
getZoom
in interfaceGeoMapPositioned
- Returns:
- the current zoom level
- See Also:
GeoMapPositioned.getZoom()
-
setZoom
public void setZoom(int zoom)Description copied from interface:GeoMapPositioned
Sets the current zoom level- Specified by:
setZoom
in interfaceGeoMapPositioned
- Parameters:
zoom
- the new zoom level- See Also:
GeoMapPositioned.setZoom(int)
-
tileUpdated
Description copied from interface:GeoMapHelperListener
Notifies listener that a tile has been updated and may need (re)painting- Specified by:
tileUpdated
in interfaceGeoMapHelperListener
- Parameters:
tileRef
- the reference to the updated tile
-
addGeoMapHelperListener
Adds a GeoMapHelperListener that will be notified about tile updates- Parameters:
listener
- the GeoMapHelperListener
-
removeGeoMapHelperListener
Removes a GeoMapHelperListener- Parameters:
listener
- the GeoMapHelperListener
-
addInternalGeoMapListener
Adds an InternalGeoMapListener that will be notified about painting and cache updates- Parameters:
listener
- the InternalGeoMapListener
-
removeInternalGeoMapListener
Removes an InternalGeoMapListener- Parameters:
listener
- the InternalGeoMapListener
-
getNumberOfTiles
public int getNumberOfTiles()- Returns:
- the number of tiles
-