Package com.itextpdf.layout.properties
Class Underline
java.lang.Object
com.itextpdf.layout.properties.Underline
A POJO that describes the underline of a layout element. This class is to be used as a property for an element or renderer, as the value for
Property.UNDERLINE
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
protected float
protected float
protected TransparentColor
protected float
protected float
-
Constructor Summary
ConstructorDescriptionUnderline
(Color color, float opacity, float thickness, float thicknessMul, float yPosition, float yPositionMul, int lineCapStyle) Creates an Underline.Underline
(Color color, float thickness, float thicknessMul, float yPosition, float yPositionMul, int lineCapStyle) Creates an Underline. -
Method Summary
Modifier and TypeMethodDescriptiongetColor()
Gets the color of the underline.int
Gets thePdfCanvasConstants.LineCapStyle
of the text underline.float
Gets the opacity of the underline color.float
getThickness
(float fontSize) Gets the total thickness of the underline (fixed + variable part).float
getYPosition
(float fontSize) Gets the vertical position of the underline (fixed + variable part).float
Gets the multiplier for the vertical positioning of the text underline.
-
Field Details
-
transparentColor
-
thickness
protected float thickness -
thicknessMul
protected float thicknessMul -
yPosition
protected float yPosition -
yPositionMul
protected float yPositionMul -
lineCapStyle
protected int lineCapStyle
-
-
Constructor Details
-
Underline
public Underline(Color color, float thickness, float thicknessMul, float yPosition, float yPositionMul, int lineCapStyle) Creates an Underline. Both the thickness and vertical positioning under the text element's base line can be set to a fixed value, or a variable one depending on the element's font size. If you want a fixed-width thickness, setthicknessMul
to 0; if you want a thickness solely dependent on the font size, setthickness
to 0. Mutatis mutandis for the y-position.- Parameters:
-
color
- theColor
of the underline -
thickness
- a float defining the minimum thickness in points of the underline -
thicknessMul
- a float defining the font size dependent component of the thickness of the underline -
yPosition
- a float defining the default absolute vertical distance in points from the text's base line -
yPositionMul
- a float defining the font size dependent component of the vertical positioning of the underline -
lineCapStyle
- the way the underline finishes at its edges.PdfCanvasConstants.LineCapStyle
-
Underline
public Underline(Color color, float opacity, float thickness, float thicknessMul, float yPosition, float yPositionMul, int lineCapStyle) Creates an Underline. Both the thickness and vertical positioning under the text element's base line can be set to a fixed value, or a variable one depending on the element's font size. If you want a fixed-width thickness, setthicknessMul
to 0; if you want a thickness solely dependent on the font size, setthickness
to 0. Mutatis mutandis for the y-position.- Parameters:
-
color
- theColor
of the underline -
opacity
- a float defining the opacity of the underline; a float between 0 and 1, where 1 stands for fully opaque color and 0 - for fully transparent -
thickness
- a float defining the minimum thickness in points of the underline -
thicknessMul
- a float defining the font size dependent component of the thickness of the underline -
yPosition
- a float defining the default absolute vertical distance in points from the text's base line -
yPositionMul
- a float defining the font size dependent component of the vertical positioning of the underline -
lineCapStyle
- the way the underline finishes at its edges.PdfCanvasConstants.LineCapStyle
-
-
Method Details
-
getColor
Gets the color of the underline.- Returns:
-
a
Color
-
getOpacity
public float getOpacity()Gets the opacity of the underline color.- Returns:
- a float between 0 and 1, where 1 stands for fully opaque color and 0 - for fully transparent
-
getThickness
public float getThickness(float fontSize) Gets the total thickness of the underline (fixed + variable part).- Parameters:
-
fontSize
- the font size for which to calculate the variable thickness - Returns:
-
the total thickness, as a
float
, in points
-
getYPosition
public float getYPosition(float fontSize) Gets the vertical position of the underline (fixed + variable part).- Parameters:
-
fontSize
- the font size for which to calculate the variable position - Returns:
-
the y-position, as a
float
, in points
-
getYPositionMul
public float getYPositionMul()Gets the multiplier for the vertical positioning of the text underline.- Returns:
-
the Y-position multiplier, as a
float
-
getLineCapStyle
public int getLineCapStyle()Gets thePdfCanvasConstants.LineCapStyle
of the text underline.- Returns:
-
the line cap style, as an
int
referring to the values ofPdfCanvasConstants.LineCapStyle
-