Class IFRenderer

All Implemented Interfaces:
Constants, Renderer

public class IFRenderer extends AbstractPathOrientedRenderer
This renderer implementation is an adapter to the IFPainter interface. It is used to generate content using FOP's intermediate format.
  • Field Details

    • log

      protected static final org.apache.commons.logging.Log log
      logging instance
    • IF_MIME_TYPE

      public static final String IF_MIME_TYPE
      XML MIME type
      See Also:
    • mimic

      protected Renderer mimic
      If not null, the XMLRenderer will mimic another renderer by using its font setup.
    • pageIndices

      protected Map pageIndices
      Maps unique PageViewport key to page indices (for link target handling)
  • Constructor Details

    • IFRenderer

      public IFRenderer(FOUserAgent userAgent)
      Main constructor
      Parameters:
      userAgent - the user agent that contains configuration details. This cannot be null.
  • Method Details

    • getMimeType

      public String getMimeType()
      Get the MIME type of the renderer.
      Returns:
      The MIME type of the renderer, may return null if not applicable.
    • setDocumentHandler

      public void setDocumentHandler(IFDocumentHandler documentHandler)
      Sets the IFDocumentHandler to be used by the IFRenderer.
      Parameters:
      documentHandler - the IFDocumentHandler
    • setupFontInfo

      public void setupFontInfo(FontInfo inFontInfo) throws FOPException
      Set up the given FontInfo.
      Specified by:
      setupFontInfo in interface Renderer
      Overrides:
      setupFontInfo in class PrintRenderer
      Parameters:
      inFontInfo - The font information
      Throws:
      FOPException - if an error occurs while setting up the font info object
    • supportsOutOfOrder

      public boolean supportsOutOfOrder()
      Check if this renderer supports out of order rendering. If this renderer supports out of order rendering then it means that the pages that are not ready will be prepared and a future page will be rendered.
      Specified by:
      supportsOutOfOrder in interface Renderer
      Overrides:
      supportsOutOfOrder in class AbstractRenderer
      Returns:
      True if the renderer supports out of order rendering
    • getDocumentNavigationHandler

      protected IFDocumentNavigationHandler getDocumentNavigationHandler()
      Returns the document navigation handler if available/supported.
      Returns:
      the document navigation handler or null if not supported
    • hasDocumentNavigation

      protected boolean hasDocumentNavigation()
      Indicates whether document navigation features are supported by the document handler.
      Returns:
      true if document navigation features are available
    • createDefaultDocumentHandler

      protected IFDocumentHandler createDefaultDocumentHandler()
      Creates a default IFDocumentHandler when none has been set.
      Returns:
      the default IFDocumentHandler
    • startRenderer

      public void startRenderer(OutputStream outputStream) throws IOException
      Initiates the rendering phase. This must only be called once for a rendering. If stopRenderer is called then this may be called again for a new document rendering.
      Specified by:
      startRenderer in interface Renderer
      Overrides:
      startRenderer in class AbstractRenderer
      Parameters:
      outputStream - The OutputStream to use for output
      Throws:
      IOException - If an I/O error occurs
    • stopRenderer

      public void stopRenderer() throws IOException
      Signals the end of the rendering phase. The renderer should reset to an initial state and dispose of any resources for the completed rendering.
      Specified by:
      stopRenderer in interface Renderer
      Overrides:
      stopRenderer in class AbstractRenderer
      Throws:
      IOException - If an I/O error occurs
    • setDocumentLocale

      public void setDocumentLocale(Locale locale)
      Description copied from class: AbstractRenderer
      Specified by:
      setDocumentLocale in interface Renderer
      Overrides:
      setDocumentLocale in class AbstractRenderer
      Parameters:
      locale - Locale of the language
    • processOffDocumentItem

      public void processOffDocumentItem(OffDocumentItem odi)
      Tells the renderer to process an item not explicitly placed on the document (e.g., PDF bookmarks). Note - not all renderers will process all off-document items.
      Specified by:
      processOffDocumentItem in interface Renderer
      Overrides:
      processOffDocumentItem in class AbstractRenderer
      Parameters:
      odi - The off-document item to be rendered
    • renderBookmarkTree

      protected void renderBookmarkTree(BookmarkData bookmarks)
      Renders a Bookmark-Tree object
      Parameters:
      bookmarks - the BookmarkData object containing all the Bookmark-Items
    • startPageSequence

      public void startPageSequence(PageSequence pageSequence)
      Tells the renderer that a new page sequence starts.
      Specified by:
      startPageSequence in interface Renderer
      Overrides:
      startPageSequence in class AbstractRenderer
      Parameters:
      pageSequence - the page sequence
    • preparePage

      public void preparePage(PageViewport page)
      This is called if the renderer supports out of order rendering. The renderer should prepare the page so that a page further on in the set of pages can be rendered. The body of the page should not be rendered. The page will be rendered at a later time by the call to Renderer.renderPage(PageViewport).
      Specified by:
      preparePage in interface Renderer
      Overrides:
      preparePage in class AbstractRenderer
      Parameters:
      page - The page viewport to use
    • renderPage

      public void renderPage(PageViewport page) throws IOException, FOPException
      Tells the renderer to render a particular page. A renderer typically responds by packing up the current page and writing it immediately to the output device.
      Specified by:
      renderPage in interface Renderer
      Overrides:
      renderPage in class AbstractRenderer
      Parameters:
      page - The page to be rendered
      Throws:
      IOException - if an I/O error occurs
      FOPException - if a FOP interal error occurs.
    • saveGraphicsState

      protected void saveGraphicsState()
      Saves the graphics state of the rendering engine.
      Specified by:
      saveGraphicsState in class AbstractPathOrientedRenderer
    • restoreGraphicsState

      protected void restoreGraphicsState()
      Restores the last graphics state of the rendering engine.
      Specified by:
      restoreGraphicsState in class AbstractPathOrientedRenderer
    • breakOutOfStateStack

      protected List breakOutOfStateStack()
      Breaks out of the state stack to handle fixed block-containers.
      Specified by:
      breakOutOfStateStack in class AbstractPathOrientedRenderer
      Returns:
      the saved state stack to recreate later
    • restoreStateStackAfterBreakOut

      protected void restoreStateStackAfterBreakOut(List breakOutList)
      Restores the state stack after a break out.
      Specified by:
      restoreStateStackAfterBreakOut in class AbstractPathOrientedRenderer
      Parameters:
      breakOutList - the state stack to restore.
    • concatenateTransformationMatrix

      protected void concatenateTransformationMatrix(AffineTransform at)
      Concatenates the current transformation matrix with the given one, therefore establishing a new coordinate system.
      Specified by:
      concatenateTransformationMatrix in class AbstractPathOrientedRenderer
      Parameters:
      at - the transformation matrix to process (coordinates in points)
    • beginTextObject

      protected void beginTextObject()
      Indicates the beginning of a text object.
      Specified by:
      beginTextObject in class AbstractPathOrientedRenderer
    • endTextObject

      protected void endTextObject()
      Indicates the end of a text object.
      Specified by:
      endTextObject in class AbstractPathOrientedRenderer
    • renderRegionViewport

      protected void renderRegionViewport(RegionViewport viewport)
      Renders a region viewport.

      The region may clip the area and it establishes a position from where the region is placed.

      Overrides:
      renderRegionViewport in class AbstractRenderer
      Parameters:
      viewport - The region viewport to be rendered
    • renderBlockViewport

      protected void renderBlockViewport(BlockViewport bv, List children)
      Renders a block viewport.
      Overrides:
      renderBlockViewport in class AbstractPathOrientedRenderer
      Parameters:
      bv - The block viewport
      children - The children to render within the block viewport
    • renderInlineViewport

      public void renderInlineViewport(InlineViewport viewport)
      Render an inline viewport. This renders an inline viewport by clipping if necessary.
      Overrides:
      renderInlineViewport in class AbstractPathOrientedRenderer
      Parameters:
      viewport - the viewport to handle
    • startVParea

      protected void startVParea(CTM ctm, Rectangle clippingRect)
      Establishes a new viewport area.
      Specified by:
      startVParea in class AbstractRenderer
      Parameters:
      ctm - the coordinate transformation matrix to use
      clippingRect - the clipping rectangle if the viewport should be clipping, null if no clipping is performed.
    • endVParea

      protected void endVParea()
      Signals exit from a viewport area. Subclasses can restore transformation matrices valid before the viewport area was started.
      Specified by:
      endVParea in class AbstractRenderer
    • startLayer

      protected void startLayer(String layer)
      Establish new optional content group layer.
      Specified by:
      startLayer in class AbstractRenderer
      Parameters:
      layer - name of layer
    • endLayer

      protected void endLayer()
      Finish current optional content group layer.
      Specified by:
      endLayer in class AbstractRenderer
    • renderInlineArea

      protected void renderInlineArea(InlineArea inlineArea)
      Render the given InlineArea.
      Overrides:
      renderInlineArea in class AbstractRenderer
      Parameters:
      inlineArea - inline area text to render
    • renderInlineParent

      public void renderInlineParent(InlineParent ip)
      Render the given InlineParent.
      Overrides:
      renderInlineParent in class AbstractRenderer
      Parameters:
      ip - the inline parent to render
    • renderBlock

      protected void renderBlock(Block block)
      Renders a block area.
      Overrides:
      renderBlock in class AbstractRenderer
      Parameters:
      block - The block area
    • renderText

      protected void renderText(TextArea text)
      Render the given TextArea.
      Overrides:
      renderText in class AbstractRenderer
      Parameters:
      text - the text to render
    • renderWord

      protected void renderWord(WordArea word)
      Render the given WordArea.
      Overrides:
      renderWord in class AbstractRenderer
      Parameters:
      word - the word to render
    • renderSpace

      protected void renderSpace(SpaceArea space)
      Render the given SpaceArea.
      Overrides:
      renderSpace in class AbstractRenderer
      Parameters:
      space - the space to render
    • renderImage

      public void renderImage(Image image, Rectangle2D pos)
      Renders an image area.
      Overrides:
      renderImage in class AbstractRenderer
      Parameters:
      image - The image
      pos - The target position of the image (todo) Make renderImage() protected
    • drawImage

      protected void drawImage(String uri, Rectangle2D pos, Map foreignAttributes)
      Draw an image at the indicated location.
      Specified by:
      drawImage in class AbstractPathOrientedRenderer
      Parameters:
      uri - the URI/URL of the image
      pos - the position of the image
      foreignAttributes - an optional Map with foreign attributes, may be null
    • renderForeignObject

      public void renderForeignObject(ForeignObject fo, Rectangle2D pos)
      Renders a foreign object area.
      Overrides:
      renderForeignObject in class AbstractPathOrientedRenderer
      Parameters:
      fo - The foreign object area
      pos - The target position of the foreign object (todo) Make renderForeignObject() protected
    • renderLeader

      public void renderLeader(Leader area)
      Render the given Leader.
      Overrides:
      renderLeader in class AbstractRenderer
      Parameters:
      area - the leader to render
    • clip

      protected void clip()
      Clip using the current path.
      Specified by:
      clip in class AbstractPathOrientedRenderer
    • clipRect

      protected void clipRect(float x, float y, float width, float height)
      Clip using a rectangular area.
      Specified by:
      clipRect in class AbstractPathOrientedRenderer
      Parameters:
      x - the x coordinate (in points)
      y - the y coordinate (in points)
      width - the width of the rectangle (in points)
      height - the height of the rectangle (in points)
    • clipBackground

      protected void clipBackground(float startx, float starty, float width, float height, BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd)
      TODO represent border related parameters in a class Clip the background to the inner border. This draws the border traits given the position and the traits.
      Overrides:
      clipBackground in class AbstractPathOrientedRenderer
      Parameters:
      startx - the start x position
      starty - the start y position
      width - the width of the area
      height - the height of the area
      bpsBefore - the border-before traits
      bpsAfter - the border-after traits
      bpsStart - the border-start traits
      bpsEnd - the border-end traits
    • closePath

      protected void closePath()
      Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath.
      Specified by:
      closePath in class AbstractPathOrientedRenderer
    • drawBackground

      protected void drawBackground(float startx, float starty, float width, float height, Trait.Background back, BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd)
      Draw the background. This draws the background given the position and the traits.
      Overrides:
      drawBackground in class AbstractPathOrientedRenderer
      Parameters:
      startx - the start x position
      starty - the start y position
      width - the width of the area
      height - the height of the area
      back - the background traits
      bpsBefore - the border specification on the top edge
      bpsAfter - the border traits associated with bottom edge
      bpsStart - the border specification on the left edge
      bpsEnd - the border specification on the right edge
    • drawBorders

      protected void drawBorders(float startx, float starty, float width, float height, BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd, int level, Color innerBackgroundColor)
      Draw the borders. This draws the border traits given the position and the traits.
      Overrides:
      drawBorders in class AbstractPathOrientedRenderer
      Parameters:
      startx - the start x position
      starty - the start y position
      width - the width of the area
      height - the height of the area
      bpsBefore - the border traits associated with before edge
      bpsAfter - the border traits associated with after edge
      bpsStart - the border traits associated with start edge
      bpsEnd - the border traits associated with end edge
      level - of bidirectional embedding
      innerBackgroundColor - the background color of the block
    • drawBorderLine

      protected void drawBorderLine(float x1, float y1, float x2, float y2, boolean horz, boolean startOrBefore, int style, Color col)
      Draw a border segment of an XSL-FO style border.
      Specified by:
      drawBorderLine in class AbstractPathOrientedRenderer
      Parameters:
      x1 - starting x coordinate
      y1 - starting y coordinate
      x2 - ending x coordinate
      y2 - ending y coordinate
      horz - true for horizontal border segments, false for vertical border segments
      startOrBefore - true for border segments on the start or before edge, false for end or after.
      style - the border style (one of Constants.EN_DASHED etc.)
      col - the color for the border segment
    • fillRect

      protected void fillRect(float x, float y, float width, float height)
      Fill a rectangular area.
      Specified by:
      fillRect in class AbstractPathOrientedRenderer
      Parameters:
      x - the x coordinate
      y - the y coordinate
      width - the width of the rectangle
      height - the height of the rectangle
    • moveTo

      protected void moveTo(float x, float y)
      Moves the current point to (x, y), omitting any connecting line segment.
      Specified by:
      moveTo in class AbstractPathOrientedRenderer
      Parameters:
      x - x coordinate
      y - y coordinate
    • lineTo

      protected void lineTo(float x, float y)
      Appends a straight line segment from the current point to (x, y). The new current point is (x, y).
      Specified by:
      lineTo in class AbstractPathOrientedRenderer
      Parameters:
      x - x coordinate
      y - y coordinate
    • updateColor

      protected void updateColor(Color col, boolean fill)
      Establishes a new foreground or fill color.
      Specified by:
      updateColor in class AbstractPathOrientedRenderer
      Parameters:
      col - the color to apply (null skips this operation)
      fill - true to set the fill color, false for the foreground color