Class AbstractPathOrientedRenderer

  • All Implemented Interfaces:
    Constants, Renderer
    Direct Known Subclasses:
    IFRenderer, Java2DRenderer, TXTRenderer

    public abstract class AbstractPathOrientedRenderer
    extends PrintRenderer
    Abstract base class for renderers like PDF and PostScript where many painting operations follow similar patterns which makes it possible to share some code.
    • Constructor Detail

      • AbstractPathOrientedRenderer

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

      • handleBlockTraits

        protected void handleBlockTraits​(Block block)
        Handle block traits. The block could be any sort of block with any positioning so this should render the traits such as border and background in its position.
        Overrides:
        handleBlockTraits in class AbstractRenderer
        Parameters:
        block - the block to render the traits
      • handleRegionTraits

        protected void handleRegionTraits​(RegionViewport region)
        Handle the traits for a region This is used to draw the traits for the given page region. (See Sect. 6.4.1.2 of XSL-FO spec.)
        Overrides:
        handleRegionTraits in class AbstractRenderer
        Parameters:
        region - the RegionViewport whose region is to be drawn
      • drawBackAndBorders

        protected void drawBackAndBorders​(Area area,
                                          float startx,
                                          float starty,
                                          float width,
                                          float height)
        Draw the background and borders. This draws the background and border traits for an area given the position.
        Parameters:
        area - the area to get the traits from
        startx - the start x position
        starty - the start y position
        width - the width of the area
        height - the height of the area
      • drawBackAndBorders

        protected void drawBackAndBorders​(Area backgroundArea,
                                          Area borderArea,
                                          float startx,
                                          float starty,
                                          float width,
                                          float height)
        Draw the background and borders. This draws the background and border traits for an area given the position.
        Parameters:
        backgroundArea - the area to get the background traits from
        borderArea - the area to get the border traits from
        startx - the start x position
        starty - the start y position
        width - the width of the area
        height - the height of the area
      • drawBackground

        protected void drawBackground​(float startx,
                                      float starty,
                                      float width,
                                      float height,
                                      Trait.Background back,
                                      BorderProps bpsBefore,
                                      BorderProps bpsAfter,
                                      BorderProps bpsStart,
                                      BorderProps bpsEnd,
                                      int level)
        Draw the background. This draws the background given the position and the traits.
        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-before traits
        bpsAfter - the border-after traits
        bpsStart - the border-start traits
        bpsEnd - the border-end traits
        level - of bidirectional embedding
      • drawBackground

        protected void drawBackground​(float startx,
                                      float starty,
                                      float width,
                                      float height,
                                      Trait.Background back,
                                      BorderProps bpsTop,
                                      BorderProps bpsBottom,
                                      BorderProps bpsLeft,
                                      BorderProps bpsRight)
        Draw the background. This draws the background given the position and the traits.
        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
        bpsTop - the border specification on the top edge
        bpsBottom - the border traits associated with bottom edge
        bpsLeft - the border specification on the left edge
        bpsRight - the border specification on the right edge
      • 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.
        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
      • 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.
        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
      • drawBorders

        protected void drawBorders​(java.awt.geom.Rectangle2D.Float borderRect,
                                   BorderProps bpsTop,
                                   BorderProps bpsBottom,
                                   BorderProps bpsLeft,
                                   BorderProps bpsRight,
                                   java.awt.Color innerBackgroundColor)
        Draws borders.
        Parameters:
        borderRect - the border rectangle
        bpsTop - the border specification on the top edge
        bpsBottom - the border traits associated with bottom edge
        bpsLeft - the border specification on the left edge
        bpsRight - the border specification on the right edge
        innerBackgroundColor - the background color of the block
      • isCollapseOuter

        private boolean isCollapseOuter​(BorderProps bp)
      • renderInlineAreaBackAndBorders

        protected void renderInlineAreaBackAndBorders​(InlineArea area)
        Common method to render the background and borders for any inline area. The all borders and padding are drawn outside the specified area.
        Specified by:
        renderInlineAreaBackAndBorders in class AbstractRenderer
        Parameters:
        area - the inline area for which the background, border and padding is to be rendered
      • renderBlockViewport

        protected void renderBlockViewport​(BlockViewport bv,
                                           java.util.List children)
        Renders a block viewport.
        Overrides:
        renderBlockViewport in class AbstractRenderer
        Parameters:
        bv - The block viewport
        children - The children to render within the block viewport
      • renderReferenceArea

        protected void renderReferenceArea​(Block block)
        Renders a block area that represents a reference area. The reference area establishes a new coordinate system.
        Specified by:
        renderReferenceArea in class AbstractRenderer
        Parameters:
        block - the block area
      • renderFlow

        protected void renderFlow​(NormalFlow flow)
        Renders a flow reference area.
        Overrides:
        renderFlow in class AbstractRenderer
        Parameters:
        flow - The flow reference area
      • concatenateTransformationMatrix

        protected abstract void concatenateTransformationMatrix​(java.awt.geom.AffineTransform at)
        Concatenates the current transformation matrix with the given one, therefore establishing a new coordinate system.
        Parameters:
        at - the transformation matrix to process (coordinates in points)
      • renderInlineViewport

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

        protected abstract void restoreStateStackAfterBreakOut​(java.util.List breakOutList)
        Restores the state stack after a break out.
        Parameters:
        breakOutList - the state stack to restore.
      • breakOutOfStateStack

        protected abstract java.util.List breakOutOfStateStack()
        Breaks out of the state stack to handle fixed block-containers.
        Returns:
        the saved state stack to recreate later
      • saveGraphicsState

        protected abstract void saveGraphicsState()
        Saves the graphics state of the rendering engine.
      • restoreGraphicsState

        protected abstract void restoreGraphicsState()
        Restores the last graphics state of the rendering engine.
      • beginTextObject

        protected abstract void beginTextObject()
        Indicates the beginning of a text object.
      • endTextObject

        protected abstract void endTextObject()
        Indicates the end of a text object.
      • renderTextDecoration

        protected void renderTextDecoration​(FontMetrics fm,
                                            int fontsize,
                                            InlineArea inline,
                                            int baseline,
                                            int startx)
        Paints the text decoration marks.
        Parameters:
        fm - Current typeface
        fontsize - Current font size
        inline - inline area to paint the marks for
        baseline - position of the baseline
        startx - start IPD
      • clip

        protected abstract void clip()
        Clip using the current path.
      • clipRect

        protected abstract void clipRect​(float x,
                                         float y,
                                         float width,
                                         float height)
        Clip using a rectangular area.
        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)
      • moveTo

        protected abstract void moveTo​(float x,
                                       float y)
        Moves the current point to (x, y), omitting any connecting line segment.
        Parameters:
        x - x coordinate
        y - y coordinate
      • lineTo

        protected abstract 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).
        Parameters:
        x - x coordinate
        y - y coordinate
      • closePath

        protected abstract void closePath()
        Closes the current subpath by appending a straight line segment from the current point to the starting point of the subpath.
      • fillRect

        protected abstract void fillRect​(float x,
                                         float y,
                                         float width,
                                         float height)
        Fill a rectangular area.
        Parameters:
        x - the x coordinate
        y - the y coordinate
        width - the width of the rectangle
        height - the height of the rectangle
      • updateColor

        protected abstract void updateColor​(java.awt.Color col,
                                            boolean fill)
        Establishes a new foreground or fill color.
        Parameters:
        col - the color to apply (null skips this operation)
        fill - true to set the fill color, false for the foreground color
      • drawImage

        protected abstract void drawImage​(java.lang.String url,
                                          java.awt.geom.Rectangle2D pos,
                                          java.util.Map foreignAttributes)
        Draw an image at the indicated location.
        Parameters:
        url - the URI/URL of the image
        pos - the position of the image
        foreignAttributes - an optional Map with foreign attributes, may be null
      • drawImage

        protected final void drawImage​(java.lang.String url,
                                       java.awt.geom.Rectangle2D pos)
        Draw an image at the indicated location.
        Parameters:
        url - the URI/URL of the image
        pos - the position of the image
      • drawBorderLine

        protected abstract 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.
        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
      • renderForeignObject

        public void renderForeignObject​(ForeignObject fo,
                                        java.awt.geom.Rectangle2D pos)
        Renders a foreign object area.
        Overrides:
        renderForeignObject in class AbstractRenderer
        Parameters:
        fo - The foreign object area
        pos - The target position of the foreign object (todo) Make renderForeignObject() protected
      • establishTransformationMatrix

        protected void establishTransformationMatrix​(java.awt.geom.AffineTransform at)
        Establishes a new coordinate system with the given transformation matrix. The current graphics state is saved and the new coordinate system is concatenated.
        Parameters:
        at - the transformation matrix