You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <HTML><HEAD><SCRIPT language="JavaScript" src="resources/script.js" type="text/javascript"></SCRIPT><TITLE>FOP Mechanics</TITLE></HEAD><BODY alink="#ff0000" bgcolor="#ffffff" leftmargin="4" link="#0000ff" marginheight="4" marginwidth="4" text="#000000" topmargin="4" vlink="#0000aa"><TABLE border="0" cellpadding="0" cellspacing="0" width="620"><TR><TD align="left" height="60" rowspan="3" valign="top" width="135"><IMG border="0" height="60" hspace="0" src="resources/logo.gif" vspace="0" width="135"></TD><TD align="left" colspan="4" height="5" valign="top" width="456"><IMG border="0" height="5" hspace="0" src="resources/line.gif" vspace="0" width="456"></TD><TD align="left" height="60" rowspan="3" valign="top" width="29"><IMG border="0" height="60" hspace="0" src="resources/right.gif" vspace="0" width="29"></TD></TR><TR><TD align="left" bgcolor="#0086b2" colspan="4" height="35" valign="top" width="456"><IMG alt="" border="0" height="35" hspace="0" src="graphics/architecture-header.jpg" vspace="0" width="456"></TD></TR><TR><TD align="left" height="20" valign="top" width="168"><IMG border="0" height="20" hspace="0" src="resources/bottom.gif" vspace="0" width="168"></TD><TD align="left" height="20" valign="top" width="96"><A href="http://xml.apache.org/" onMouseOut="rolloverOff('xml');" onMouseOver="rolloverOn('xml');" target="new"><IMG alt="http://xml.apache.org/" border="0" height="20" hspace="0" name="xml" onLoad="rolloverLoad('xml','resources/button-xml-hi.gif','resources/button-xml-lo.gif');" src="resources/button-xml-lo.gif" vspace="0" width="96"></A></TD><TD align="left" height="20" valign="top" width="96"><A href="http://www.apache.org/" onMouseOut="rolloverOff('asf');" onMouseOver="rolloverOn('asf');" target="new"><IMG alt="http://www.apache.org/" border="0" height="20" hspace="0" name="asf" onLoad="rolloverLoad('asf','resources/button-asf-hi.gif','resources/button-asf-lo.gif');" src="resources/button-asf-lo.gif" vspace="0" width="96"></A></TD><TD align="left" height="20" valign="top" width="96"><A href="http://www.w3.org/" onMouseOut="rolloverOff('w3c');" onMouseOver="rolloverOn('w3c');" target="new"><IMG alt="http://www.w3.org/" border="0" height="20" hspace="0" name="w3c" onLoad="rolloverLoad('w3c','resources/button-w3c-hi.gif','resources/button-w3c-lo.gif');" src="resources/button-w3c-lo.gif" vspace="0" width="96"></A></TD></TR></TABLE><TABLE border="0" cellpadding="0" cellspacing="0" width="620"><TR><TD align="left" valign="top" width="120"><IMG border="0" height="14" hspace="0" src="resources/join.gif" vspace="0" width="120"><BR>
  2. <A href="../index.html" onMouseOut="rolloverOff('side-ext-2');" onMouseOver="rolloverOn('side-ext-2');"><IMG alt="Home" border="0" height="12" hspace="0" name="side-ext-2" onLoad="rolloverLoad('side-ext-2','graphics/ext-2-label-2.jpg','graphics/ext-2-label-3.jpg');" src="graphics/ext-2-label-3.jpg" vspace="0" width="120"></A><BR>
  3. <IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
  4. <A href="index.html" onMouseOut="rolloverOff('side-index');" onMouseOver="rolloverOn('side-index');"><IMG alt="Readme" border="0" height="12" hspace="0" name="side-index" onLoad="rolloverLoad('side-index','graphics/index-label-2.jpg','graphics/index-label-3.jpg');" src="graphics/index-label-3.jpg" vspace="0" width="120"></A><BR>
  5. <A href="download.html" onMouseOut="rolloverOff('side-download');" onMouseOver="rolloverOn('side-download');"><IMG alt="Download" border="0" height="12" hspace="0" name="side-download" onLoad="rolloverLoad('side-download','graphics/download-label-2.jpg','graphics/download-label-3.jpg');" src="graphics/download-label-3.jpg" vspace="0" width="120"></A><BR>
  6. <A href="running.html" onMouseOut="rolloverOff('side-running');" onMouseOver="rolloverOn('side-running');"><IMG alt="Running FOP" border="0" height="12" hspace="0" name="side-running" onLoad="rolloverLoad('side-running','graphics/running-label-2.jpg','graphics/running-label-3.jpg');" src="graphics/running-label-3.jpg" vspace="0" width="120"></A><BR>
  7. <A href="implemented.html" onMouseOut="rolloverOff('side-implemented');" onMouseOver="rolloverOn('side-implemented');"><IMG alt="Features" border="0" height="12" hspace="0" name="side-implemented" onLoad="rolloverLoad('side-implemented','graphics/implemented-label-2.jpg','graphics/implemented-label-3.jpg');" src="graphics/implemented-label-3.jpg" vspace="0" width="120"></A><BR>
  8. <A href="limitations.html" onMouseOut="rolloverOff('side-limitations');" onMouseOver="rolloverOn('side-limitations');"><IMG alt="Limitations" border="0" height="12" hspace="0" name="side-limitations" onLoad="rolloverLoad('side-limitations','graphics/limitations-label-2.jpg','graphics/limitations-label-3.jpg');" src="graphics/limitations-label-3.jpg" vspace="0" width="120"></A><BR>
  9. <A href="bugs.html" onMouseOut="rolloverOff('side-bugs');" onMouseOver="rolloverOn('side-bugs');"><IMG alt="Bugs" border="0" height="12" hspace="0" name="side-bugs" onLoad="rolloverLoad('side-bugs','graphics/bugs-label-2.jpg','graphics/bugs-label-3.jpg');" src="graphics/bugs-label-3.jpg" vspace="0" width="120"></A><BR>
  10. <A href="examples.html" onMouseOut="rolloverOff('side-examples');" onMouseOver="rolloverOn('side-examples');"><IMG alt="Examples" border="0" height="12" hspace="0" name="side-examples" onLoad="rolloverLoad('side-examples','graphics/examples-label-2.jpg','graphics/examples-label-3.jpg');" src="graphics/examples-label-3.jpg" vspace="0" width="120"></A><BR>
  11. <IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
  12. <A href="compiling.html" onMouseOut="rolloverOff('side-compiling');" onMouseOver="rolloverOn('side-compiling');"><IMG alt="Compiling" border="0" height="12" hspace="0" name="side-compiling" onLoad="rolloverLoad('side-compiling','graphics/compiling-label-2.jpg','graphics/compiling-label-3.jpg');" src="graphics/compiling-label-3.jpg" vspace="0" width="120"></A><BR>
  13. <A href="embedding.html" onMouseOut="rolloverOff('side-embedding');" onMouseOver="rolloverOn('side-embedding');"><IMG alt="Embedding" border="0" height="12" hspace="0" name="side-embedding" onLoad="rolloverLoad('side-embedding','graphics/embedding-label-2.jpg','graphics/embedding-label-3.jpg');" src="graphics/embedding-label-3.jpg" vspace="0" width="120"></A><BR>
  14. <A href="involved.html" onMouseOut="rolloverOff('side-involved');" onMouseOver="rolloverOn('side-involved');"><IMG alt="Getting involved" border="0" height="12" hspace="0" name="side-involved" onLoad="rolloverLoad('side-involved','graphics/involved-label-2.jpg','graphics/involved-label-3.jpg');" src="graphics/involved-label-3.jpg" vspace="0" width="120"></A><BR>
  15. <IMG border="0" height="6" hspace="0" src="resources/separator.gif" vspace="0" width="120"><BR>
  16. <A href="faqs.html" onMouseOut="rolloverOff('side-faqs');" onMouseOver="rolloverOn('side-faqs');"><IMG alt="FAQs" border="0" height="12" hspace="0" name="side-faqs" onLoad="rolloverLoad('side-faqs','graphics/faqs-label-2.jpg','graphics/faqs-label-3.jpg');" src="graphics/faqs-label-3.jpg" vspace="0" width="120"></A><BR>
  17. <A href="specs.html" onMouseOut="rolloverOff('side-specs');" onMouseOver="rolloverOn('side-specs');"><IMG alt="Specifications" border="0" height="12" hspace="0" name="side-specs" onLoad="rolloverLoad('side-specs','graphics/specs-label-2.jpg','graphics/specs-label-3.jpg');" src="graphics/specs-label-3.jpg" vspace="0" width="120"></A><BR>
  18. <A href="license.html" onMouseOut="rolloverOff('side-license');" onMouseOver="rolloverOn('side-license');"><IMG alt="License" border="0" height="12" hspace="0" name="side-license" onLoad="rolloverLoad('side-license','graphics/license-label-2.jpg','graphics/license-label-3.jpg');" src="graphics/license-label-3.jpg" vspace="0" width="120"></A><BR>
  19. <IMG border="0" height="14" hspace="0" src="resources/close.gif" vspace="0" width="120"><BR></TD><TD align="left" valign="top" width="500"><TABLE border="0" cellpadding="3" cellspacing="0"><TR><TD>
  20. <TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="666699" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Introduction</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
  21. <P>
  22. The overall process is controlled by <B>org.apache.fop.apps.Driver</B>. In
  23. this class, a typical sequence is:</P>
  24. <P><CODE><FONT face="courier, monospaced">Driver driver = new Driver();</FONT></CODE></P>
  25. <P><CODE><FONT face="courier, monospaced">driver.setRenderer(&quot;org.apache.fop.render.pdf.PDFRenderer&quot;, version);</FONT></CODE></P>
  26. <P><CODE><FONT face="courier, monospaced">driver.addElementMapping(&quot;org.apache.fop.fo.StandardElementMapping&quot;);</FONT></CODE></P>
  27. <P><CODE><FONT face="courier, monospaced">driver.addElementMapping(&quot;org.apache.fop.svg.SVGElementMapping&quot;);</FONT></CODE></P>
  28. <P><CODE><FONT face="courier, monospaced">driver.setWriter(new PrintWriter(new FileWriter(args[1])));</FONT></CODE></P>
  29. <P></P>
  30. <P><CODE><FONT face="courier, monospaced">driver.buildFOTree(parser, fileInputSource(args[0]));</FONT></CODE></P>
  31. <P></P>
  32. <P><CODE><FONT face="courier, monospaced">driver.format();</FONT></CODE></P>
  33. <P></P>
  34. <P><CODE><FONT face="courier, monospaced">driver.render();</FONT></CODE></P>
  35. </FONT></TD></TR></TABLE><BR>
  36. <TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="666699" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Formatting Object Tree</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
  37. <P>The class <B>org.apache.fop.fo.FOTreeBuilder</B> is responsible for actually
  38. constructing the FO tree. The key SAX events used are </P>
  39. <P><CODE><FONT face="courier, monospaced">startElement()</FONT></CODE>,</P>
  40. <P><CODE><FONT face="courier, monospaced">endElement()</FONT></CODE> and <CODE><FONT face="courier, monospaced">characters()</FONT></CODE>.</P>
  41. <P>All formatting objects derive from abstract class
  42. <B>org.apache.fop.fo.FONode</B>. The other FO classes inherit from
  43. <B>FONode</B> as follows:</P>
  44. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FONode</FONT></CODE></P>
  45. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|</FONT></CODE></P>
  46. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;__________|________</FONT></CODE></P>
  47. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|</FONT></CODE></P>
  48. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;FObj&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FOText</FONT></CODE></P>
  49. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp;|</FONT></CODE></P>
  50. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp;|___________________</FONT></CODE></P>
  51. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|</FONT></CODE></P>
  52. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp;FObjMixed&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SequenceSpecifier
  53. </FONT></CODE></P>
  54. <P>FO's extending FObj:</P>
  55. <P>Package org.apache.fop.fo.pagination:</P>
  56. <P><CODE><FONT face="courier, monospaced"> LayoutMasterSet</FONT></CODE></P>
  57. <P><CODE><FONT face="courier, monospaced"> PageSequence</FONT></CODE></P>
  58. <P><CODE><FONT face="courier, monospaced"> RegionAfter</FONT></CODE></P>
  59. <P><CODE><FONT face="courier, monospaced"> RegionBefore</FONT></CODE></P>
  60. <P><CODE><FONT face="courier, monospaced"> RegionBody</FONT></CODE></P>
  61. <P><CODE><FONT face="courier, monospaced"> Root</FONT></CODE></P>
  62. <P><CODE><FONT face="courier, monospaced"> SequenceSpecification</FONT></CODE></P>
  63. <P><CODE><FONT face="courier, monospaced"> SimplePageMaster</FONT></CODE></P>
  64. <P>Package org.apache.fop.fo.flow:</P>
  65. <P><CODE><FONT face="courier, monospaced">BlockContainer</FONT></CODE></P>
  66. <P><CODE><FONT face="courier, monospaced">DisplayGraphic</FONT></CODE></P>
  67. <P><CODE><FONT face="courier, monospaced">DisplayRule</FONT></CODE></P>
  68. <P><CODE><FONT face="courier, monospaced">DisplaySequence</FONT></CODE></P>
  69. <P><CODE><FONT face="courier, monospaced">Flow</FONT></CODE></P>
  70. <P><CODE><FONT face="courier, monospaced">InlineGraphic</FONT></CODE></P>
  71. <P><CODE><FONT face="courier, monospaced">ListBlock</FONT></CODE></P>
  72. <P><CODE><FONT face="courier, monospaced">ListItem</FONT></CODE></P>
  73. <P><CODE><FONT face="courier, monospaced">ListItemBody</FONT></CODE></P>
  74. <P><CODE><FONT face="courier, monospaced">ListItemLabel</FONT></CODE></P>
  75. <P><CODE><FONT face="courier, monospaced">PageNumber</FONT></CODE></P>
  76. <P><CODE><FONT face="courier, monospaced">StaticContent</FONT></CODE></P>
  77. <P><CODE><FONT face="courier, monospaced">Table</FONT></CODE></P>
  78. <P><CODE><FONT face="courier, monospaced">TableBody</FONT></CODE></P>
  79. <P><CODE><FONT face="courier, monospaced">TableCell</FONT></CODE></P>
  80. <P><CODE><FONT face="courier, monospaced">TableColumn</FONT></CODE></P>
  81. <P><CODE><FONT face="courier, monospaced">TableRow</FONT></CODE></P>
  82. <P>FO's extending SequenceSpecifier:</P>
  83. <P>Package org.apache.fop.fo.pagination:</P>
  84. <P><CODE><FONT face="courier, monospaced">SequenceSpecifierAlternating</FONT></CODE></P>
  85. <P><CODE><FONT face="courier, monospaced">SequenceSpecifierRepeating</FONT></CODE></P>
  86. <P><CODE><FONT face="courier, monospaced">SequenceSpecifierSingle</FONT></CODE></P>
  87. <P>FO's extending FObjMixed:</P>
  88. <P>Package org.apache.fop.fo.flow:</P>
  89. <P><CODE><FONT face="courier, monospaced">Block</FONT></CODE></P>
  90. <P><CODE><FONT face="courier, monospaced">InlineSequence</FONT></CODE></P>
  91. <P><CODE><FONT face="courier, monospaced">SimpleLink</FONT></CODE></P>
  92. </FONT></TD></TR></TABLE><BR>
  93. <TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="666699" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>FONode</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
  94. <P>
  95. The class inheritance described above only describes the nature of the
  96. content. Every FO in FOP also has a parent, and a Vector of children. The
  97. parent attribute (in the Java sense), in particular, is used to enforce
  98. constraints required by the FO hierarchy.
  99. </P>
  100. <P>
  101. FONode, among other things, ensures that FO's have a parent, that they
  102. have children, that they maintain a marker of where the layout was up to
  103. (for FObj's it is the child number, and for FOText's it is the character
  104. number), and that they have a <CODE><FONT face="courier, monospaced">layout()</FONT></CODE> method.
  105. </P>
  106. </FONT></TD></TR></TABLE><BR>
  107. <TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="666699" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Making FO's</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
  108. <P>
  109. Every FO class has code that looks something like this:
  110. </P>
  111. <P><CODE><FONT face="courier, monospaced">public static class Maker extends FObj.Maker {</FONT></CODE></P>
  112. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp; public FObj make(FObj parent, PropertyList propertyList)</FONT></CODE></P>
  113. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp; throws FOPException</FONT></CODE></P>
  114. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp; {</FONT></CODE></P>
  115. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp; return new SimplePageMaster(parent, propertyList);</FONT></CODE></P>
  116. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp; }</FONT></CODE></P>
  117. <P><CODE><FONT face="courier, monospaced">}</FONT></CODE></P>
  118. <P>
  119. The class also has a static method that resembles
  120. </P>
  121. <P><CODE><FONT face="courier, monospaced">public static FObj.Maker maker()</FONT></CODE></P>
  122. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp; {</FONT></CODE></P>
  123. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp;&nbsp;&nbsp; return new PageSequence.Maker();</FONT></CODE></P>
  124. <P><CODE><FONT face="courier, monospaced">&nbsp;&nbsp; }</FONT></CODE></P>
  125. <P>
  126. A hash 'fobjTable' exists in <B>FOTreeBuilder</B>, and maps the FO names (such as
  127. 'fo:table') to object references to the appropriate factories
  128. (such as <B>Table.Maker</B>).
  129. </P>
  130. <P>
  131. Properties (recall that FO's have properties, areas have traits, and XML
  132. nodes have attributes) are also a concern of <B>FOTreeBuilder</B>. It
  133. accomplishes this by using <B>PropertyListBuilder</B>, which contains a hash of
  134. property names and <I>their</I> respective makers. The base class for
  135. properties is <B>Property</B>, and the property makers extend
  136. <B>Property.Maker</B>.
  137. </P>
  138. </FONT></TD></TR></TABLE><BR>
  139. <TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="666699" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>FO Formatting</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
  140. <P>
  141. <B>FOTreeBuilder</B> calls <CODE><FONT face="courier, monospaced">format()</FONT></CODE> on the root FO, passing
  142. it the <B>AreaTree</B>
  143. reference. In turn, <B>Root</B> calls <CODE><FONT face="courier, monospaced">format()</FONT></CODE> on each
  144. <B>PageSequence</B>, passing <I>it</I>
  145. the <B>AreaTree</B> reference.
  146. </P>
  147. <P>
  148. The <B>PageSequence</B> <CODE><FONT face="courier, monospaced">format()</FONT></CODE> method does the following things:
  149. </P>
  150. <OL>
  151. <LI>Makes a <B>Page</B>, using <B>PageMasterFactory</B> to produce a
  152. <B>PageMaster</B>, and
  153. using <CODE><FONT face="courier, monospaced">makePage()</FONT></CODE> in the latter class. In the simplest picture,
  154. a <B>Page</B> has
  155. 5 areas represented by <B>AreaContainers</B>;</LI>
  156. <LI>Handles layout for <B>StaticContent</B> objects in the 'before' and 'after'
  157. regions, if set. This uses the <CODE><FONT face="courier, monospaced">layout()</FONT></CODE> method in
  158. <B>StaticContent</B>;</LI>
  159. <LI>If a page break is not forced, it will continue to layout the flow into
  160. the body area (<B>AreaContainer</B>) of the current page;</LI>
  161. <LI>It continues with (1) when layout into the current page is done, but
  162. the flow is not empty.</LI>
  163. </OL>
  164. </FONT></TD></TR></TABLE><BR>
  165. <TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="666699" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Area Layout</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
  166. <P>
  167. FO's that represent actual areas, starting with <B>Flow</B> and
  168. <B>StaticContent</B>, have
  169. a <CODE><FONT face="courier, monospaced">layout()</FONT></CODE> method, with the following signature:
  170. </P>
  171. <P>
  172. <CODE><FONT face="courier, monospaced">
  173. public Status layout(Area area)
  174. </FONT></CODE>
  175. </P>
  176. <P>
  177. The fundamental role of the <CODE><FONT face="courier, monospaced">layout()</FONT></CODE> method is to manage the layout of
  178. children and/or to generate new areas.
  179. </P>
  180. <P>
  181. <B>Example</B>: the <CODE><FONT face="courier, monospaced">layout()</FONT></CODE> method for <B>Flow</B> generates no new areas - it manages the
  182. layout of the flow children.
  183. </P>
  184. <P>
  185. <B>Example</B>: the <CODE><FONT face="courier, monospaced">layout()</FONT></CODE> method for <B>Block</B>
  186. generates a new <B>BlockArea</B> in and of
  187. itself, and also manages the layout of the block children, which are added
  188. to the <B>BlockArea</B> before that is itself added to its parent
  189. <B>Area</B>.
  190. </P>
  191. <P>
  192. <CODE><FONT face="courier, monospaced">Layout()</FONT></CODE> methods are subject to the general constraint that possibly not
  193. all of their children can be accommodated, and they report back accordingly
  194. with an appropriate <B>Status</B>.
  195. </P>
  196. </FONT></TD></TR></TABLE><BR>
  197. <TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="666699" colspan="2" width="494"><TABLE border="0" cellpadding="0" cellspacing="0" width="494"><TR><TD bgcolor="#039acc" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#039acc" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#039acc" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#0086b2" width="492"><FONT color="#ffffff" face="arial,helvetica,sanserif" size="+1"><IMG border="0" height="2" hspace="0" src="resources/void.gif" vspace="0" width="2"><B>Rendering</B></FONT></TD><TD bgcolor="#017299" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR><TR><TD bgcolor="#0086b2" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD><TD bgcolor="#017299" height="1" width="492"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="492"></TD><TD bgcolor="#017299" height="1" width="1"><IMG border="0" height="1" hspace="0" src="resources/void.gif" vspace="0" width="1"></TD></TR></TABLE></TD></TR><TR><TD width="10">&nbsp;</TD><TD width="484"><FONT color="#000000" face="arial,helvetica,sanserif">
  198. <P>
  199. This is a separate process. The <CODE><FONT face="courier, monospaced">render()</FONT></CODE> method in
  200. <B>Driver</B> is invoked (say,
  201. by <B>CommandLine</B>) with the laid-out <B>AreaTree</B> and a
  202. <B>PrintWriter</B> as arguments.
  203. This actually calls the <CODE><FONT face="courier, monospaced">render()</FONT></CODE> method in a specific implementation of
  204. the <B>Renderer</B> interface, typically <B>PDFRenderer</B> or
  205. <B>AWTRenderer</B>.
  206. </P>
  207. <P>
  208. At the highest level <B>PDFRenderer</B>, for example, begins by rendering each
  209. <B>Page</B>. The <CODE><FONT face="courier, monospaced">render()</FONT></CODE> method in <B>Page</B> (as is the case for other areas),
  210. invokes a particular method in the renderer of choice, e.g.
  211. <CODE><FONT face="courier, monospaced">renderPage()</FONT></CODE>.
  212. <B>NOTE</B>: this system is bypassed for <B>Page</B>, incidentally.
  213. </P>
  214. <P>
  215. Rendering will not be discussed further in this document, as most of our
  216. current effort must concentrate on layout. Section 4.12 in the XSL WD
  217. discusses some issues applicable to rendering.
  218. </P>
  219. </FONT></TD></TR></TABLE><BR>
  220. </TD></TR></TABLE></TD></TR></TABLE><BR><TABLE border="0" cellpadding="0" cellspacing="0" width="620"><TR><TD bgcolor="#0086b2"><IMG height="1" src="images/dot.gif" width="1"></TD></TR><TR><TD align="center"><FONT color="#0086b2" size="-1"><I>
  221. Copyright &copy; 1999 The Apache Software Foundation.
  222. All Rights Reserved.
  223. </I></FONT></TD></TR></TABLE></BODY></HTML>