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.

Renderer.java 5.8KB

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