Class IFRenderer

    • Field Detail

      • log

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

        public static final java.lang.String IF_MIME_TYPE
        XML MIME type
        See Also:
        Constant Field Values
      • mimic

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

        protected java.util.Map pageIndices
        Maps unique PageViewport key to page indices (for link target handling)
    • Constructor Detail

      • IFRenderer

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

      • getMimeType

        public java.lang.String getMimeType()
        Get the MIME type of the renderer.
        Returns:
        The MIME type of the renderer, may return null if not applicable.
      • 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​(java.io.OutputStream outputStream)
                           throws java.io.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:
        java.io.IOException - If an I/O error occurs
      • stopRenderer

        public void stopRenderer()
                          throws java.io.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:
        java.io.IOException - If an I/O error occurs
      • 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
      • 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 java.io.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:
        java.io.IOException - if an I/O error occurs
        FOPException - if a FOP interal error occurs.
      • breakOutOfStateStack

        protected java.util.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​(java.util.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​(java.awt.geom.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)
      • 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
      • startVParea

        protected void startVParea​(CTM ctm,
                                   java.awt.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​(java.lang.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
      • 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,
                                java.awt.geom.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​(java.lang.String uri,
                                 java.awt.geom.Rectangle2D pos,
                                 java.util.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,
                                        java.awt.geom.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
      • 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,
                                   java.awt.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,
                                      java.awt.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​(java.awt.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