Class SimpleImageCache
- java.lang.Object
-
- com.itextpdf.styledxmlparser.resolver.resource.SimpleImageCache
-
class SimpleImageCache extends java.lang.ObjectSimple implementation of an image cache.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,PdfXObject>cacheThe cache mapping a source path to an Image XObject.private intcapacityThe capacity of the cache.private java.util.Map<java.lang.String,java.lang.Integer>imagesFrequencyStores how many times each image is used.
-
Constructor Summary
Constructors Constructor Description SimpleImageCache()Creates a newSimpleImageCacheinstance.SimpleImageCache(int capacity)Creates a newSimpleImageCacheinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidensureCapacity()Ensures the capacity of the cache by removing the least important images (based on the number of times an image is used).(package private) PdfXObjectgetImage(java.lang.String src)Gets an image from the cache.(package private) voidputImage(java.lang.String src, PdfXObject imageXObject)Adds an image to the cache.(package private) voidreset()Resets the cache.(package private) intsize()Gets the size of the cache.
-
-
-
Field Detail
-
cache
private java.util.Map<java.lang.String,PdfXObject> cache
The cache mapping a source path to an Image XObject.
-
imagesFrequency
private java.util.Map<java.lang.String,java.lang.Integer> imagesFrequency
Stores how many times each image is used.
-
capacity
private int capacity
The capacity of the cache.
-
-
Constructor Detail
-
SimpleImageCache
SimpleImageCache()
Creates a newSimpleImageCacheinstance.
-
SimpleImageCache
SimpleImageCache(int capacity)
Creates a newSimpleImageCacheinstance.- Parameters:
capacity- the capacity
-
-
Method Detail
-
putImage
void putImage(java.lang.String src, PdfXObject imageXObject)Adds an image to the cache.- Parameters:
src- the source pathimageXObject- the image XObject to be cached
-
getImage
PdfXObject getImage(java.lang.String src)
Gets an image from the cache.- Parameters:
src- the source path- Returns:
- the image XObject
-
size
int size()
Gets the size of the cache.- Returns:
- the cache size
-
reset
void reset()
Resets the cache.
-
ensureCapacity
private void ensureCapacity()
Ensures the capacity of the cache by removing the least important images (based on the number of times an image is used).
-
-