org.writersforge.catalan.layout
Class AsciiLayout

java.lang.Object
  |
  +--org.writersforge.catalan.layout.AbstractLayoutEngine
        |
        +--org.writersforge.catalan.layout.AsciiLayout
All Implemented Interfaces:
LayoutEngine

public class AsciiLayout
extends AbstractLayoutEngine

Ascii art-style layout engine, a starting point for the TextRenderer

Author:
jsheets

Constructor Summary
AsciiLayout()
           
 
Method Summary
protected  LayoutArea addToPage(Page page, LayoutArea area)
          Attempts to add a single area to the Page.
 boolean fitsInRegion(LayoutArea area, java.awt.Rectangle region, java.util.List areasInRegion)
          Checks to see if the area will fit in the given region.
protected  boolean fitsOnPage(Page page, LayoutArea area)
          Checks to see if the area will fit on the given Page.
 LayoutArea[] layoutPage(Page page, LayoutArea[] areas)
          Adds as many areas to the Page as will fit; returns the rest of them for the next Page.
 void layoutRegion(LayoutContext context, java.awt.Rectangle region)
          Attempts to lay out as many of the pending areas in the context as it can, into the provided region's bounding box.
 
Methods inherited from class org.writersforge.catalan.layout.AbstractLayoutEngine
acceptArea, clearQueue, fitsInRegion, getFreeSpace, getQueueSize, guessSize, layoutAreas, setCurrentRegion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsciiLayout

public AsciiLayout()
Method Detail

layoutPage

public LayoutArea[] layoutPage(Page page,
                               LayoutArea[] areas)
Adds as many areas to the Page as will fit; returns the rest of them for the next Page. The returned areas should be moved to a relative offset of zero, so they will appear at the top of the next Page by default.

Parameters:
page - the target Page to add LayoutAreas to
areas - an array of areas to pack into the Page
Returns:
areas that didn't fit on the Page, or a zero-length array if they all fit

fitsOnPage

protected boolean fitsOnPage(Page page,
                             LayoutArea area)
Checks to see if the area will fit on the given Page.

Parameters:
page - the Page to test the area against
area - the area to test
Returns:
true if the area fits on the Page

addToPage

protected LayoutArea addToPage(Page page,
                               LayoutArea area)
Attempts to add a single area to the Page. If the area does not fit, return a new area which represents the rejected portion of the content, or simply return the whole area. If this area has a keepWith constraint, it should not attempt to break the area into fragments, i.e., keepWith overrides isAtomic().

Parameters:
page - the target Page
area - the LayoutArea to attempt to add to the Page
Returns:
the rejected portion of the area, or null if the area was accepted in full

layoutRegion

public void layoutRegion(LayoutContext context,
                         java.awt.Rectangle region)
Attempts to lay out as many of the pending areas in the context as it can, into the provided region's bounding box.

Parameters:
context - the running context for this rendering pass
region - the bounding area to render areas into

fitsInRegion

public boolean fitsInRegion(LayoutArea area,
                            java.awt.Rectangle region,
                            java.util.List areasInRegion)
Checks to see if the area will fit in the given region. The areasInRegion parameter may contain an optional array of LayoutArea objects that the engine has already fitted into the region. This method should take these pre-existing areas into account. If no areas are currently in the region, areasInRegion can be null or an empty array.

Parameters:
area - the LayoutArea object to try to fit
region - the bounding area of the region
areasInRegion - optional list of areas already in the region
Returns:
true if the area fits in the region, or false if not