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) http://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>cacheprivate intcacheSizeprivate static intDEFAULT_NUMBER_OF_IMAGEFETCHER_THREADSprivate org.eclipse.swt.widgets.Displaydisplay(package private) java.util.concurrent.ThreadPoolExecutorexecutorprivate java.util.List<GeoMapHelperListener>geoMapHelperListenersprivate java.util.List<InternalGeoMapListener>internalGeoMapListenersprivate org.eclipse.swt.graphics.PointmapPositionprivate org.eclipse.swt.graphics.PointmapSizeprivate static intMIN_CACHE_SIZEprivate java.util.concurrent.ThreadFactorythreadFactorystatic intTILE_SIZEbasically not be changed, must be the same as GeoMapUtil's TILE_SIZEprivate TileServertileServerprivate org.eclipse.swt.graphics.ColorwaitBackgroundprivate org.eclipse.swt.graphics.ColorwaitForegroundprivate java.util.concurrent.BlockingQueue<java.lang.Runnable>workQueueprivate intzoom(package private) java.util.concurrent.atomic.AtomicLongzoomStamp
-
Constructor Summary
Constructors Modifier Constructor Description privateGeoMapHelper(org.eclipse.swt.widgets.Display display)Initializes a newGeoMapHelperwith a specific display.GeoMapHelper(org.eclipse.swt.widgets.Display display, org.eclipse.swt.graphics.Point mapPosition, int zoom, int cacheSize)Initializes a newGeoMapHelperfor a specific display, position, zoom level and cache size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddGeoMapHelperListener(GeoMapHelperListener listener)Adds a GeoMapHelperListener that will be notified about tile updatesvoidaddInternalGeoMapListener(InternalGeoMapListener listener)Adds an InternalGeoMapListener that will be notified about painting and cache updatesvoiddispose()Dispose internal data(package private) org.eclipse.swt.widgets.DisplaygetDisplay()org.eclipse.swt.graphics.PointgetMapPosition()Gets the position of the upper left corner of the map.intgetMaxZoom()Gets the maximum supported zoom levelintgetNumberOfTiles()TileServergetTileServer()Gets the tile server used for fetching tilesintgetZoom()Gets the current zoom levelvoidpaint(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) voidpaintTile(org.eclipse.swt.graphics.GC gc, int dx, int dy, int x, int y)voidremoveGeoMapHelperListener(GeoMapHelperListener listener)Removes a GeoMapHelperListenervoidremoveInternalGeoMapListener(InternalGeoMapListener listener)Removes an InternalGeoMapListenervoidsetMapPosition(int x, int y)Sets the position of the upper left corner of the map.voidsetTileServer(TileServer tileServer)Sets the tile server used for fetching tilesvoidsetZoom(int zoom)Sets the current zoom levelvoidtileUpdated(TileRef tileRef)Notifies listener that a tile has been updated and may need (re)painting
-
-
-
Field Detail
-
display
private final org.eclipse.swt.widgets.Display display
-
TILE_SIZE
public static final int TILE_SIZE
basically not be changed, must be the same as GeoMapUtil's TILE_SIZE- See Also:
- Constant Field Values
-
DEFAULT_NUMBER_OF_IMAGEFETCHER_THREADS
private static final int DEFAULT_NUMBER_OF_IMAGEFETCHER_THREADS
- See Also:
- Constant Field Values
-
MIN_CACHE_SIZE
private static final int MIN_CACHE_SIZE
- See Also:
- Constant Field Values
-
mapSize
private org.eclipse.swt.graphics.Point mapSize
-
mapPosition
private org.eclipse.swt.graphics.Point mapPosition
-
zoom
private int zoom
-
zoomStamp
java.util.concurrent.atomic.AtomicLong zoomStamp
-
tileServer
private TileServer tileServer
-
cacheSize
private int cacheSize
-
cache
java.util.Map<TileRef,AsyncImage> cache
-
workQueue
private java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue
-
threadFactory
private java.util.concurrent.ThreadFactory threadFactory
-
executor
java.util.concurrent.ThreadPoolExecutor executor
-
waitBackground
private org.eclipse.swt.graphics.Color waitBackground
-
waitForeground
private org.eclipse.swt.graphics.Color waitForeground
-
geoMapHelperListeners
private java.util.List<GeoMapHelperListener> geoMapHelperListeners
-
internalGeoMapListeners
private java.util.List<InternalGeoMapListener> internalGeoMapListeners
-
-
Constructor Detail
-
GeoMapHelper
private GeoMapHelper(org.eclipse.swt.widgets.Display display)
Initializes a newGeoMapHelperwith a specific display. The display is used for async runnables and as device for images.- Parameters:
display- the display
-
GeoMapHelper
public GeoMapHelper(org.eclipse.swt.widgets.Display display, org.eclipse.swt.graphics.Point mapPosition, int zoom, int cacheSize)Initializes a newGeoMapHelperfor a specific display, position, zoom level and cache size.- Parameters:
display- theDisplayto 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 Detail
-
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
public TileServer getTileServer()
Gets the tile server used for fetching tiles- Returns:
- the tile server
-
setTileServer
public void setTileServer(TileServer tileServer)
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:GeoMapPositionedGets the position of the upper left corner of the map. The resolution depends on the zoom level.- Specified by:
getMapPositionin 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:GeoMapPositionedSets the position of the upper left corner of the map. The resolution depends on the zoom level.- Specified by:
setMapPositionin interfaceGeoMapPositioned- Parameters:
x- the x coordinatey- the y coordinate- See Also:
GeoMapPositioned.setMapPosition(int, int)
-
getMaxZoom
public int getMaxZoom()
Description copied from interface:GeoMapPositionedGets the maximum supported zoom level- Specified by:
getMaxZoomin interfaceGeoMapPositioned- Returns:
- the maximum zoom level
- See Also:
GeoMapPositioned.getMaxZoom()
-
getZoom
public int getZoom()
Description copied from interface:GeoMapPositionedGets the current zoom level- Specified by:
getZoomin interfaceGeoMapPositioned- Returns:
- the current zoom level
- See Also:
GeoMapPositioned.getZoom()
-
setZoom
public void setZoom(int zoom)
Description copied from interface:GeoMapPositionedSets the current zoom level- Specified by:
setZoomin interfaceGeoMapPositioned- Parameters:
zoom- the new zoom level- See Also:
GeoMapPositioned.setZoom(int)
-
tileUpdated
public void tileUpdated(TileRef tileRef)
Description copied from interface:GeoMapHelperListenerNotifies listener that a tile has been updated and may need (re)painting- Specified by:
tileUpdatedin interfaceGeoMapHelperListener- Parameters:
tileRef- the reference to the updated tile
-
addGeoMapHelperListener
public void addGeoMapHelperListener(GeoMapHelperListener listener)
Adds a GeoMapHelperListener that will be notified about tile updates- Parameters:
listener- the GeoMapHelperListener
-
removeGeoMapHelperListener
public void removeGeoMapHelperListener(GeoMapHelperListener listener)
Removes a GeoMapHelperListener- Parameters:
listener- the GeoMapHelperListener
-
addInternalGeoMapListener
public void addInternalGeoMapListener(InternalGeoMapListener listener)
Adds an InternalGeoMapListener that will be notified about painting and cache updates- Parameters:
listener- the InternalGeoMapListener
-
removeInternalGeoMapListener
public void removeInternalGeoMapListener(InternalGeoMapListener listener)
Removes an InternalGeoMapListener- Parameters:
listener- the InternalGeoMapListener
-
getNumberOfTiles
public int getNumberOfTiles()
- Returns:
- the number of tiles
-
-