Class SimpleImageCache
java.lang.Object
com.itextpdf.styledxmlparser.resolver.resource.SimpleImageCache
Simple implementation of an image cache.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<String, PdfXObject> The cache mapping a source path to an Image XObject.private intThe capacity of the cache.Stores how many times each image is used. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newSimpleImageCacheinstance.SimpleImageCache(int capacity) Creates a newSimpleImageCacheinstance. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidEnsures the capacity of the cache by removing the least important images (based on the number of times an image is used).(package private) PdfXObjectGets an image from the cache.(package private) voidputImage(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 Details
-
cache
The cache mapping a source path to an Image XObject. -
imagesFrequency
-
capacity
private int capacityThe capacity of the cache.
-
-
Constructor Details
-
SimpleImageCache
SimpleImageCache()Creates a newSimpleImageCacheinstance. -
SimpleImageCache
SimpleImageCache(int capacity) Creates a newSimpleImageCacheinstance.- Parameters:
capacity- the capacity
-
-
Method Details
-
putImage
Adds an image to the cache.- Parameters:
src- the source pathimageXObject- the image XObject to be cached
-
getImage
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).
-