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 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. * Reports if out of order rendering is supported. <p>
  88. *
  89. * Normally, all pages of a document are rendered in their natural order
  90. * (page 1, page 2, page 3 etc.). Some output formats (such as PDF) allow
  91. * pages to be output in random order. This is helpful to reduce resource
  92. * strain on the system because a page that cannot be fully resolved
  93. * doesn't block subsequent pages that are already fully resolved. </p>
  94. *
  95. * @return True if this renderer supports out of order rendering.
  96. */
  97. boolean supportsOutOfOrder();
  98. /**
  99. * Tells the renderer to render an extension element.
  100. *
  101. * @param ext The extension element to be rendered
  102. */
  103. void renderExtension(TreeExt ext);
  104. /**
  105. * This is called if the renderer supports out of order rendering. The
  106. * renderer should prepare the page so that a page further on in the set of
  107. * pages can be rendered. The body of the page should not be rendered. The
  108. * page will be rendered at a later time by the call to {@link
  109. * #renderPage(PageViewport)}.
  110. *
  111. * @param page The page viewport to use
  112. */
  113. void preparePage(PageViewport page);
  114. /**
  115. * Tells the renderer that a new page sequence starts.
  116. *
  117. * @param seqTitle The title of the page sequence
  118. */
  119. void startPageSequence(Title seqTitle);
  120. /**
  121. * Tells the renderer to render a particular page. A renderer typically
  122. * reponds by packing up the current page and writing it immediately to the
  123. * output device.
  124. *
  125. * @param page The page to be rendered
  126. * @exception IOException if an I/O error occurs
  127. * @exception FOPException if a FOP interal error occurs.
  128. */
  129. void renderPage(PageViewport page)
  130. throws IOException, FOPException;
  131. /**
  132. * Tells the renderer to render an inline container.
  133. *
  134. * @param cont The inline container area
  135. */
  136. void renderContainer(Container cont);
  137. }