com.levigo.jadice.document.render
Class PageImageRenderer

java.lang.Object
  extended by com.levigo.jadice.document.render.AbstractPageRenderer
      extended by com.levigo.jadice.document.render.PageImageRenderer

public class PageImageRenderer
extends AbstractPageRenderer

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.


Field Summary
protected static Logger LOGGER
           
 
Constructor Summary
PageImageRenderer()
          Creates an instance of this class.
PageImageRenderer(Page page)
          Creates an instance of this class.
PageImageRenderer(Page page, RenderControls renderControl)
          Creates an instance of this class.
 
Method Summary
 Rectangle getRenderArea()
          Returns the page area, which will be used as clip bounds of the rendered image.
 boolean isEnableCaching()
           
protected  void render(Graphics2D target)
          Paint a Page.
 BufferedImage renderImage()
          Creates and returns a buffered image instance representing the entire page content or defined area of the current page.
 void setEnableCaching(boolean enableCaching)
           
 void setRenderArea(Rectangle area)
          Sets the page area, which will be used as clip bounds of the rendered image.
 
Methods inherited from class com.levigo.jadice.document.render.AbstractPageRenderer
getPage, getRenderControls, setPage, setRenderControls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static final Logger LOGGER
Constructor Detail

PageImageRenderer

public PageImageRenderer(Page page,
                         RenderControls renderControl)
Creates an instance of this class.

Parameters:
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.
See Also:
AbstractPageRenderer.setPage(Page), AbstractPageRenderer.setRenderControls(RenderControls)

PageImageRenderer

public PageImageRenderer(Page page)
Creates an instance of this class. For rendering the page into an image a default render context with zoom 100%, rotation 0 and deviceResolution 72dpi will be assumed.

Parameters:
page - The page to be rendered into the buffered image.
See Also:
AbstractPageRenderer.setPage(Page), AbstractPageRenderer.setRenderControls(RenderControls)

PageImageRenderer

public PageImageRenderer()
Creates an instance of this class.

Ensure to set a valid page instance and optionally a render control before calling the renderImage() method. Otherwise the renderImage() method will throw an adequate exception and the page image renderer could not be used.

See Also:
AbstractPageRenderer.setPage(Page), AbstractPageRenderer.setRenderControls(RenderControls)
Method Detail

getRenderArea

public Rectangle getRenderArea()
Returns the page area, which will be used as clip bounds of the rendered image.

The render area can be defined with a call of setRenderArea(Rectangle). If no render 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 renderArea = new Rectangle(0,0,size.width, size.height);

Returns:
Rectangle the area to be rendered

setRenderArea

public void setRenderArea(Rectangle area)
Sets the page area, which will be used as clip bounds of the rendered image.

The render area can be accessed with a call of getRenderArea(). 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 renderArea = 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.

Parameters:
area - the render area used within renderImage() or null if the entire page bounds should be used
Throws:
IllegalArgumentException - if the given area is not entirely contained in the page bounds
IllegalStateException - if no page is available

renderImage

public BufferedImage renderImage()
Creates and returns a buffered image instance representing the entire page content or defined area of the current page. The render characteristics are defined with the current render context.

Returns:
an image of the page or an image of a page part defined by the render area. If the current page reference is NULL an IllegalStateException will be thrown.
Throws:
IllegalStateException - if page reference is null
See Also:
AbstractPageRenderer.getPage(), AbstractPageRenderer.getRenderControls(), getRenderArea()

render

protected void render(Graphics2D target)
               throws JadiceException
Description copied from class: AbstractPageRenderer
Paint a Page. This method will paint the Page set using AbstractPageRenderer.setPage(Page) or if the Page is null, return immediately.

Specified by:
render in class AbstractPageRenderer
Parameters:
target - the Graphics2D to paint to.
Throws:
JadiceException - will be thrown if the initialization or the rendering of the Page failed.

isEnableCaching

public boolean isEnableCaching()

setEnableCaching

public void setEnableCaching(boolean enableCaching)


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.