org.writersforge.catalan.layout
Class Book

java.lang.Object
  extended byorg.writersforge.catalan.layout.Book

public class Book
extends java.lang.Object

A collection of Page objects, to be passed on to a Renderer. The Book is essentially an object that wraps data and helps manage it. The raw input data resides in a Bellows ListDatum object tree, and is typically treated as read-only data. The RenderTemplate converts the raw Datum objects into generic LayoutArea objects, packs them in Page objects, and places the Page objects back in the Book. At the end of the layout process, the Book contains essentially two copies of the same data: the raw data in the Datum tree, and the sorted, ready-to-render data in an array of Page objects.

Author:
jsheets

Constructor Summary
Book(org.writersforge.bellows.ListDatum data)
          Creates a new instance of Book
 
Method Summary
 void addPage(Page page)
          Appends a new Page object into the Book.
 void clearPages()
          Removes all current pages.
 Page getCurrentPage()
          Gets the current page object in this Book.
 int getCurrentPageNumber()
          Gets the current page number in this Book.
 org.writersforge.bellows.ListDatum getData()
          Gets the Book's raw input data
 Page getPage(int pageNum)
          Gets a single processed page.
 Page[] getPages()
          Gets the array of processed pages.
 java.lang.Object getProperty(java.lang.String name)
          Returns the value of a generic property.
 void removeProperty(java.lang.String name)
          Delete all traces of the named property
 void setCurrentPageNumber(int pageNum)
          Sets the current page number in this Book.
 void setProperty(java.lang.String name, java.lang.Object value)
          Assigns a value to a generic property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Book

public Book(org.writersforge.bellows.ListDatum data)
Creates a new instance of Book

Parameters:
data - the raw input data tree
Method Detail

getPages

public Page[] getPages()
Gets the array of processed pages. The RenderTemplate creates and populates the Page objects with LayoutArea objects. A LayoutEngine might also take part.

Returns:
the array of processed pages

getPage

public Page getPage(int pageNum)
Gets a single processed page. If the requested Page does not exist, return a null.

Parameters:
pageNum - the index number for the Page
Returns:
a single processed page, or null if pageNum is out of bounds

setCurrentPageNumber

public void setCurrentPageNumber(int pageNum)
Sets the current page number in this Book. The current page is used during rendering to cycle through pages without requiring a separate page argument to all rendering methods.

Parameters:
pageNum - the index of the new current page
Throws:
java.lang.IllegalArgumentException - if the given page number is not in the valid range of pages in this Book

getCurrentPageNumber

public int getCurrentPageNumber()
Gets the current page number in this Book. The current page is used during rendering to cycle through pages without requiring a separate page argument to all rendering methods.

Returns:
the index of the current page

getCurrentPage

public Page getCurrentPage()
Gets the current page object in this Book. The current page is used during rendering to cycle through pages without requiring a separate page argument to all rendering methods.

Returns:
the current Page object

clearPages

public void clearPages()
Removes all current pages.


addPage

public void addPage(Page page)
Appends a new Page object into the Book.

Parameters:
page - new Page object to append

getData

public org.writersforge.bellows.ListDatum getData()
Gets the Book's raw input data

Returns:
the Book's data

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)
Assigns a value to a generic property. Book properties are used by the Renderer to customize the output for a particular Book. Given the same root Datum and RenderTemplate sources, a Book can still be rendered differently according to its Book properties. For example, properties might control how many pages of Book to squeeze in per printed page.

Parameters:
name - the name of the Book property
value - the value of the property (the Renderer must be able to handle objects of the given type)

getProperty

public java.lang.Object getProperty(java.lang.String name)
Returns the value of a generic property. Book properties are used by the Renderer to customize the output for a particular Book. Given the same root Datum and RenderTemplate sources, a Book can still be rendered differently according to its Book properties. For example, properties might control how many pages of Book to squeeze in per printed page.

Parameters:
name - the name of the Book property
Returns:
the value of the property

removeProperty

public void removeProperty(java.lang.String name)
Delete all traces of the named property

Parameters:
name - the name of the Book property