fot2pdf (w) C. Drescher

com.pdftech.fot2pdf.formatter
Class Formatter

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--com.pdftech.fot2pdf.formatter.Formatter
All Implemented Interfaces:
java.lang.Runnable

public class Formatter
extends java.lang.Thread

The core formatting class. This one walks through the given FlowObjectTree recursively, creates the DisplayBoxes, paginates and writes the pages out into the PDF file.


Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Formatter(com.pdftech.fot2pdf.xml.FlowObjectTree fot, java.lang.String outFilename)
           
Formatter(java.lang.ThreadGroup g, com.pdftech.fot2pdf.xml.FlowObjectTree fot, java.lang.String outFilename)
           
 
Method Summary
 double compactDisplayBoxes(com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList DisplayStream, com.pdftech.fot2pdf.tools.LinkedList contentlist)
          This method creates a list of contentboxes from DisplayBoxes.
static com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList filterAnchorBoxes(com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList inlist)
          Takes all anchor boxes from a given display box list; needed for nested objects etc.
static java.lang.String makeAlignedLineDrawString(com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic, double linelen, char orientation, char aligning)
          Creates PDF markup to draw a line based on standard-DSSSL-parameters at position 0/0.
static java.lang.String makeAlignedLineDrawStringXY(com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic, double x, double y, double linelen, char orientation, char aligning)
          Creates PDF markup to draw a line based on standard-DSSSL-parameters.
 com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeBox(com.pdftech.fot2pdf.xml.xmlnode o, com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic)
          Produces a boxed object.
 com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeConditionalSpaceAfter(com.pdftech.fot2pdf.formatter.DSSSL_DisplayNics d)
          Adds space (=glue) if specified in DSSSL, parsing a DisplayNics object.
 com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeConditionalSpaceAfter(com.pdftech.fot2pdf.xml.xmlnode o)
          Adds space (=glue) if specified in DSSSL, parsing an xmlnode into a DisplayNics object.
 com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeConditionalSpaceBefore(com.pdftech.fot2pdf.formatter.DSSSL_DisplayNics d)
          Adds space (=glue) if specified in DSSSL, parsing a DisplayNics object.
 com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeConditionalSpaceBefore(com.pdftech.fot2pdf.xml.xmlnode o)
          Adds space (=glue) if specified in DSSSL, parsing an xmlnode into a DisplayNics object.
 com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeDisplayedGraphic(com.pdftech.fot2pdf.xml.xmlnode o, com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic)
          This routine takes an external graphic and creates a display stream from it.
 com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeDisplayedParagraph(com.pdftech.fot2pdf.xml.xmlnode o, com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic)
          This routine adds a paragraph to a display stream, heeding spaces+keeps.
 com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeDisplayedRule(com.pdftech.fot2pdf.xml.xmlnode o, com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic)
          This routine creates a displayed rule.
 com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeDisplayGroup(com.pdftech.fot2pdf.xml.xmlnode o, com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic)
          Manages a DisplayGroup, first processing all children, then applying any keeps.
static java.lang.String makeLineDrawString(com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic, double linelen, char orientation)
          Creates PDF markup to draw a line based on standard-DSSSL-parameters, centered.
 com.pdftech.fot2pdf.formatter.displayboxes.DisplayBox makePageBreak()
          Adds a page-break display box
 com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeSimpleParagraph(com.pdftech.fot2pdf.xml.xmlnode o, com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic, com.pdftech.fot2pdf.formatter.TextState ts)
          This method constructs an elementary paragraph.
 com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeTable(com.pdftech.fot2pdf.xml.xmlnode o, com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic)
          Adds a Table to the DisplayStream, which in turn calls the LayoutTable routines.
 void paginate(com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList DisplayStream, com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic, com.pdftech.fot2pdf.formatter.PageHeadersAndFooters phf)
          The core pagination routine.
 void resolveAnchorList()
          A routine for resolving all anchors to provide quick lookup.
 void run()
          This is the core routine of the Formatter.
 void writepages()
          The core routine for writing pdf-pages.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Formatter

public Formatter(java.lang.ThreadGroup g,
                 com.pdftech.fot2pdf.xml.FlowObjectTree fot,
                 java.lang.String outFilename)

Formatter

public Formatter(com.pdftech.fot2pdf.xml.FlowObjectTree fot,
                 java.lang.String outFilename)
Method Detail

compactDisplayBoxes

public double compactDisplayBoxes(com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList DisplayStream,
                                  com.pdftech.fot2pdf.tools.LinkedList contentlist)
This method creates a list of contentboxes from DisplayBoxes. It is used for tables and box objects to have content properly formattet to fit into another object.
Parameters:
DisplayStream - The list of DisplayBoxes to be formatted
contentlist - The list where the contentboxes are appended to
Returns:
Height of group

paginate

public void paginate(com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList DisplayStream,
                     com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic,
                     com.pdftech.fot2pdf.formatter.PageHeadersAndFooters phf)
The core pagination routine. Essentially, this is a simple FirstFit algorithm; we put DisplayBoxes onto the page as long as they fit in the space given by the page size less the margins. Of cource, constraints given by certain characteristics (such as "keepwithnext") or those inherent to some problems (such as the avoidance of orphans in paragraphs which actually keeps two lines together) must be fulfilled.
The input is a stream (a list...) of DisplayBoxes, the state of the FlowObjectTree at the start of this pagination (for page size etc.) and the headers&footers meant to be part of the pages.

