public class IlvFileTileManager extends Object implements IlvTileManager
IlvDefaultFileTileCache
. This tile
manager is intended to be used with a IlvManagerServlet
and a
IlvManagerServletSupport
. In the servlet code, you can use it
the following way:
protected BufferedImage generateImage( HttpServletRequest request, IlvRect bbox, int width, int height, String[] requestedLayers, Color bgColor, boolean transparent) throws ServletException { String s = request.getParameter("overview"); BufferedImage image = null; boolean overview = (s != null && s.equalsIgnoreCase("true")); if (!overview) { IlvTileManager tileManager = getTileManager(...); Object key = getKey(request); // retrieve key attribute from request. image = tileManager.getImage(key); if (image == null) { // image not found by the tile manager, create it from the view image = super.generateImage(request, bbox, width, height, requestedLayers, bgColor, transparent); // register image in the tile manager tileManager.putImage(key, image); } return image; } return super.generateImage(request, bbox, width, height, requestedLayers, bgColor, transparent); }
Modifier and Type | Field and Description |
---|---|
static int |
JPEG_FORMAT
Constant to save images in JPEG format.
|
static int |
PNG_FORMAT
Constant to save images in PNG format.
|
Constructor and Description |
---|
IlvFileTileManager()
Create a
IlvFileTileManager with default values:
null tile storage directory and a size of 10 mega bytes. |
IlvFileTileManager(File base,
long maxCacheSize,
long freeCacheSize)
Constructs a
IlvFileTileManager by specifying the location of
the directory in which the tiles will be stored. |
Modifier and Type | Method and Description |
---|---|
IlvDefaultFileTileCache |
getCache()
Retrieves the
IlvFileTileCache used by the tile manager to
cache the tiles. |
BufferedImage |
getImage(Object o)
Retrieves an image of a tile by specifying an
Object as a key. |
int |
getImageFormat()
Returns the compression format used to write the image tiles.
|
IlvDefaultFileTileReader |
getReader()
Retrieves the
IlvTileReader used by this tile manager to read
the tiles. |
IlvTileURLFactory |
getUrlFactory()
Retrieves the URL factory used to build URLs.
|
IlvDefaultFileTileWriter |
getWriter()
Retrieves the
IlvTileWriter used by this tile manager to write
the tiles. |
Object |
putImage(Object o,
BufferedImage image)
Put an image in the tile manager.
|
void |
setBase(File base)
Sets the base directory for this tile manager.
|
void |
setCache(IlvDefaultFileTileCache cacheManager)
Sets the
IlvFileTileCache used by this tile manager to cache
the tiles. |
void |
setImageFormat(int format)
Sets the compression format used to write the image tiles.
|
void |
setReader(IlvDefaultFileTileReader reader)
Sets the
IlvTileReader used by this tile manager to read the
tiles. |
void |
setUrlFactory(IlvTileURLFactory urlFactory)
Sets the URL factory.
|
void |
setWriter(IlvDefaultFileTileWriter writer)
Sets the
IlvTileWriter used by this tile manager to write the
tiles. |
public static int PNG_FORMAT
public static int JPEG_FORMAT
public IlvFileTileManager()
IlvFileTileManager
with default values:
null
tile storage directory and a size of 10 mega bytes.
Before using a cache created with this constructor, you have to call the
setBase
method with a non null base file.setBase(File)
public IlvFileTileManager(File base, long maxCacheSize, long freeCacheSize)
IlvFileTileManager
by specifying the location of
the directory in which the tiles will be stored. IlvDefaultFileTileWriter
as tile writer.IlvDefaultFileTileReader
as tile reader.IlvFileTileURLFactory
as URL factory.IlvDefaultFileTileCache
as tile cache.base
- The base directory for tile cache.maxCacheSize
- The max tile cache size.freeCacheSize
- The size that will be free when the cache is full.public void setBase(File base)
base
- The base directory where the tiles will be stored.public void setImageFormat(int format)
format
- the image format.public int getImageFormat()
public BufferedImage getImage(Object o)
Object
as a key.getImage
in interface IlvTileManager
o
- The object specifying the location of the tile.null
if no image is found at
this location.public Object putImage(Object o, BufferedImage image)
putImage
in interface IlvTileManager
o
- The object used to build the tile location.image
- The image of the tile.File
storing the tile or null
if the
tile manager was unable to write the tile.public IlvTileURLFactory getUrlFactory()
public void setUrlFactory(IlvTileURLFactory urlFactory)
urlFactory
- The URL factory to set.public IlvDefaultFileTileReader getReader()
IlvTileReader
used by this tile manager to read
the tiles.IlvTileReader
used by this tile manager to read
the tiles.public void setReader(IlvDefaultFileTileReader reader)
IlvTileReader
used by this tile manager to read the
tiles.reader
- The new IlvTileReader
used by this tile manager to
read the tiles.public IlvDefaultFileTileWriter getWriter()
IlvTileWriter
used by this tile manager to write
the tiles.IlvTileWriter
used by this tile manager to write
the tiles.public void setWriter(IlvDefaultFileTileWriter writer)
IlvTileWriter
used by this tile manager to write the
tiles.writer
- The new IlvTiledWriterReader
used by this tile
manager to write the tiles.public IlvDefaultFileTileCache getCache()
IlvFileTileCache
used by the tile manager to
cache the tiles.IlvFileTileCache
used by the tile manager to cache
the tiles.public void setCache(IlvDefaultFileTileCache cacheManager)
IlvFileTileCache
used by this tile manager to cache
the tiles.cacheManager
- The IlvFileTileCache
used by this tile manager to
cache the tiles.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.