public class StandardMapTileFactory extends CacheHandler implements MapTileFactory, PropertyConsumer
This component can be configured using properties:
rootDir=the path to the parent directory of the tiles. The factory will construct specific file paths that are appended to this value. fileExt=the file extension to append to the tile names cacheSize=the number of mapTiles the factory should hold on to. The default is 100. # default is OSMMapTileCoordinateTransform, but it depends on the source of tiles. GDAL is TSMMapTileCoordinateTransform mapTileTransform=com.bbn.openmap.dataAccess.mapTile.OSMMapTileCoordinateTransform, or com.bbn.openmap.dataAccess.mapTile.TSMMapTileCoordinateTransform # what to do about missing tiles? emptyTileHandler=com.bbn.openmap.dataAccess.mapTile.SimpleEmptyTileHandler # Set a tile image preparer, if you want to change how images are rendered (greyscale, for instance) tileImagePreparer=com.bbn.openmap.dataAccess.mapTile.StandardImagePreparer # or tileImagePreparer=com.bbn.openmap.dataAccess.mapTile.GreyscaleImagePreparer
Modifier and Type | Class and Description |
---|---|
static class |
StandardMapTileFactory.TilePathBuilder |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CACHE_SIZE_PROPERTY |
static java.lang.String |
EMPTY_TILE_HANDLER_PROPERTY |
protected EmptyTileHandler |
emptyTileHandler |
static java.lang.String |
FILE_EXT_PROPERTY |
protected java.lang.String |
fileExt |
protected Projection |
lastProj |
protected static java.util.logging.Logger |
logger |
protected static java.util.logging.Logger |
mapTileLogger |
protected MapTileCoordinateTransform |
mtcTransform
Coordinate transform for the uv coordinates of the tiles.
|
static java.lang.String |
MTCTRANSFORM_PROPERTY |
protected java.lang.String |
prefix |
protected java.awt.Component |
repaintCallback
A component that is painting the tiles to the screen.
|
static java.lang.String |
ROOT_DIR_PATH_PROPERTY
Inserted into properties loaded via tiles.omp, so that the
EmptyTileHandler can know where the tile set is located, in case it needs
to know the absolute path.
|
static java.lang.String |
ROOT_DIR_PROPERTY |
protected java.lang.String |
rootDir |
protected java.lang.String |
rootDirProperty |
protected float[] |
scales
An array of scales for all of the possible zoom levels, from 1 to 20.
|
static java.lang.String |
TILE_IMAGE_PREPARER_PROPERTY |
static java.lang.String |
TILE_PROPERTIES
The name of the properties file that the factory looks for in the root
directory of the data (tiles.omp).
|
protected TileImagePreparer |
tileImagePreparer |
protected boolean |
verbose |
static java.lang.String |
ZOOM_LEVEL_INFO_PROPERTY |
static java.lang.String |
ZOOM_LEVEL_TILE_SIZE_PROPERTY |
protected ZoomLevelInfo |
zoomLevelInfo |
protected int |
zoomLevelTileSize |
DEFAULT_MAX_CACHE_SIZE, logicalClock, objs
EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty
Constructor and Description |
---|
StandardMapTileFactory() |
StandardMapTileFactory(java.awt.Component layer,
java.lang.String rootDir,
java.lang.String tileFileExt) |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
buildCacheKey(int x,
int y,
int z,
java.lang.String fileExt)
Creates a unique cache key for this tile based on zoom, x, y.
|
java.lang.String |
buildFilePath(int x,
int y,
int z,
java.lang.String fileExt)
Build an image path to load, based on specified tile coordinates, zoom
level and file extension settings.
|
protected void |
configureFromProperties(java.io.InputStream is,
java.lang.String rootDirectory)
Called with an input stream for a properties file, used for reading
tiles.omp files.
|
protected OMGraphic |
createOMGraphicFromBufferedImage(java.awt.image.BufferedImage bi,
int x,
int y,
int zoomLevel,
Projection proj)
Creates an OMRaster appropriate for projection and other parameters from
a buffered image.
|
java.lang.Object |
get(java.lang.Object key,
int x,
int y,
int zoomLevel,
Projection proj)
The main call to retrieve something from the cache, modified to allow
load method to do some projection calculations to initialize tile
parameters.
|
CacheObject |
getEmptyTile(java.lang.Object key,
int x,
int y,
int zoomLevel,
Projection proj)
Call to make when you want the tile factory to create some empty tile
representation for the given location.
|
EmptyTileHandler |
getEmptyTileHandler()
Get object that handles empty tiles.
|
java.lang.String |
getFileExt() |
java.lang.Object |
getFromCache(java.lang.Object key,
int x,
int y,
int zoomLevel)
An auxiliary call to retrieve something from the cache, modified to allow
load method to do some projection calculations to initialize tile
parameters.
|
MapTileCoordinateTransform |
getMtcTransform() |
java.util.Properties |
getProperties(java.util.Properties getList)
Method to fill in a Properties object, reflecting the current
values of the PropertyConsumer.
|
java.util.Properties |
getPropertyInfo(java.util.Properties list)
Method to fill in a Properties object with values reflecting
the properties able to be set on this PropertyConsumer.
|
java.lang.String |
getPropertyPrefix()
Get the property key prefix that is being used to prepend to
the property keys for Properties lookups.
|
java.awt.Component |
getRepaintCallback() |
java.lang.String |
getRootDir() |
TileImagePreparer |
getTileImagePreparer() |
protected OMGraphic |
getTileMatchingProjectionType(java.awt.image.BufferedImage image,
int x,
int y,
int zoomLevel)
Create an OMScalingRaster that matches the basic projection of the
current map.
|
protected OMGraphic |
getTileNotMatchingProjectionType(java.awt.image.BufferedImage image,
int x,
int y,
int zoomLevel)
Create an OMWarpingImage that knows how to re-project itself for
different projections.
|
protected void |
getTiles(int uvleft,
int uvright,
int uvup,
int uvbottom,
ZoomLevelInfo zoomLevelInfo,
Projection proj,
OMGraphicList list) |
OMGraphicList |
getTiles(Projection proj)
Returns projected tiles for the given projection.
|
OMGraphicList |
getTiles(Projection proj,
int zoomLevel)
Returns projected tiles for given projection at specified zoom level.
|
OMGraphicList |
getTiles(Projection proj,
int zoomLevel,
OMGraphicList list)
Returns projected tiles for given projection at specified zoom level.
|
int |
getZoomLevelForProj(Projection proj)
Given a projection, figure out the appropriate zoom level for it.
|
ZoomLevelInfo |
getZoomLevelInfo()
Get the ZoomLevelInfo set on the factory.
|
CacheObject |
load(java.lang.Object key)
Called from get if the key doesn't exist, to "load" the new object into
the cache before returning it.
|
CacheObject |
load(java.lang.Object key,
int x,
int y,
int zoomLevel,
Projection proj)
Called to load cache object from data source, when not found in cache.
|
protected java.awt.image.BufferedImage |
preprocessImage(java.awt.Image origImage,
int imageWidth,
int imageHeight)
Method that allows subclasses to modify the image as necessary before it
is passed into an OMGraphic.
|
void |
reset()
Tell the factory to clean up resources.
|
void |
setEmptyTileHandler(EmptyTileHandler emptyTileHandler) |
void |
setFileExt(java.lang.String fileExt) |
void |
setMtcTransform(MapTileCoordinateTransform mtcTransform)
Set the map tile coordinate transformed used to figure out lat/lon to
tile coordinates.
|
void |
setProperties(java.util.Properties setList)
Method to set the properties in the PropertyConsumer.
|
void |
setProperties(java.lang.String prefix,
java.util.Properties setList)
Method to set the properties in the PropertyConsumer.
|
void |
setPropertyPrefix(java.lang.String prefix)
Set the property key prefix that should be used by the
PropertyConsumer.
|
void |
setRepaintCallback(java.awt.Component callback)
Set a component in the tile factory that should be told to repaint when
new tiles become available.
|
void |
setRootDir(java.lang.String rootDirectory) |
void |
setTileImagePreparer(TileImagePreparer tileImagePreparer) |
void |
setZoomLevelInfo(ZoomLevelInfo zoomLevelInfo)
Get the ZoomLevelInfo set on the factory.
|
clear, get, getCacheSize, listIterator, replaceLeastUsed, resetCache, resetCache, searchCache
protected java.lang.String prefix
protected static final java.util.logging.Logger logger
protected static final java.util.logging.Logger mapTileLogger
public static final java.lang.String ROOT_DIR_PROPERTY
public static final java.lang.String FILE_EXT_PROPERTY
public static final java.lang.String CACHE_SIZE_PROPERTY
public static final java.lang.String MTCTRANSFORM_PROPERTY
public static final java.lang.String EMPTY_TILE_HANDLER_PROPERTY
public static final java.lang.String ZOOM_LEVEL_INFO_PROPERTY
public static final java.lang.String ZOOM_LEVEL_TILE_SIZE_PROPERTY
public static final java.lang.String TILE_IMAGE_PREPARER_PROPERTY
public static final java.lang.String ROOT_DIR_PATH_PROPERTY
public static final java.lang.String TILE_PROPERTIES
protected ZoomLevelInfo zoomLevelInfo
protected java.lang.String rootDir
protected java.lang.String fileExt
protected java.lang.String rootDirProperty
protected EmptyTileHandler emptyTileHandler
protected boolean verbose
protected int zoomLevelTileSize
protected TileImagePreparer tileImagePreparer
protected java.awt.Component repaintCallback
protected MapTileCoordinateTransform mtcTransform
protected Projection lastProj
protected float[] scales
public StandardMapTileFactory()
public StandardMapTileFactory(java.awt.Component layer, java.lang.String rootDir, java.lang.String tileFileExt)
public CacheObject load(java.lang.Object key)
CacheHandler
load
in class CacheHandler
public void reset()
reset
in interface MapTileFactory
public CacheObject load(java.lang.Object key, int x, int y, int zoomLevel, Projection proj)
key
- cache keyx
- uv x coordinatey
- uv y coordinatezoomLevel
- zoom level for tile to loadproj
- passed solely to enable checking if the projection of the
tiles matches the rendered projection.protected OMGraphic createOMGraphicFromBufferedImage(java.awt.image.BufferedImage bi, int x, int y, int zoomLevel, Projection proj) throws java.lang.InterruptedException
bi
- BufferedImage to use for tile.x
- x uv coordinate for tile.y
- y uv coordinate for tile.zoomLevel
- zoom level for tile.proj
- the current map projectionjava.lang.InterruptedException
protected OMGraphic getTileMatchingProjectionType(java.awt.image.BufferedImage image, int x, int y, int zoomLevel)
image
- BufferedImage created from tile filex
- uv x coordinatey
- uv y coordinatezoomLevel
- zoom level for tile retrievalprotected OMGraphic getTileNotMatchingProjectionType(java.awt.image.BufferedImage image, int x, int y, int zoomLevel)
image
- x
- y
- zoomLevel
- protected java.awt.image.BufferedImage preprocessImage(java.awt.Image origImage, int imageWidth, int imageHeight) throws java.lang.InterruptedException
origImage
- Any java ImageimageWidth
- pixel widthimageHeight
- pixel heightjava.lang.InterruptedException
public java.lang.Object get(java.lang.Object key, int x, int y, int zoomLevel, Projection proj)
key
- cache key, usually string of location of a tilex
- uv x location of tiley
- uv y location of tilezoomLevel
- zoom level of tileproj
- passed solely to enable checking if the projection of the
tiles matches the rendered projection.public java.lang.Object getFromCache(java.lang.Object key, int x, int y, int zoomLevel)
key
- cache key, usually string of location of a tilex
- uv x location of tiley
- uv y location of tilezoomLevel
- zoom level of tilepublic CacheObject getEmptyTile(java.lang.Object key, int x, int y, int zoomLevel, Projection proj)
key
- the cache key for this objectx
- the uv x coordinate of the tiley
- the uv y coordinate of the tilezoomLevel
- the zoom level for the tileproj
- the projection being used for the map.public OMGraphicList getTiles(Projection proj)
getTiles
in interface MapTileFactory
proj
- the projection to fetch tiles for.java.lang.InterruptedException
public OMGraphicList getTiles(Projection proj, int zoomLevel)
getTiles
in interface MapTileFactory
proj
- projection for queryzoomLevel
- zoom level 1-20 for tiles to be returned, -1 for code to
figure out appropriate zoom level.java.lang.InterruptedException
public OMGraphicList getTiles(Projection proj, int zoomLevel, OMGraphicList list)
getTiles
in interface MapTileFactory
proj
- projection for queryzoomLevel
- zoom level 1-20 for tiles to be returned, -1 for code to
figure out appropriate zoom level.list
- OMGraphicList that is returned, that will also have tiles
added to it.java.lang.InterruptedException
protected void getTiles(int uvleft, int uvright, int uvup, int uvbottom, ZoomLevelInfo zoomLevelInfo, Projection proj, OMGraphicList list)
public java.lang.String buildFilePath(int x, int y, int z, java.lang.String fileExt)
x
- the x tile coordinatey
- the y tile coordinatez
- the zoom levelfileExt
- the file extension to use for the path.protected java.lang.String buildCacheKey(int x, int y, int z, java.lang.String fileExt)
x
- tile coord.y
- tile coord.z
- zoomLevel.fileExt
- file extension.public int getZoomLevelForProj(Projection proj)
proj
- public java.awt.Component getRepaintCallback()
public void setRepaintCallback(java.awt.Component callback)
MapTileFactory
setRepaintCallback
in interface MapTileFactory
callback
- java.awt.Component to call repaint on.public java.util.Properties getProperties(java.util.Properties getList)
PropertyConsumer
getProperties
in interface PropertyConsumer
getList
- a Properties object to load the PropertyConsumer
properties into. If getList equals null, then a new
Properties object should be created.public java.util.Properties getPropertyInfo(java.util.Properties list)
PropertyConsumer
getPropertyInfo
in interface PropertyConsumer
list
- a Properties object to load the PropertyConsumer
properties into. If getList equals null, then a new
Properties object should be created.public java.lang.String getPropertyPrefix()
PropertyConsumer
getPropertyPrefix
in interface PropertyConsumer
public void setProperties(java.util.Properties setList)
PropertyConsumer
setProperties
in interface PropertyConsumer
setList
- a properties object that the PropertyConsumer
can use to retrieve expected properties it can use for
configuration.public void setProperties(java.lang.String prefix, java.util.Properties setList)
PropertyConsumer
setProperties
in interface PropertyConsumer
prefix
- a String used by the PropertyConsumer to prepend
to each property value it wants to look up -
setList.getProperty(prefix.propertyKey). If the prefix
had already been set, then the prefix passed in should
replace that previous value.setList
- a Properties object that the PropertyConsumer
can use to retrieve expected properties it can use for
configuration.public void setPropertyPrefix(java.lang.String prefix)
PropertyConsumer
setPropertyPrefix
in interface PropertyConsumer
prefix
- the prefix String.public java.lang.String getRootDir()
public void setRootDir(java.lang.String rootDirectory)
public TileImagePreparer getTileImagePreparer()
public void setTileImagePreparer(TileImagePreparer tileImagePreparer)
protected void configureFromProperties(java.io.InputStream is, java.lang.String rootDirectory) throws java.io.IOException
is
- input stream for tiles.omp file.rootDirectory
- original path to what was specified as root
directoryjava.io.IOException
public java.lang.String getFileExt()
public void setFileExt(java.lang.String fileExt)
public ZoomLevelInfo getZoomLevelInfo()
public void setZoomLevelInfo(ZoomLevelInfo zoomLevelInfo)
Won't allow itself to be set to null.
zoomLevelInfo
- the zoomLevelInfo to setpublic MapTileCoordinateTransform getMtcTransform()
public void setMtcTransform(MapTileCoordinateTransform mtcTransform)
mtcTransform
- public EmptyTileHandler getEmptyTileHandler()
MapTileFactory
getEmptyTileHandler
in interface MapTileFactory
public void setEmptyTileHandler(EmptyTileHandler emptyTileHandler)
emptyTileHandler
- the emptyTileHandler to setCopyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details