writepages

public void writepages()
The core routine for writing pdf-pages. We go through all the paginated pages and do the final processing, which includes

resolveAnchorList

public void resolveAnchorList()
A routine for resolving all anchors to provide quick lookup.

makeAlignedLineDrawStringXY

public static java.lang.String makeAlignedLineDrawStringXY(com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic,
                                                           double x,
                                                           double y,
                                                           double linelen,
                                                           char orientation,
                                                           char aligning)
Creates PDF markup to draw a line based on standard-DSSSL-parameters. The string is given by starting position (x/y) and a line length; for horizontal lines, the line goes to the right, for vertial lines it goes down.
The line can be aligned using a parameter of 's','c' or 'e' for start,center or end; this alignment is form the DisplayBox-filling-direction point of view (equal for x, inverse for y to PDF-markers!)

makeAlignedLineDrawString

public static java.lang.String makeAlignedLineDrawString(com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic,
                                                         double linelen,
                                                         char orientation,
                                                         char aligning)
Creates PDF markup to draw a line based on standard-DSSSL-parameters at position 0/0.
See Also:
makeAlignedLineDrawStringXY(com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics, double, double, double, char, char)

makeLineDrawString

public static java.lang.String makeLineDrawString(com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic,
                                                  double linelen,
                                                  char orientation)
Creates PDF markup to draw a line based on standard-DSSSL-parameters, centered.
See Also:
makeAlignedLineDrawString(com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics, double, char, char)

makePageBreak

public com.pdftech.fot2pdf.formatter.displayboxes.DisplayBox makePageBreak()
Adds a page-break display box

makeConditionalSpaceBefore

public com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeConditionalSpaceBefore(com.pdftech.fot2pdf.formatter.DSSSL_DisplayNics d)
Adds space (=glue) if specified in DSSSL, parsing a DisplayNics object.

makeConditionalSpaceBefore

public com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeConditionalSpaceBefore(com.pdftech.fot2pdf.xml.xmlnode o)
Adds space (=glue) if specified in DSSSL, parsing an xmlnode into a DisplayNics object.

makeConditionalSpaceAfter

public com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeConditionalSpaceAfter(com.pdftech.fot2pdf.formatter.DSSSL_DisplayNics d)
Adds space (=glue) if specified in DSSSL, parsing a DisplayNics object.

makeConditionalSpaceAfter

public com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeConditionalSpaceAfter(com.pdftech.fot2pdf.xml.xmlnode o)
Adds space (=glue) if specified in DSSSL, parsing an xmlnode into a DisplayNics object.

makeSimpleParagraph

public com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeSimpleParagraph(com.pdftech.fot2pdf.xml.xmlnode o,
                                                                                     com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic,
                                                                                     com.pdftech.fot2pdf.formatter.TextState ts)
This method constructs an elementary paragraph. It takes all content, builds a LayoutParagraph, makes DisplayBoxes out of it and adds them all up to a DisplayBoxList. If there should be included displayed objects in it, they are processed as well.

makeDisplayedRule

public com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeDisplayedRule(com.pdftech.fot2pdf.xml.xmlnode o,
                                                                                   com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic)
This routine creates a displayed rule.
Internally, it takes an inlined graphic and makes a DisplayBox (heeding any indents) out of it.

makeDisplayedGraphic

public com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeDisplayedGraphic(com.pdftech.fot2pdf.xml.xmlnode o,
                                                                                      com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic)
This routine takes an external graphic and creates a display stream from it.
Internally, it takes an inlined graphic and makes a DisplayBox (heeding any indents) out of it.

makeDisplayedParagraph

public com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeDisplayedParagraph(com.pdftech.fot2pdf.xml.xmlnode o,
                                                                                        com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic)
This routine adds a paragraph to a display stream, heeding spaces+keeps.
See Also:
com.pdftech.fot2pdf.formatter.LayoutParagraph

makeTable

public com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeTable(com.pdftech.fot2pdf.xml.xmlnode o,
                                                                           com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic)
Adds a Table to the DisplayStream, which in turn calls the LayoutTable routines.
See Also:
com.pdftech.fot2pdf.formatter.Formatter.LayoutTable

filterAnchorBoxes

public static com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList filterAnchorBoxes(com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList inlist)
Takes all anchor boxes from a given display box list; needed for nested objects etc.

makeBox

public com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeBox(com.pdftech.fot2pdf.xml.xmlnode o,
                                                                         com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic)
Produces a boxed object. This only cares for displayed box objects, which can contain any other object in turn.

makeDisplayGroup

public com.pdftech.fot2pdf.formatter.displayboxes.DisplayBoxList makeDisplayGroup(com.pdftech.fot2pdf.xml.xmlnode o,
                                                                                  com.pdftech.fot2pdf.formatter.DSSSL_InheritedCharacteristics ic)
Manages a DisplayGroup, first processing all children, then applying any keeps.

run

public void run()
This is the core routine of the Formatter. It processes all elements of the FOT starting at the root node, then resolves all anchors and writes the pdf-pages at the end.
Overrides:
run in class java.lang.Thread

fot2pdf (w) C. Drescher