public class PageImageRenderer extends AbstractRenderer
PageImageRenderer
provides an easy possibility to obtain a buffered image which
displays a defined area of a page or an entire Page
.
To render a page into an image, just instantiate this class with a valid page instance and
optionally with a render control which should be applied in the render process. Afterwards just
call the renderImage()
method, which returns the desired page representing image.
Modifier and Type | Field and Description |
---|---|
protected static Logger |
LOGGER |
graphicsContextRenderer
Constructor and Description |
---|
PageImageRenderer(Page page)
Creates an instance of this class.
|
PageImageRenderer(Page page,
RenderControls renderControl)
Creates an instance of this class.
|
Modifier and Type | Method and Description |
---|---|
Rectangle |
getClip()
Returns the area, which will be used as clip bounds of the
rendered image . |
Page |
getPage()
Returns the page to be rendered.
|
boolean |
isEnableCaching()
If there are multiple rendering calls on the same page an enabled caching allows to reuse prior
generated resources and render preparations.
|
protected void |
render(Graphics2D target)
Renders contents into given
Graphics2D . |
BufferedImage |
renderImage()
Creates and returns a buffered image instance representing the entire page content or defined
area of the current page.
|
void |
setClip(Rectangle area)
Sets the area, which will be used as clip bounds of the
rendered image . |
void |
setEnableCaching(boolean enableCaching)
If there are multiple rendering calls on the same page an enabled caching allows to reuse prior
generated resources and render preparations.
|
getRenderControls, setRenderControls
protected static final Logger LOGGER
public PageImageRenderer(Page page, RenderControls renderControl)
page
- The page to be rendered into the buffered image.renderControl
- The render control to be applied when rendering the page into a buffered
image. If the render control is NULL
, a default render control with zoom
100%, rotation 0 and deviceResolution 72dpi will be assumed.AbstractRenderer.setRenderControls(RenderControls)
public PageImageRenderer(Page page)
page
- The page to be rendered into the buffered image.AbstractRenderer.setRenderControls(RenderControls)
public Rectangle getClip()
rendered image
.
The render area can be defined with a call of setClip(Rectangle)
. If no clipping
area is defined the entire page bounds will be used. The entire page bounds are defined as
follows:
Dimension size = Pages.getRenderedSize(getPage(), getRenderControls());
Rectangle clip = new Rectangle(0,0,size.width, size.height);
public void setClip(Rectangle area)
rendered image
.
The clipping area can be accessed with a call of getClip()
. If no render area is
defined by a call of this method the entire page bounds will be used. The entire page bounds
are defined as follows:
Dimension size = Pages.getRenderedSize(getPage(), getRenderControls());
Rectangle clip = new Rectangle(0,0,size.width, size.height);
The given render area should be in device coordinates and must be entirely contained within the page bounds.
area
- the render area used within renderImage()
or null
if the entire page bounds should be usedIllegalArgumentException
- if the given area is not entirely contained in the page boundsIllegalStateException
- if no page is availablepublic BufferedImage renderImage()
NULL
an IllegalStateException
will be
thrown.IllegalStateException
- if page reference is null
getPage()
,
AbstractRenderer.getRenderControls()
,
getClip()
protected void render(Graphics2D target) throws JadiceException
AbstractRenderer
Graphics2D
.render
in class AbstractRenderer
target
- the Graphics2D
to paint to.JadiceException
- will be thrown if a problem occured while renderingpublic boolean isEnableCaching()
public void setEnableCaching(boolean enableCaching)
enableCaching
- Set to true
caching is enabled, false
disables
caching.Copyright © 2024 levigo holding gmbh. All rights reserved.