Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Renderer.java 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  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. package org.apache.fop.render;
  18. // Java
  19. import java.io.OutputStream;
  20. import java.io.IOException;
  21. import java.util.Date;
  22. import java.util.Map;
  23. // FOP
  24. import org.apache.fop.apps.FOPException;
  25. import org.apache.fop.area.PageViewport;
  26. import org.apache.fop.area.Title;
  27. import org.apache.fop.area.TreeExt;
  28. import org.apache.fop.area.inline.Container;
  29. import org.apache.fop.area.inline.InlineParent;
  30. import org.apache.fop.area.inline.Leader;
  31. import org.apache.fop.area.inline.Space;
  32. import org.apache.fop.area.inline.Viewport;
  33. import org.apache.fop.area.inline.TextArea;
  34. import org.apache.fop.fo.FOTreeControl;
  35. import org.apache.fop.apps.FOUserAgent;
  36. /**
  37. * Interface implemented by all renderers. This interface is used to control
  38. * the rendering of pages and to let block and inline level areas call the
  39. * appropriate method to render themselves. <p>
  40. *
  41. * A Renderer implementation takes areas/spaces and produces output in some
  42. * format.</p> <p>
  43. *
  44. * Typically, most renderers are subclassed from FOP's abstract implementations
  45. * ({@link AbstractRenderer}, {@link PrintRenderer}) which already handle a lot
  46. * of things letting you concentrate on the details of the output format.
  47. */
  48. public interface Renderer {
  49. /**
  50. * Role constant for Avalon.
  51. */
  52. String ROLE = Renderer.class.getName();
  53. /**
  54. * Initiates the rendering phase.
  55. * This must only be called once for a rendering. If
  56. * stopRenderer is called then this may be called again
  57. * for a new document rendering.
  58. *
  59. * @param outputStream The OutputStream to use for output
  60. * @exception IOException If an I/O error occurs
  61. */
  62. void startRenderer(OutputStream outputStream)
  63. throws IOException;
  64. /**
  65. * Signals the end of the rendering phase.
  66. * The renderer should reset to an initial state and dispose of
  67. * any resources for the completed rendering.
  68. *
  69. * @exception IOException If an I/O error occurs
  70. */
  71. void stopRenderer()
  72. throws IOException;
  73. /**
  74. * Set the User Agent.
  75. *
  76. * @param agent The User Agent
  77. */
  78. void setUserAgent(FOUserAgent agent);
  79. /**
  80. * Set up the given FontInfo.
  81. *
  82. * @param fontInfo The fonts
  83. */
  84. void setupFontInfo(FOTreeControl foTreeControl);
  85. /**
  86. * Set up renderer options.
  87. *
  88. * @param options The Configuration for the renderer
  89. */
  90. void setOptions(Map options);
  91. /**
  92. * Set the producer of the rendering. If this method isn't called the
  93. * renderer uses a default. Note: Not all renderers support this feature.
  94. *
  95. * @param producer The name of the producer (normally "FOP") to be
  96. * embedded in the generated file.
  97. */
  98. void setProducer(String producer);
  99. /**
  100. * Set the creator of the document to be rendered.
  101. * If this method isn't called the renderer uses a default.
  102. * Note: Not all renderers support this feature.
  103. *
  104. * @param creator The name of the document creator
  105. */
  106. void setCreator(String creator);
  107. /**
  108. * Set the creator date/timeof the document to be rendered.
  109. * If this method isn't called the renderer uses the current date/time
  110. * as default.
  111. * Note: Not all renderers support this feature.
  112. *
  113. * @param date The name of the document creator
  114. */
  115. void setCreationDate(Date date);
  116. /**
  117. * Reports if out of order rendering is supported. <p>
  118. *
  119. * Normally, all pages of a document are rendered in their natural order
  120. * (page 1, page 2, page 3 etc.). Some output formats (such as PDF) allow
  121. * pages to be output in random order. This is helpful to reduce resource
  122. * strain on the system because a page that cannot be fully resolved
  123. * doesn't block subsequent pages that are already fully resolved. </p>
  124. *
  125. * @return True if this renderer supports out of order rendering.
  126. */
  127. boolean supportsOutOfOrder();
  128. /**
  129. * Tells the renderer to render an extension element.
  130. *
  131. * @param ext The extension element to be rendered
  132. */
  133. void renderExtension(TreeExt ext);
  134. /**
  135. * This is called if the renderer supports out of order rendering. The
  136. * renderer should prepare the page so that a page further on in the set of
  137. * pages can be rendered. The body of the page should not be rendered. The
  138. * page will be rendered at a later time by the call to {@link
  139. * #renderPage(PageViewport)}.
  140. *
  141. * @param page The page viewport to use
  142. */
  143. void preparePage(PageViewport page);
  144. /**
  145. * Tells the renderer that a new page sequence starts.
  146. *
  147. * @param seqTitle The title of the page sequence
  148. */
  149. void startPageSequence(Title seqTitle);
  150. /**
  151. * Tells the renderer to render a particular page. A renderer typically
  152. * reponds by packing up the current page and writing it immediately to the
  153. * output device.
  154. *
  155. * @param page The page to be rendered
  156. * @exception IOException if an I/O error occurs
  157. * @exception FOPException if a FOP interal error occurs.
  158. */
  159. void renderPage(PageViewport page)
  160. throws IOException, FOPException;
  161. /**
  162. * Tells the renderer to render an inline container.
  163. *
  164. * @param cont The inline container area
  165. */
  166. void renderContainer(Container cont);
  167. }