|
Side of Software Print Preview Library 1.8.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sos.preview.CachingPageable
A java.awt.print.Pageable
wrapper that caches page images rendered at 100%.
This class can be used when page rendering is slow. With this class, page rendering is
done once, and the images are cached. Caching is done lazily, that is, only
when actual rendering is needed. This is in contrast to the behavior of
PageableAdapter
, which caches all pages up front.
Since cached page images occupy a lot of memory, this class has an option to be memory sensitive. If set to true, this class uses soft references to store cached images. When memory is in demand, these soft references are cleared, and images are re-cached.
To convert an existing pageable to a caching pageable,
create an instance of CachingPageable
,
passing the pageable object and a flag indicating whether or
not it should be memory sensitive.
An instance of CachingPageable
can be used anywhere a
Pageable
object is accepted. For instance, it can be
passed to JPrintPreviewPane.setPageable(java.awt.print.Pageable)
.
Since CachingPageable
renders images at 100%,
pages will appear pixilated if used in a print preview panel at
zoom levels other than 100%.
For smooth zooming while still using a cache, use
BasicPrintPreviewPageUI.CACHING_POLICY_KEY
instead of this class.
PageableAdapter
,
BasicPrintPreviewPageUI.CACHING_POLICY_KEY
Field Summary |
Fields inherited from interface java.awt.print.Pageable |
UNKNOWN_NUMBER_OF_PAGES |
Constructor Summary | |
CachingPageable(java.awt.print.Pageable pageable)
Creates a new instance of CachingPageable |
|
CachingPageable(java.awt.print.Pageable pageable,
boolean memorySensitive)
|
Method Summary | |
int |
getNumberOfPages()
Returns the number of pages in the set. |
java.awt.print.PageFormat |
getPageFormat(int pageIndex)
Returns the PageFormat of the page specified by
pageIndex . |
java.awt.print.Printable |
getPrintable(int pageIndex)
Returns the Printable instance responsible for
rendering the page specified by pageIndex . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public CachingPageable(java.awt.print.Pageable pageable)
public CachingPageable(java.awt.print.Pageable pageable, boolean memorySensitive)
Method Detail |
public int getNumberOfPages()
Pageable
implementations return the true number of pages
rather than the
UNKNOWN_NUMBER_OF_PAGES constant.
getNumberOfPages
in interface java.awt.print.Pageable
Pageable
.public java.awt.print.PageFormat getPageFormat(int pageIndex) throws java.lang.IndexOutOfBoundsException
PageFormat
of the page specified by
pageIndex
.
getPageFormat
in interface java.awt.print.Pageable
pageIndex
- the zero based index of the page whose
PageFormat
is being requested
PageFormat
describing the size and
orientation.
java.lang.IndexOutOfBoundsException
- if
the Pageable
does not contain the requested
page.public java.awt.print.Printable getPrintable(int pageIndex) throws java.lang.IndexOutOfBoundsException
Printable
instance responsible for
rendering the page specified by pageIndex
.
getPrintable
in interface java.awt.print.Pageable
pageIndex
- the zero based index of the page whose
Printable
is being requested
Printable
that renders the page.
java.lang.IndexOutOfBoundsException
- if
the Pageable
does not contain the requested
page.
|
Side of Software Print Preview Library 1.8.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |