org.writersforge.catalan.templates
Class GenericTemplate

java.lang.Object
  extended byorg.writersforge.catalan.templates.RenderTemplate
      extended byorg.writersforge.catalan.templates.GenericTemplate

public class GenericTemplate
extends RenderTemplate

A configurable template driven by an XML layout template which can transform arbitrary XML inputs into layouts.

Author:
jsheets

Constructor Summary
GenericTemplate()
           
 
Method Summary
protected  LayoutArea[] buildFlowLayout(Section section, java.lang.String regionName, Book book)
          Renders a single flow region in the current section, using the data in the Book as an input source.
protected  LayoutArea[] buildStaticLayout(Section section, java.lang.String regionName, Book book)
          Renders a single static region in the current section, using the data in the Book as an input source.
protected  Page createNewPage(Book book)
          Creates a new Page object, initialized with width, height, and margins appropriate to this template and Book.
 int getDefaultPageHeight()
          Retrieves the default Page height for this template.
 int getDefaultPageWidth()
          Retrieves the default Page width for this template.
protected  Section[] getSections()
          Returns an array of all Section objects associated with this template.
 boolean loadTemplate(org.writersforge.bellows.ListDatum root)
          Loads the XML layout template.
 boolean loadTemplate(java.io.Reader reader)
          Loads the XML layout template.
 
Methods inherited from class org.writersforge.catalan.templates.RenderTemplate
getCurrentPage, getLayout, listToDatumArray, listToLayoutAreaArray, process, renderSection, setCurrentPage, setLayout, sortAreas
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericTemplate

public GenericTemplate()
Method Detail

loadTemplate

public boolean loadTemplate(java.io.Reader reader)
Loads the XML layout template.

Parameters:
reader - the XML layout template
Returns:
true if the template loaded successfully

loadTemplate

public boolean loadTemplate(org.writersforge.bellows.ListDatum root)
Loads the XML layout template.

Parameters:
root - the XML layout template
Returns:
true if the template loaded successfully

getDefaultPageWidth

public int getDefaultPageWidth()
Retrieves the default Page width for this template. The units don't really matter, since the template can just create LayoutAreas to whatever scale it wants.

Specified by:
getDefaultPageWidth in class RenderTemplate
Returns:
the default Page width, in arbitrary units

getDefaultPageHeight

public int getDefaultPageHeight()
Retrieves the default Page height for this template. The units don't really matter, since the template can just create LayoutAreas to whatever scale it wants.

Specified by:
getDefaultPageHeight in class RenderTemplate
Returns:
the default Page height, in arbitrary units

createNewPage

protected Page createNewPage(Book book)
Creates a new Page object, initialized with width, height, and margins appropriate to this template and Book.

Overrides:
createNewPage in class RenderTemplate
Parameters:
book - the owning Book object for the new Page
Returns:
a newly created Page object

getSections

protected Section[] getSections()
Returns an array of all Section objects associated with this template. Each Section represents a series of pages in the document with similar structure.

Specified by:
getSections in class RenderTemplate
Returns:
an array of Section objects

buildStaticLayout

protected LayoutArea[] buildStaticLayout(Section section,
                                         java.lang.String regionName,
                                         Book book)
Renders a single static region in the current section, using the data in the Book as an input source. The created LayoutArea objects are in a simplified, transitional state, with a single area for each block of text. (Later in the rendering process, these transitional areas will be further decomposed into separate areas per line of text, and perhaps split across two or more pages.) This method should call sortAreas() at some point.

Specified by:
buildStaticLayout in class RenderTemplate
Parameters:
section - the Section object to render
regionName - the name of the region in this section to process
book - the data source
Returns:
an array of partially rendered LayoutArea objects

buildFlowLayout

protected LayoutArea[] buildFlowLayout(Section section,
                                       java.lang.String regionName,
                                       Book book)
Renders a single flow region in the current section, using the data in the Book as an input source. The created LayoutArea objects are in a simplified, transitional state, with a single area for each block of text. (Later in the rendering process, these transitional areas will be further decomposed into separate areas per line of text, and perhaps split across two or more pages.) This method should call sortAreas() at some point.

Specified by:
buildFlowLayout in class RenderTemplate
Parameters:
section - the Section object to render
regionName - the name of the region in this section to process
book - the data source
Returns:
an array of partially rendered LayoutArea objects