Package com.sun.pdfview
Class Cache
- java.lang.Object
-
- com.sun.pdfview.Cache
-
public class Cache extends java.lang.Object
A cache of PDF pages and images.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
Cache.PageRecord
the record stored for each page in the cache(package private) class
Cache.Record
the basic information about a page or image
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Integer,java.lang.ref.SoftReference>
pages
the pages in the cache, mapped by page number
-
Constructor Summary
Constructors Constructor Description Cache()
Creates a new instance of a Cache
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addImage(PDFPage page, ImageInfo info, java.awt.image.BufferedImage image)
Add an image to the cache.void
addImage(PDFPage page, ImageInfo info, java.awt.image.BufferedImage image, PDFRenderer renderer)
Add an image to the cache.(package private) Cache.Record
addImageRecord(PDFPage page, ImageInfo info, java.awt.image.BufferedImage image, PDFRenderer renderer)
The internal routine to add an image to the cache and return the record that was generated.void
addPage(java.lang.Integer pageNumber, PDFPage page)
Add a page to the cache.void
addPage(java.lang.Integer pageNumber, PDFPage page, PDFParser parser)
Add a page to the cache.(package private) Cache.PageRecord
addPageRecord(java.lang.Integer pageNumber, PDFPage page, PDFParser parser)
The internal routine to add a page to the cache, and return the page record which was generatedjava.awt.image.BufferedImage
getImage(PDFPage page, ImageInfo info)
Get an image from the cache(package private) Cache.Record
getImageRecord(PDFPage page, ImageInfo info)
Get an image's record from the cachePDFRenderer
getImageRenderer(PDFPage page, ImageInfo info)
Get an image's renderer from the cachePDFPage
getPage(java.lang.Integer pageNumber)
Get a page from the cachePDFParser
getPageParser(java.lang.Integer pageNumber)
Get a page's parser from the cache(package private) Cache.PageRecord
getPageRecord(java.lang.Integer pageNumber)
Get a page's record from the cachevoid
removeImage(PDFPage page, ImageInfo info)
Remove an image and its associated renderer from the cache(package private) Cache.Record
removeImageRecord(PDFPage page, ImageInfo info)
Remove an image's record from the cachevoid
removePage(java.lang.Integer pageNumber)
Remove a page and all its associated images, as well as its parser and renderers, from the cache(package private) Cache.PageRecord
removePageRecord(java.lang.Integer pageNumber)
Remove a page's record from the cache
-
-
-
Method Detail
-
addPage
public void addPage(java.lang.Integer pageNumber, PDFPage page)
Add a page to the cache. This method should be used for pages which have already been completely rendered.- Parameters:
pageNumber
- the page number of this pagepage
- the page to add
-
addPage
public void addPage(java.lang.Integer pageNumber, PDFPage page, PDFParser parser)
Add a page to the cache. This method should be used for pages which are still in the process of being rendered.- Parameters:
pageNumber
- the page number of this pagepage
- the page to addparser
- the parser which is parsing this page
-
addImage
public void addImage(PDFPage page, ImageInfo info, java.awt.image.BufferedImage image)
Add an image to the cache. This method should be used for images which have already been completely rendered- Parameters:
page
- page this image is associated withinfo
- the image info associated with this imageimage
- the image to add
-
addImage
public void addImage(PDFPage page, ImageInfo info, java.awt.image.BufferedImage image, PDFRenderer renderer)
Add an image to the cache. This method should be used for images which are still in the process of being rendered.- Parameters:
page
- the page this image is associated withinfo
- the image info associated with this imageimage
- the image to addrenderer
- the renderer which is rendering this page
-
getPage
public PDFPage getPage(java.lang.Integer pageNumber)
Get a page from the cache- Parameters:
pageNumber
- the number of the page to get- Returns:
- the page, if it is in the cache, or null if not
-
getPageParser
public PDFParser getPageParser(java.lang.Integer pageNumber)
Get a page's parser from the cache- Parameters:
pageNumber
- the number of the page to get the parser for- Returns:
- the parser, or null if it is not in the cache
-
getImage
public java.awt.image.BufferedImage getImage(PDFPage page, ImageInfo info)
Get an image from the cache- Parameters:
page
- the page the image is associated withinfo
- the image info that describes the image- Returns:
- the image if it is in the cache, or null if not
-
getImageRenderer
public PDFRenderer getImageRenderer(PDFPage page, ImageInfo info)
Get an image's renderer from the cache- Parameters:
page
- the page this image was generated frominfo
- the image info describing the image- Returns:
- the renderer, or null if it is not in the cache
-
removePage
public void removePage(java.lang.Integer pageNumber)
Remove a page and all its associated images, as well as its parser and renderers, from the cache- Parameters:
pageNumber
- the number of the page to remove
-
removeImage
public void removeImage(PDFPage page, ImageInfo info)
Remove an image and its associated renderer from the cache- Parameters:
page
- the page the image is generated frominfo
- the image info of the image to remove
-
addPageRecord
Cache.PageRecord addPageRecord(java.lang.Integer pageNumber, PDFPage page, PDFParser parser)
The internal routine to add a page to the cache, and return the page record which was generated
-
getPageRecord
Cache.PageRecord getPageRecord(java.lang.Integer pageNumber)
Get a page's record from the cache- Returns:
- the record, or null if it's not in the cache
-
removePageRecord
Cache.PageRecord removePageRecord(java.lang.Integer pageNumber)
Remove a page's record from the cache
-
addImageRecord
Cache.Record addImageRecord(PDFPage page, ImageInfo info, java.awt.image.BufferedImage image, PDFRenderer renderer)
The internal routine to add an image to the cache and return the record that was generated.
-
getImageRecord
Cache.Record getImageRecord(PDFPage page, ImageInfo info)
Get an image's record from the cache- Returns:
- the record, or null if it's not in the cache
-
removeImageRecord
Cache.Record removeImageRecord(PDFPage page, ImageInfo info)
Remove an image's record from the cache
-
-