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.

implement.xml 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <!-- $Id$ -->
  17. <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.3//EN" "http://forrest.apache.org/dtd/document-v13.dtd">
  18. <document>
  19. <header>
  20. <title>Apache™ FOP Development: Implementation Overview</title>
  21. <subtitle>Following a Document Through Apache� FOP</subtitle>
  22. <version>$Revision$</version>
  23. <authors>
  24. <person name="Arved Sandstrom" email=""/>
  25. </authors>
  26. </header>
  27. <body>
  28. <p>The purpose of this document is to tie together the Apache™ FOP design (interface) with some of the key points where control is passed within FOP (implementation), so that developers can quickly find the section of code that is relevant to their needs. The process described is for a "typical" command-line document. All classes are in org.apache.fop unless otherwise designated.</p>
  29. <section>
  30. <title>Overview</title>
  31. <p>The input FO document is sent to the FO tree builder via SAX events. Fragments of an FO Tree are built from this process. As each page-sequence element is completed, it is passed to a layout processor, which in turn converts it into an Area Tree. The Area Tree is then given to the Renderer, which converts it into a stream of data containing the output document. The sections below will provide additional details. Where needed differences between the trunk and maintenance branches are shown in tabular format.</p>
  32. </section>
  33. <section>
  34. <title>Startup</title>
  35. <ul>
  36. <li>The job starts in <em>apps.Fop.main()</em>.</li>
  37. <li>Control is passed to <em>apps.CommandLineStarter.run()</em>.</li>
  38. <li>Control is passed to <em>apps.Driver.render()</em>. This class fires up a SAX parser, the events from which indirectly control the remaining processing, including building the FO Tree, building the Area Tree, rendering, output and logging.</li>
  39. </ul>
  40. </section>
  41. <section>
  42. <title>Formatting Object Tree</title>
  43. <table>
  44. <tr>
  45. <th>Trunk</th><th>Maintenance</th>
  46. </tr>
  47. <tr>
  48. <td colspan="2">The SAX events that the parser creates are handled by <em>fo.FOTreeBuilder</em>, which uses <code>startElement()</code>, <code>endElement()</code>, and <code>characters()</code> methods to build the FO Tree.</td>
  49. </tr>
  50. <tr>
  51. <td><code>fo.FOTreeBuilder.endElement()</code> runs the <code>end()</code> method for each node as it is created. The <em>fo.pagination.PageSequence</em> class overrides this <code>end()</code> method to run <code>apps.LayoutHandler.endPageSequence()</code>, which in turn runs <code>fo.pagination.PageSequence.format()</code>.</td>
  52. <td>the end of a PageSequence element causes the PageSequence object to be passed to <code>apps.StreamRenderer.render()</code>, which in turn runs <code>fo.pagination.PageSequence.format()</code>.</td>
  53. </tr>
  54. <tr>
  55. <td><code>fo.pagination.PageSequence.format()</code> creates a <em>layoutmgr.PageLayoutManager</em>, passing the AreaTree and PageSequence objects to it, then calls its <code>run()</code> method.</td>
  56. <td><code>fo.pagination.PageSequence.addFlow()</code> programatically adds a Flow object to the page sequence.</td>
  57. </tr>
  58. <tr>
  59. <td>.</td>
  60. <td><code>fo.pagination.PageSequence.makePage()</code> creates a BodyArea and passes it to <em>fo.Flow.layout</em></td>
  61. </tr>
  62. <tr>
  63. <td>.</td>
  64. <td>the layout process is then driven from <code>fo.pagination.PageSequence.format()</code>.</td>
  65. </tr>
  66. </table>
  67. </section>
  68. <section>
  69. <title>Layout</title>
  70. <p>There are layout managers for each type of layout decision.
  71. They take an FO Tree as input and build a laid-out Area Tree from it.
  72. The layout process involves finding out where line breaks and page breaks should be made, then creating the areas on the page.
  73. Static areas can then be added for any static regions.
  74. As pages are completed, they are added to the Area Tree.</p>
  75. </section>
  76. <section>
  77. <title>Area Tree</title>
  78. <p>The area tree is a data structure designed to hold the page areas.
  79. These pages are then filled with the page regions and various areas.
  80. The area tree is used primarily as a minimal structure that can be rendered
  81. by the renderers.</p>
  82. <p>The area tree is supported by an area tree model. This model
  83. handles the adding of pages to the area tree. It also handles
  84. page sequence starts, document level extensions, id references
  85. and unresolved id areas. This model allows the pages to be handled
  86. directly by a renderer or to store the pages for later use.
  87. </p>
  88. </section>
  89. <section>
  90. <title>Rendering</title>
  91. <p>
  92. The renderer receives pages from the area tree and renders those pages.
  93. If a renderer supports out of order rendering then it will either
  94. render or prepare a page in the correct order. Otherwise the
  95. pages are rendered in order.
  96. The task of the renderer is to take the pages and output them to
  97. the requested type.
  98. In the case of the AWTRenderer it needs to be able to view any page.
  99. </p>
  100. <p>
  101. When rendering a page it takes the page and renders each page region.
  102. The main work for a renderer implementation is to handle the viewports
  103. and inline areas. The inline areas need to be drawn on the page in the
  104. correct place.
  105. </p>
  106. </section>
  107. </body>
  108. </document>