Class Border

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Border.Side
      Enumerates the different sides of the rectangle.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Border​(float width)
      Creates a border with the given width.
      protected Border​(Color color, float width)
      Creates a border with given width and color.
      protected Border​(Color color, float width, float opacity)
      Creates a border with given width, color and opacity.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void draw​(PdfCanvas canvas, float x1, float y1, float x2, float y2, float horizontalRadius1, float verticalRadius1, float horizontalRadius2, float verticalRadius2, Border.Side defaultSide, float borderWidthBefore, float borderWidthAfter)
      All borders are supposed to be drawn in such way, that inner content of the element is on the right from the drawing direction.
      void draw​(PdfCanvas canvas, float x1, float y1, float x2, float y2, float borderRadius, Border.Side defaultSide, float borderWidthBefore, float borderWidthAfter)
      All borders are supposed to be drawn in such way, that inner content of the element is on the right from the drawing direction.
      abstract void draw​(PdfCanvas canvas, float x1, float y1, float x2, float y2, Border.Side defaultSide, float borderWidthBefore, float borderWidthAfter)
      All borders are supposed to be drawn in such way, that inner content of the element is on the right from the drawing direction.
      void draw​(PdfCanvas canvas, Rectangle rectangle)
      Draw borders around the target rectangle.
      abstract void drawCellBorder​(PdfCanvas canvas, float x1, float y1, float x2, float y2, Border.Side defaultSide)
      Draws the border of a cell.
      protected void drawDiscontinuousBorders​(PdfCanvas canvas, Rectangle boundingRectangle, float[] horizontalRadii, float[] verticalRadii, Border.Side defaultSide, float borderWidthBefore, float borderWidthAfter)
      Perform drawing operations to draw discontinuous borders.
      boolean equals​(java.lang.Object anObject)
      Indicates whether the border is equal to the given border.
      protected Border.Side getBorderSide​(float x1, float y1, float x2, float y2, Border.Side defaultSide)
      Returns the side corresponded to the line between two points.
      Color getColor()
      Gets the color of the border
      protected float getDotsGap​(double distance, float initialGap)
      Adjusts the size of the gap between dots
      protected Point getIntersectionPoint​(Point lineBeg, Point lineEnd, Point clipLineBeg, Point clipLineEnd)
      Gets a Point in which two lines intersect.
      float getOpacity()
      Gets the opacity of the border
      protected float[] getStartingPointsForBorderSide​(float x1, float y1, float x2, float y2, Border.Side defaultSide)
      Calculate adjusted starting points for discontinuous borders, given two opposing points (A and B) that define the bounding rectangle
      abstract int getType()
      Returns the type of the border
      float getWidth()
      Gets the width of the border
      int hashCode()
      void setColor​(Color color)
      Sets the color of the border
      void setWidth​(float width)
      Sets the width of the border
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Border

        protected Border​(float width)
        Creates a border with the given width. The color to be set by default is black
        Parameters:
        width - the width which the border should have
      • Border

        protected Border​(Color color,
                         float width)
        Creates a border with given width and color.
        Parameters:
        color - the color which the border should have
        width - the width which the border should have
      • Border

        protected Border​(Color color,
                         float width,
                         float opacity)
        Creates a border with given width, color and opacity.
        Parameters:
        color - the color which the border should have
        width - the width which the border should have
        opacity - the opacity which border should have; a float between 0 and 1, where 1 stands for fully opaque color and 0 - for fully transparent
    • Method Detail

      • draw

        public abstract void draw​(PdfCanvas canvas,
                                  float x1,
                                  float y1,
                                  float x2,
                                  float y2,
                                  Border.Side defaultSide,
                                  float borderWidthBefore,
                                  float borderWidthAfter)
        All borders are supposed to be drawn in such way, that inner content of the element is on the right from the drawing direction. Borders are drawn in this order: top, right, bottom, left.

        Given points specify the line which lies on the border of the content area, therefore the border itself should be drawn to the left from the drawing direction.

        borderWidthBefore and borderWidthAfter parameters are used to define the widths of the borders that are before and after the current border, e.g. for the bottom border, borderWidthBefore specifies width of the right border and borderWidthAfter - width of the left border. Those width are used to handle areas of border joins.

        Parameters:
        canvas - PdfCanvas to be written to
        x1 - x coordinate of the beginning point of the element side, that should be bordered
        y1 - y coordinate of the beginning point of the element side, that should be bordered
        x2 - x coordinate of the ending point of the element side, that should be bordered
        y2 - y coordinate of the ending point of the element side, that should be bordered
        defaultSide - the Border.Side, that we will fallback to, if it cannot be determined by border coordinates
        borderWidthBefore - defines width of the border that is before the current one
        borderWidthAfter - defines width of the border that is after the current one
      • draw

        public void draw​(PdfCanvas canvas,
                         Rectangle rectangle)
        Draw borders around the target rectangle.
        Parameters:
        canvas - PdfCanvas to be written to
        rectangle - border positions rectangle
      • draw

        public void draw​(PdfCanvas canvas,
                         float x1,
                         float y1,
                         float x2,
                         float y2,
                         float borderRadius,
                         Border.Side defaultSide,
                         float borderWidthBefore,
                         float borderWidthAfter)
        All borders are supposed to be drawn in such way, that inner content of the element is on the right from the drawing direction. Borders are drawn in this order: top, right, bottom, left.

        Given points specify the line which lies on the border of the content area, therefore the border itself should be drawn to the left from the drawing direction.

        borderWidthBefore and borderWidthAfter parameters are used to define the widths of the borders that are before and after the current border, e.g. for the bottom border, borderWidthBefore specifies width of the right border and borderWidthAfter - width of the left border. Those width are used to handle areas of border joins.

        borderRadius is used to draw rounded borders.

        Parameters:
        canvas - PdfCanvas to be written to
        x1 - x coordinate of the beginning point of the element side, that should be bordered
        y1 - y coordinate of the beginning point of the element side, that should be bordered
        x2 - x coordinate of the ending point of the element side, that should be bordered
        y2 - y coordinate of the ending point of the element side, that should be bordered
        borderRadius - defines the radius of the element's corners
        defaultSide - the Border.Side, that we will fallback to, if it cannot be determined by border coordinates
        borderWidthBefore - defines width of the border that is before the current one
        borderWidthAfter - defines width of the border that is after the current one
      • draw

        public void draw​(PdfCanvas canvas,
                         float x1,
                         float y1,
                         float x2,
                         float y2,
                         float horizontalRadius1,
                         float verticalRadius1,
                         float horizontalRadius2,
                         float verticalRadius2,
                         Border.Side defaultSide,
                         float borderWidthBefore,
                         float borderWidthAfter)
        All borders are supposed to be drawn in such way, that inner content of the element is on the right from the drawing direction. Borders are drawn in this order: top, right, bottom, left.

        Given points specify the line which lies on the border of the content area, therefore the border itself should be drawn to the left from the drawing direction.

        borderWidthBefore and borderWidthAfter parameters are used to define the widths of the borders that are before and after the current border, e.g. for the bottom border, borderWidthBefore specifies width of the right border and borderWidthAfter - width of the left border. Those width are used to handle areas of border joins.

        horizontalRadius1, verticalRadius1, horizontalRadius2 and verticalRadius2 are used to draw rounded borders.

        Parameters:
        canvas - PdfCanvas to be written to
        x1 - x coordinate of the beginning point of the element side, that should be bordered
        y1 - y coordinate of the beginning point of the element side, that should be bordered
        x2 - x coordinate of the ending point of the element side, that should be bordered
        y2 - y coordinate of the ending point of the element side, that should be bordered
        horizontalRadius1 - defines the horizontal radius of the border's first corner
        verticalRadius1 - defines the vertical radius of the border's first corner
        horizontalRadius2 - defines the horizontal radius of the border's second corner
        verticalRadius2 - defines the vertical radius of the border's second corner
        defaultSide - the Border.Side, that we will fallback to, if it cannot be determined by border coordinates
        borderWidthBefore - defines width of the border that is before the current one
        borderWidthAfter - defines width of the border that is after the current one
      • drawCellBorder

        public abstract void drawCellBorder​(PdfCanvas canvas,
                                            float x1,
                                            float y1,
                                            float x2,
                                            float y2,
                                            Border.Side defaultSide)
        Draws the border of a cell.
        Parameters:
        canvas - PdfCanvas to be written to
        x1 - x coordinate of the beginning point of the element side, that should be bordered
        y1 - y coordinate of the beginning point of the element side, that should be bordered
        x2 - x coordinate of the ending point of the element side, that should be bordered
        y2 - y coordinate of the ending point of the element side, that should be bordered
        defaultSide - the Border.Side, that we will fallback to, if it cannot be determined by border coordinates
      • getType

        public abstract int getType()
        Returns the type of the border
        Returns:
        the type of border.
      • getOpacity

        public float getOpacity()
        Gets the opacity of the border
        Returns:
        the border opacity; a float between 0 and 1, where 1 stands for fully opaque color and 0 - for fully transparent
      • getWidth

        public float getWidth()
        Gets the width of the border
        Returns:
        the width
      • setColor

        public void setColor​(Color color)
        Sets the color of the border
        Parameters:
        color - The color
      • setWidth

        public void setWidth​(float width)
        Sets the width of the border
        Parameters:
        width - The width
      • equals

        public boolean equals​(java.lang.Object anObject)
        Indicates whether the border is equal to the given border. The border type, width and color are considered during the comparison.
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getBorderSide

        protected Border.Side getBorderSide​(float x1,
                                            float y1,
                                            float x2,
                                            float y2,
                                            Border.Side defaultSide)
        Returns the side corresponded to the line between two points. Notice that we consider the rectangle traversal to be clockwise. In case side couldn't be detected we will fallback to default side
        Parameters:
        x1 - the abscissa of the left-bottom point
        y1 - the ordinate of the left-bottom point
        x2 - the abscissa of the right-top point
        y2 - the ordinate of the right-top point
        defaultSide - the default side of border
        Returns:
        the corresponded side
      • getIntersectionPoint

        protected Point getIntersectionPoint​(Point lineBeg,
                                             Point lineEnd,
                                             Point clipLineBeg,
                                             Point clipLineEnd)
        Gets a Point in which two lines intersect.
        Parameters:
        lineBeg - a Point which defines some point on the first line
        lineEnd - a Point which defines another point on the first line
        clipLineBeg - a Point which defines some point on the second line
        clipLineEnd - a Point which defines another point on the second line
        Returns:
        the intersection Point
      • getDotsGap

        protected float getDotsGap​(double distance,
                                   float initialGap)
        Adjusts the size of the gap between dots
        Parameters:
        distance - the border length
        initialGap - the initial size of the gap
        Returns:
        the adjusted size of the gap
      • drawDiscontinuousBorders

        protected void drawDiscontinuousBorders​(PdfCanvas canvas,
                                                Rectangle boundingRectangle,
                                                float[] horizontalRadii,
                                                float[] verticalRadii,
                                                Border.Side defaultSide,
                                                float borderWidthBefore,
                                                float borderWidthAfter)
        Perform drawing operations to draw discontinuous borders. Used by DashedBorder, DottedBorder and RoundDotsBorder.
        Parameters:
        canvas - canvas to draw on
        boundingRectangle - rectangle representing the bounding box of the drawing operations
        horizontalRadii - the horizontal radius of the border's two corners
        verticalRadii - the vertical radius of the border's two corners
        defaultSide - the Border.Side, that we will fallback to, if it cannot be determined by border coordinates
        borderWidthBefore - defines width of the border that is before the current one
        borderWidthAfter - defines width of the border that is after the current one
      • getStartingPointsForBorderSide

        protected float[] getStartingPointsForBorderSide​(float x1,
                                                         float y1,
                                                         float x2,
                                                         float y2,
                                                         Border.Side defaultSide)
        Calculate adjusted starting points for discontinuous borders, given two opposing points (A and B) that define the bounding rectangle
        Parameters:
        x1 - x-coordinate of point A
        y1 - y-ordinate of point A
        x2 - x-coordinate of point B
        y2 - y-ordinate of point B
        defaultSide - default side of the border used to determine the side given by points A and B
        Returns:
        float[] containing the adjusted starting points in the form {x1,y1,x2,y2}