org.apache.fop.render.intermediate

## Class BorderPainter

- java.lang.Object
- - org.apache.fop.render.intermediate.BorderPainter

-     public class BorderPainter
      extends java.lang.Object

  This is an abstract base class for handling border painting.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static int` | `BOTTOM` Convention index of bottom border
    `protected static int` | `BOTTOM_LEFT` Convention index of bottom-left border corners
    `protected static int` | `BOTTOM_RIGHT` Convention index of bottom-right border corners
    `protected static float` | `DASHED_BORDER_LENGTH_FACTOR` The length of the dash as a factor of the border width i.e.
    `static float` | `DASHED_BORDER_SPACE_RATIO` The ratio between a solid dash and the white-space in a dashed-border
    `protected static int` | `LEFT` Convention index of left border
    `protected static int` | `RIGHT` Convention index of right border
    `protected static int` | `TOP` Convention index of before top
    `protected static int` | `TOP_LEFT` Convention index of top-left border corners
    `protected static int` | `TOP_RIGHT` Convention index of top-right-end border corners

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BorderPainter(GraphicsPainter graphicsPainter)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected static double` | `calculateCornerCorrectionFactor(int width, int height, BorderProps before, BorderProps after, BorderProps start, BorderProps end)` Calculate the correction factor to handle over-sized elliptic corner radii.
    `protected static double` | `calculateCornerScaleCorrection(int width, int height, org.apache.fop.render.intermediate.BorderPainter.BorderSegment before, org.apache.fop.render.intermediate.BorderPainter.BorderSegment after, org.apache.fop.render.intermediate.BorderPainter.BorderSegment start, org.apache.fop.render.intermediate.BorderPainter.BorderSegment end)` Calculate the scaling factor to handle over-sized elliptic corner radii.
    `void` | `clipBackground(java.awt.Rectangle rect, BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd)` Clip the background to the inner border
    `static float` | `dashWidthCalculator(float borderLength, float borderWidth)` This method calculates the length of the "dash" in a dashed border.
    `void` | `drawBorders(java.awt.Rectangle borderRect, BorderProps bpsTop, BorderProps bpsBottom, BorderProps bpsLeft, BorderProps bpsRight, java.awt.Color innerBackgroundColor)` Draws borders.
    `protected void` | `drawRectangularBorders(java.awt.Rectangle borderRect, BorderProps bpsTop, BorderProps bpsBottom, BorderProps bpsLeft, BorderProps bpsRight)` TODO merge with drawRoundedBorders()?
    `protected void` | `drawRoundedBorders(java.awt.Rectangle borderRect, BorderProps beforeBorderProps, BorderProps afterBorderProps, BorderProps startBorderProps, BorderProps endBorderProps)` TODO merge with drawRectangularBorders?

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### TOP

          protected static final int TOP

      Convention index of before top
      See Also:
        Constant Field Values

    - #### RIGHT

          protected static final int RIGHT

      Convention index of right border
      See Also:
        Constant Field Values

    - #### BOTTOM

          protected static final int BOTTOM

      Convention index of bottom border
      See Also:
        Constant Field Values

    - #### LEFT

          protected static final int LEFT

      Convention index of left border
      See Also:
        Constant Field Values

    - #### TOP_LEFT

          protected static final int TOP_LEFT

      Convention index of top-left border corners
      See Also:
        Constant Field Values

    - #### TOP_RIGHT

          protected static final int TOP_RIGHT

      Convention index of top-right-end border corners
      See Also:
        Constant Field Values

    - #### BOTTOM_RIGHT

          protected static final int BOTTOM_RIGHT

      Convention index of bottom-right border corners
      See Also:
        Constant Field Values

    - #### BOTTOM_LEFT

          protected static final int BOTTOM_LEFT

      Convention index of bottom-left border corners
      See Also:
        Constant Field Values

    - #### DASHED_BORDER_SPACE_RATIO

          public static final float DASHED_BORDER_SPACE_RATIO

      The ratio between a solid dash and the white-space in a dashed-border
      See Also:
        Constant Field Values

    - #### DASHED_BORDER_LENGTH_FACTOR

          protected static final float DASHED_BORDER_LENGTH_FACTOR

      The length of the dash as a factor of the border width i.e. 2 -> dashWidth = 2*borderWidth
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### BorderPainter

          public BorderPainter(GraphicsPainter graphicsPainter)

  - ### Method Detail

    - #### drawBorders

          public void drawBorders(java.awt.Rectangle borderRect,
                                  BorderProps bpsTop,
                                  BorderProps bpsBottom,
                                  BorderProps bpsLeft,
                                  BorderProps bpsRight,
                                  java.awt.Color innerBackgroundColor)
                           throws IFException

      Draws borders.
      Parameters:
        `borderRect` - the border rectangle
        `bpsTop` - the border specification on the top side
        `bpsBottom` - the border specification on the bottom side
        `bpsLeft` - the border specification on the left side
        `bpsRight` - the border specification on the end side
        `innerBackgroundColor` - the inner background color
      Throws:
        `IFException` - if an error occurs while drawing the borders

    - #### drawRectangularBorders

          protected void drawRectangularBorders(java.awt.Rectangle borderRect,
                                                BorderProps bpsTop,
                                                BorderProps bpsBottom,
                                                BorderProps bpsLeft,
                                                BorderProps bpsRight)
                                         throws java.io.IOException

      TODO merge with drawRoundedBorders()?
      Parameters:
        `borderRect` - the border rectangle
        `bpsTop` - the border specification on the top side
        `bpsBottom` - the border specification on the bottom side
        `bpsLeft` - the border specification on the left side
        `bpsRight` - the border specification on the end side
      Throws:
        `java.io.IOException`

    - #### dashWidthCalculator

          public static float dashWidthCalculator(float borderLength,
                                                  float borderWidth)

      This method calculates the length of the "dash" in a dashed border. The dash satisfies the condition that corners start on a dash and end with a dash (rather than ending with a white space).
      Parameters:
        `borderLength` - The length of the border.
        `borderWidth` - The width/thickness of the border.
      Returns:
        returns the length of the dash such that it fits the criteria above.

    - #### drawRoundedBorders

          protected void drawRoundedBorders(java.awt.Rectangle borderRect,
                                            BorderProps beforeBorderProps,
                                            BorderProps afterBorderProps,
                                            BorderProps startBorderProps,
                                            BorderProps endBorderProps)
                                     throws java.io.IOException

      TODO merge with drawRectangularBorders?
      Parameters:
        `borderRect` - the border rectangle
      Throws:
        `java.io.IOException` - on io exception

    - #### clipBackground

          public void clipBackground(java.awt.Rectangle rect,
                                     BorderProps bpsBefore,
                                     BorderProps bpsAfter,
                                     BorderProps bpsStart,
                                     BorderProps bpsEnd)
                              throws java.io.IOException

      Clip the background to the inner border
      Parameters:
        `rect` - clipping rectangle
        `bpsBefore` - before border
        `bpsAfter` - after border
        `bpsStart` - start border
        `bpsEnd` - end border
      Throws:
        `java.io.IOException` - if an I/O error occurs

    - #### calculateCornerCorrectionFactor

          protected static double calculateCornerCorrectionFactor(int width,
                                                                  int height,
                                                                  BorderProps before,
                                                                  BorderProps after,
                                                                  BorderProps start,
                                                                  BorderProps end)

      Calculate the correction factor to handle over-sized elliptic corner radii.
      Parameters:
        `width` - the border width
        `height` - the border height
        `before` - the before border properties
        `after` - the after border properties
        `start` - the start border properties
        `end` - the end border properties

    - #### calculateCornerScaleCorrection

          protected static double calculateCornerScaleCorrection(int width,
                                                                 int height,
                                                                 org.apache.fop.render.intermediate.BorderPainter.BorderSegment before,
                                                                 org.apache.fop.render.intermediate.BorderPainter.BorderSegment after,
                                                                 org.apache.fop.render.intermediate.BorderPainter.BorderSegment start,
                                                                 org.apache.fop.render.intermediate.BorderPainter.BorderSegment end)

      Calculate the scaling factor to handle over-sized elliptic corner radii.
      Parameters:
        `width` - the border width
        `height` - the border height
        `before` - the before border segment
        `after` - the after border segment
        `start` - the start border segment
        `end` - the end border segment

Copyright 1999-2022 The Apache Software Foundation. All Rights Reserved.