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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.render;
  19. // Java
  20. import java.io.IOException;
  21. import java.io.OutputStream;
  22. import java.util.Locale;
  23. import org.apache.fop.apps.FOPException;
  24. import org.apache.fop.apps.FOUserAgent;
  25. import org.apache.fop.area.LineArea;
  26. import org.apache.fop.area.OffDocumentItem;
  27. import org.apache.fop.area.PageSequence;
  28. import org.apache.fop.area.PageViewport;
  29. import org.apache.fop.fonts.FontInfo;
  30. /**
  31. * Interface implemented by all renderers. This interface is used to control
  32. * the rendering of pages and to let block and inline level areas call the
  33. * appropriate method to render themselves. <p>
  34. *
  35. * A Renderer implementation takes areas/spaces and produces output in some
  36. * format.</p> <p>
  37. *
  38. * Typically, most renderers are subclassed from FOP's abstract implementations
  39. * ({@link AbstractRenderer}, {@link PrintRenderer}) which already handle a lot
  40. * of things letting you concentrate on the details of the output format.
  41. */
  42. public interface Renderer {
  43. /**
  44. * Role constant for Avalon.
  45. */
  46. String ROLE = Renderer.class.getName();
  47. /**
  48. * Get the MIME type of the renderer.
  49. *
  50. * @return The MIME type of the renderer, may return null if not applicable.
  51. */
  52. String getMimeType();
  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. * Returns the associated user agent.
  75. * @return the user agent
  76. */
  77. FOUserAgent getUserAgent();
  78. /**
  79. * Set up the given FontInfo.
  80. *
  81. * @param fontInfo The font information
  82. * @throws FOPException if an error occurs while setting up the font info object
  83. */
  84. void setupFontInfo(FontInfo fontInfo) throws FOPException;
  85. /**
  86. * Reports if out of order rendering is supported. <p>
  87. *
  88. * Normally, all pages of a document are rendered in their natural order
  89. * (page 1, page 2, page 3 etc.). Some output formats (such as PDF) allow
  90. * pages to be output in random order. This is helpful to reduce resource
  91. * strain on the system because a page that cannot be fully resolved
  92. * doesn't block subsequent pages that are already fully resolved. </p>
  93. *
  94. * @return True if this renderer supports out of order rendering.
  95. */
  96. boolean supportsOutOfOrder();
  97. /**
  98. *
  99. * @param locale Locale of the language
  100. */
  101. void setDocumentLocale(Locale locale);
  102. /**
  103. * Tells the renderer to process an item not explicitly placed on the
  104. * document (e.g., PDF bookmarks). Note - not all renderers will process
  105. * all off-document items.
  106. *
  107. * @param odi The off-document item to be rendered
  108. */
  109. void processOffDocumentItem(OffDocumentItem odi);
  110. /**
  111. * @return the adapter for painting Java2D images (or null if not supported)
  112. */
  113. Graphics2DAdapter getGraphics2DAdapter();
  114. /**
  115. * @return the adapter for painting RenderedImages (or null if not supported)
  116. */
  117. ImageAdapter getImageAdapter();
  118. /**
  119. * This is called if the renderer supports out of order rendering. The
  120. * renderer should prepare the page so that a page further on in the set of
  121. * pages can be rendered. The body of the page should not be rendered. The
  122. * page will be rendered at a later time by the call to {@link
  123. * #renderPage(PageViewport)}.
  124. *
  125. * @param page The page viewport to use
  126. */
  127. void preparePage(PageViewport page);
  128. /**
  129. * Tells the renderer that a new page sequence starts.
  130. *
  131. * @param seqTitle The title of the page sequence
  132. * @deprecated Use {@link #startPageSequence(PageSequence)} instead
  133. */
  134. void startPageSequence(LineArea seqTitle);
  135. /**
  136. * Tells the renderer that a new page sequence starts.
  137. *
  138. * @param pageSequence the page sequence
  139. */
  140. void startPageSequence(PageSequence pageSequence);
  141. /**
  142. * Tells the renderer to render a particular page. A renderer typically
  143. * responds by packing up the current page and writing it immediately to the
  144. * output device.
  145. *
  146. * @param page The page to be rendered
  147. * @exception IOException if an I/O error occurs
  148. * @exception FOPException if a FOP interal error occurs.
  149. */
  150. void renderPage(PageViewport page)
  151. throws IOException, FOPException;
  152. }