org.writersforge.catalan.renderers
Class Renderer

java.lang.Object
  extended byorg.writersforge.catalan.renderers.Renderer
Direct Known Subclasses:
PdfRenderer, TextRenderer

public abstract class Renderer
extends java.lang.Object

Abstract base class for rendering Page objects into a final output format. The Renderer will always work on a Book object. The Book should be processed with a RenderTemplate beforehand, and typically a LayoutEngine too. The type of output will depend on the subclass of Renderer.

Derived Renderers can override rendering at the Book level, at the Page level, and at the LayoutArea level. The default implementation of Book and Page rendering should be sufficient for most purposes. The renderArea() method is the most important in this class, and is the one that does all the real Renderer-specific work.

The startPage() and endPage() methods should be overridden if any resources need to be allocated for each Page. Likewise, global resources should be managed in startBook() and endBook().

Author:
jsheets

Constructor Summary
Renderer()
           
 
Method Summary
protected  void endBook(Book book)
          Performs any cleanup that the Renderer must do at the end of the rendering process.
protected  void endPage(Page page)
          Performs any cleanup that the Renderer must do after every Page.
 void render(Book book)
          Renders an entire Book, pulling all data from the Book's Page array.
protected  void renderArea(LayoutArea area)
          Renders a single LayoutArea object within the current Page.
protected  void renderPage(Book book, int pageNumber)
          Renders a single page of a book.
protected abstract  void renderShapeArea(LayoutShape shapeArea)
          Renders a single LayoutShape area within the current Page.
protected abstract  void renderTextArea(LayoutText textArea)
          Renders a single LayoutText area within the current Page.
protected  void startBook(Book book)
          Performs any special initialization that the Renderer must do at the very beginning of the rendering process.
protected  void startPage(Page page)
          Performs any special initialization that the Renderer must do before every Page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Renderer

public Renderer()
Method Detail

renderArea

protected void renderArea(LayoutArea area)
Renders a single LayoutArea object within the current Page.

This base class implementation delegates rendering to renderTextArea() for all LayoutText objects, and renderShapeArea() for all LayoutShape objects. If a renderer needs to support other area types, it can override this method; however, for most cases this implementation should work fine.

Parameters:
area - the LayoutArea object to render

renderTextArea

protected abstract void renderTextArea(LayoutText textArea)
Renders a single LayoutText area within the current Page.

Parameters:
textArea - the LayoutText object to render

renderShapeArea

protected abstract void renderShapeArea(LayoutShape shapeArea)
Renders a single LayoutShape area within the current Page.

Parameters:
shapeArea - the LayoutArea object to render

startBook

protected void startBook(Book book)
Performs any special initialization that the Renderer must do at the very beginning of the rendering process. By default, does nothing.

Parameters:
book - the Book object to initialize with

endBook

protected void endBook(Book book)
Performs any cleanup that the Renderer must do at the end of the rendering process. By default, does nothing.

Parameters:
book - the Book object to clean up

startPage

protected void startPage(Page page)
Performs any special initialization that the Renderer must do before every Page. By default, does nothing.

Parameters:
page - the Page object to initialize with

endPage

protected void endPage(Page page)
Performs any cleanup that the Renderer must do after every Page. By default, does nothing.

Parameters:
page - the Page object to clean up

renderPage

protected void renderPage(Book book,
                          int pageNumber)
Renders a single page of a book.

Parameters:
book - the Book to render
pageNumber - the page index number to render

render

public void render(Book book)
Renders an entire Book, pulling all data from the Book's Page array. The Book must have already been processed by a RenderTemplate.

Parameters:
book - the Book to render