Package org.jxmapviewer.viewer
Class TileFactory
java.lang.Object
org.jxmapviewer.viewer.TileFactory
- Direct Known Subclasses:
AbstractTileFactory,EmptyTileFactory
public abstract class TileFactory
extends java.lang.Object
A class that can produce tiles and convert coordinates to pixels
-
Constructor Summary
Constructors Modifier Constructor Description protectedTileFactory(TileFactoryInfo info)Creates a new instance of TileFactory -
Method Summary
Modifier and Type Method Description voidaddTileListener(TileListener listener)Adds a tile listenerabstract voiddispose()Disposes this TileFactoryprotected voidfireTileLoadedEvent(Tile tile)Notifies all tile listenersjava.awt.geom.Point2DgeoToPixel(GeoPosition c, int zoomLevel)Convert a GeoPosition to a pixel position in the world bitmap a the specified zoom level.TileFactoryInfogetInfo()Get the TileFactoryInfo describing this TileFactoryjava.awt.DimensiongetMapSize(int zoom)Returns a Dimension containing the width and height of the map, in tiles at the current zoom level.abstract TilegetTile(int x, int y, int zoom)Return the Tile at a given TilePoint and zoom levelintgetTileSize(int zoom)Gets the size of an edge of a tile in pixels at the current zoom level.GeoPositionpixelToGeo(java.awt.geom.Point2D pixelCoordinate, int zoom)Convert a pixel in the world bitmap at the specified zoom level into a GeoPositionvoidremoveTileListener(TileListener listener)Removes a tile listenervoidsetLocalCache(LocalCache cache)protected abstract voidstartLoading(Tile tile)Override this method to load the tile using, for example, anExecutorService.
-
Constructor Details
-
TileFactory
Creates a new instance of TileFactory- Parameters:
info- a TileFactoryInfo to configure this TileFactory
-
-
Method Details
-
getTileSize
public int getTileSize(int zoom)Gets the size of an edge of a tile in pixels at the current zoom level. Tiles must be square.- Parameters:
zoom- the current zoom level- Returns:
- the size of an edge of a tile in pixels
-
getMapSize
public java.awt.Dimension getMapSize(int zoom)Returns a Dimension containing the width and height of the map, in tiles at the current zoom level. So a Dimension that returns 10x20 would be 10 tiles wide and 20 tiles tall. These values can be multipled by getTileSize() to determine the pixel width/height for the map at the given zoom level- Parameters:
zoom- the current zoom level- Returns:
- the size of the world bitmap in tiles
-
getTile
Return the Tile at a given TilePoint and zoom level- Parameters:
x- the x valuey- the y valuezoom- the current zoom level- Returns:
- the tile that is located at the given tilePoint for this zoom level. For example, if getMapSize() returns 10x20 for this zoom, and the tilePoint is (3,5), then the appropriate tile will be located and returned. This method must not return null. However, it can return dummy tiles that contain no data if it wants. This is appropriate, for example, for tiles which are outside of the bounds of the map and if the factory doesn't implement wrapping.
-
pixelToGeo
Convert a pixel in the world bitmap at the specified zoom level into a GeoPosition- Parameters:
pixelCoordinate- a Point2D representing a pixel in the world bitmapzoom- the zoom level of the world bitmap- Returns:
- the converted GeoPosition
-
geoToPixel
Convert a GeoPosition to a pixel position in the world bitmap a the specified zoom level.- Parameters:
c- a GeoPositionzoomLevel- the zoom level to extract the pixel coordinate for- Returns:
- the pixel point
-
getInfo
Get the TileFactoryInfo describing this TileFactory- Returns:
- a TileFactoryInfo
-
addTileListener
Adds a tile listener- Parameters:
listener- the listener
-
removeTileListener
Removes a tile listener- Parameters:
listener- the listener
-
dispose
public abstract void dispose()Disposes this TileFactory -
fireTileLoadedEvent
Notifies all tile listeners- Parameters:
tile- the tile
-
startLoading
Override this method to load the tile using, for example, anExecutorService.- Parameters:
tile- The tile to load.
-
setLocalCache
- Parameters:
cache- the local cache to use
-