Class Border
- java.lang.Object
-
- com.itextpdf.layout.borders.Border
-
- Direct Known Subclasses:
AbstractFormBorder,Border3D,DashedBorder,DottedBorder,DoubleBorder,FixedDashedBorder,RoundDotsBorder,SolidBorder
public abstract class Border extends java.lang.ObjectRepresents a border.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBorder.SideEnumerates the different sides of the rectangle.
-
Field Summary
Fields Modifier and Type Field Description static int_3D_GROOVEThe 3D groove border.static int_3D_INSETThe 3D inset border.static int_3D_OUTSETThe 3D outset border.static int_3D_RIDGEThe 3D ridge border.private static intARC_BOTTOM_DEGREEprivate static intARC_LEFT_DEGREEprivate static intARC_QUARTER_CLOCKWISE_EXTENTprivate static intARC_RIGHT_DEGREEprivate static intARC_TOP_DEGREEstatic intDASHEDThe dashed border.static intDASHED_FIXEDThe fixed dashed border.static intDOTTEDThe dotted border.static intDOUBLEThe double border.private inthashThe hash value for the border.static BorderNO_BORDERThe null Border, i.e.static intROUND_DOTSThe round-dots border.static intSOLIDThe solid border.protected TransparentColortransparentColorThe color of the border.protected inttypeThe type of the border.protected floatwidthThe width of the border.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voiddraw(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.voiddraw(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 voiddraw(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.voiddraw(PdfCanvas canvas, Rectangle rectangle)Draw borders around the target rectangle.abstract voiddrawCellBorder(PdfCanvas canvas, float x1, float y1, float x2, float y2, Border.Side defaultSide)Draws the border of a cell.protected voiddrawDiscontinuousBorders(PdfCanvas canvas, Rectangle boundingRectangle, float[] horizontalRadii, float[] verticalRadii, Border.Side defaultSide, float borderWidthBefore, float borderWidthAfter)Perform drawing operations to draw discontinuous borders.booleanequals(java.lang.Object anObject)Indicates whether the border is equal to the given border.protected Border.SidegetBorderSide(float x1, float y1, float x2, float y2, Border.Side defaultSide)Returns thesidecorresponded to the line between two points.ColorgetColor()protected floatgetDotsGap(double distance, float initialGap)Adjusts the size of the gap between dotsprotected PointgetIntersectionPoint(Point lineBeg, Point lineEnd, Point clipLineBeg, Point clipLineEnd)Gets aPointin which two lines intersect.floatgetOpacity()Gets the opacity of theborderprotected 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 rectangleabstract intgetType()Returns the type of theborderfloatgetWidth()Gets the width of theborderinthashCode()voidsetColor(Color color)voidsetWidth(float width)Sets the width of theborder
-
-
-
Field Detail
-
NO_BORDER
public static final Border NO_BORDER
The null Border, i.e. the presence of such border is equivalent to the absence of the border
-
SOLID
public static final int SOLID
The solid border.- See Also:
SolidBorder, Constant Field Values
-
DASHED
public static final int DASHED
The dashed border.- See Also:
DashedBorder, Constant Field Values
-
DOTTED
public static final int DOTTED
The dotted border.- See Also:
DottedBorder, Constant Field Values
-
DOUBLE
public static final int DOUBLE
The double border.- See Also:
DoubleBorder, Constant Field Values
-
ROUND_DOTS
public static final int ROUND_DOTS
The round-dots border.- See Also:
RoundDotsBorder, Constant Field Values
-
_3D_GROOVE
public static final int _3D_GROOVE
The 3D groove border.- See Also:
GrooveBorder, Constant Field Values
-
_3D_INSET
public static final int _3D_INSET
The 3D inset border.- See Also:
InsetBorder, Constant Field Values
-
_3D_OUTSET
public static final int _3D_OUTSET
The 3D outset border.- See Also:
OutsetBorder, Constant Field Values
-
_3D_RIDGE
public static final int _3D_RIDGE
The 3D ridge border.- See Also:
RidgeBorder, Constant Field Values
-
DASHED_FIXED
public static final int DASHED_FIXED
The fixed dashed border.- See Also:
FixedDashedBorder, Constant Field Values
-
ARC_RIGHT_DEGREE
private static final int ARC_RIGHT_DEGREE
- See Also:
- Constant Field Values
-
ARC_TOP_DEGREE
private static final int ARC_TOP_DEGREE
- See Also:
- Constant Field Values
-
ARC_LEFT_DEGREE
private static final int ARC_LEFT_DEGREE
- See Also:
- Constant Field Values
-
ARC_BOTTOM_DEGREE
private static final int ARC_BOTTOM_DEGREE
- See Also:
- Constant Field Values
-
ARC_QUARTER_CLOCKWISE_EXTENT
private static final int ARC_QUARTER_CLOCKWISE_EXTENT
- See Also:
- Constant Field Values
-
transparentColor
protected TransparentColor transparentColor
The color of the border.- See Also:
TransparentColor
-
width
protected float width
The width of the border.
-
type
protected int type
The type of the border.
-
hash
private int hash
The hash value for the border.
-
-
Constructor Detail
-
Border
protected Border(float width)
- Parameters:
width- the width which the border should have
-
Border
protected Border(Color color, float width)
- Parameters:
color- the color which the border should havewidth- the width which the border should have
-
Border
protected Border(Color color, float width, float opacity)
- Parameters:
color- the color which the border should havewidth- the width which the border should haveopacity- 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.
borderWidthBeforeandborderWidthAfterparameters are used to define the widths of the borders that are before and after the current border, e.g. for the bottom border,borderWidthBeforespecifies width of the right border andborderWidthAfter- width of the left border. Those width are used to handle areas of border joins.- Parameters:
canvas- PdfCanvas to be written tox1- x coordinate of the beginning point of the element side, that should be borderedy1- y coordinate of the beginning point of the element side, that should be borderedx2- x coordinate of the ending point of the element side, that should be borderedy2- y coordinate of the ending point of the element side, that should be bordereddefaultSide- theBorder.Side, that we will fallback to, if it cannot be determined by border coordinatesborderWidthBefore- defines width of the border that is before the current oneborderWidthAfter- 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 torectangle- 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.
borderWidthBeforeandborderWidthAfterparameters are used to define the widths of the borders that are before and after the current border, e.g. for the bottom border,borderWidthBeforespecifies width of the right border andborderWidthAfter- width of the left border. Those width are used to handle areas of border joins.borderRadiusis used to draw rounded borders.- Parameters:
canvas- PdfCanvas to be written tox1- x coordinate of the beginning point of the element side, that should be borderedy1- y coordinate of the beginning point of the element side, that should be borderedx2- x coordinate of the ending point of the element side, that should be borderedy2- y coordinate of the ending point of the element side, that should be borderedborderRadius- defines the radius of the element's cornersdefaultSide- theBorder.Side, that we will fallback to, if it cannot be determined by border coordinatesborderWidthBefore- defines width of the border that is before the current oneborderWidthAfter- 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.
borderWidthBeforeandborderWidthAfterparameters are used to define the widths of the borders that are before and after the current border, e.g. for the bottom border,borderWidthBeforespecifies width of the right border andborderWidthAfter- width of the left border. Those width are used to handle areas of border joins.horizontalRadius1,verticalRadius1,horizontalRadius2andverticalRadius2are used to draw rounded borders.- Parameters:
canvas- PdfCanvas to be written tox1- x coordinate of the beginning point of the element side, that should be borderedy1- y coordinate of the beginning point of the element side, that should be borderedx2- x coordinate of the ending point of the element side, that should be borderedy2- y coordinate of the ending point of the element side, that should be borderedhorizontalRadius1- defines the horizontal radius of the border's first cornerverticalRadius1- defines the vertical radius of the border's first cornerhorizontalRadius2- defines the horizontal radius of the border's second cornerverticalRadius2- defines the vertical radius of the border's second cornerdefaultSide- theBorder.Side, that we will fallback to, if it cannot be determined by border coordinatesborderWidthBefore- defines width of the border that is before the current oneborderWidthAfter- 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 tox1- x coordinate of the beginning point of the element side, that should be borderedy1- y coordinate of the beginning point of the element side, that should be borderedx2- x coordinate of the ending point of the element side, that should be borderedy2- y coordinate of the ending point of the element side, that should be bordereddefaultSide- theBorder.Side, that we will fallback to, if it cannot be determined by border coordinates
-
getType
public abstract int getType()
Returns the type of theborder- Returns:
- the type of border.
-
getOpacity
public float getOpacity()
Gets the opacity of theborder- 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 theborder- Returns:
- the width
-
setColor
public void setColor(Color color)
- Parameters:
color- The color
-
setWidth
public void setWidth(float width)
Sets the width of theborder- 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getBorderSide
protected Border.Side getBorderSide(float x1, float y1, float x2, float y2, Border.Side defaultSide)
Returns thesidecorresponded 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 pointy1- the ordinate of the left-bottom pointx2- the abscissa of the right-top pointy2- the ordinate of the right-top pointdefaultSide- the default side of border- Returns:
- the corresponded
side
-
getIntersectionPoint
protected Point getIntersectionPoint(Point lineBeg, Point lineEnd, Point clipLineBeg, Point clipLineEnd)
Gets aPointin which two lines intersect.- Parameters:
lineBeg- aPointwhich defines some point on the first linelineEnd- aPointwhich defines another point on the first lineclipLineBeg- aPointwhich defines some point on the second lineclipLineEnd- aPointwhich 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- theborderlengthinitialGap- 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 byDashedBorder,DottedBorderandRoundDotsBorder.- Parameters:
canvas- canvas to draw onboundingRectangle- rectangle representing the bounding box of the drawing operationshorizontalRadii- the horizontal radius of the border's two cornersverticalRadii- the vertical radius of the border's two cornersdefaultSide- theBorder.Side, that we will fallback to, if it cannot be determined by border coordinatesborderWidthBefore- defines width of the border that is before the current oneborderWidthAfter- 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 Ay1- y-ordinate of point Ax2- x-coordinate of point By2- y-ordinate of point BdefaultSide- 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}
-
-