Class Underline
- java.lang.Object
-
- com.itextpdf.layout.properties.Underline
-
public class Underline extends java.lang.Object
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
Fields Modifier and Type Field Description private float[]
dashArray
private float
dashPhase
protected int
lineCapStyle
private TransparentColor
strokeColor
private float
strokeWidth
protected float
thickness
protected float
thicknessMul
protected TransparentColor
transparentColor
protected float
yPosition
protected float
yPositionMul
-
Constructor Summary
Constructors Constructor Description Underline(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Color
getColor()
Gets the color of the underline.float[]
getDashArray()
Gets dash array part of the dash pattern to be used when paths are stroked.float
getDashPhase()
Gets dash phase part of the dash pattern to be used when paths are stroked.int
getLineCapStyle()
Gets thePdfCanvasConstants.LineCapStyle
of the text underline.float
getOpacity()
Gets the opacity of the underline color.TransparentColor
getStrokeColor()
Gets the color of the underline stroke.float
getStrokeWidth()
Gets the thickness of the underline stroke.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
getYPositionMul()
Gets the multiplier for the vertical positioning of the text underline.Underline
setDashPattern(float[] dashArray, float dashPhase)
Sets a description of the dash pattern to be used when paths are stroked.Underline
setStrokeColor(TransparentColor strokeColor)
Sets the stroke color of the underline.Underline
setStrokeWidth(float strokeWidth)
Sets the thickness of the underline stroke.
-
-
-
Field Detail
-
transparentColor
protected TransparentColor transparentColor
-
thickness
protected float thickness
-
thicknessMul
protected float thicknessMul
-
yPosition
protected float yPosition
-
yPositionMul
protected float yPositionMul
-
lineCapStyle
protected int lineCapStyle
-
strokeColor
private TransparentColor strokeColor
-
strokeWidth
private float strokeWidth
-
dashArray
private float[] dashArray
-
dashPhase
private float dashPhase
-
-
Constructor Detail
-
Underline
public Underline(Color color, float thickness, float thicknessMul, float yPosition, float yPositionMul, int lineCapStyle)
Creates an Underline. Both 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 underlinethickness
- a float defining the minimum thickness in points of the underlinethicknessMul
- a float defining the font size dependent component of the thickness of the underlineyPosition
- a float defining the default absolute vertical distance in points from the text's base lineyPositionMul
- a float defining the font size dependent component of the vertical positioning of the underlinelineCapStyle
- 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 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 underlineopacity
- 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 transparentthickness
- a float defining the minimum thickness in points of the underlinethicknessMul
- a float defining the font size dependent component of the thickness of the underlineyPosition
- a float defining the default absolute vertical distance in points from the text's base lineyPositionMul
- a float defining the font size dependent component of the vertical positioning of the underlinelineCapStyle
- the way the underline finishes at its edges.PdfCanvasConstants.LineCapStyle
-
-
Method Detail
-
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
-
getStrokeColor
public TransparentColor getStrokeColor()
Gets the color of the underline stroke.- Returns:
TransparentColor
stroke color
-
setStrokeColor
public Underline setStrokeColor(TransparentColor strokeColor)
Sets the stroke color of the underline.- Parameters:
strokeColor
-TransparentColor
stroke color- Returns:
- this
Underline
instance
-
getStrokeWidth
public float getStrokeWidth()
Gets the thickness of the underline stroke.- Returns:
- float value of the stroke width
-
setStrokeWidth
public Underline setStrokeWidth(float strokeWidth)
Sets the thickness of the underline stroke.- Parameters:
strokeWidth
- float value of the stroke width- Returns:
- this
Underline
instance
-
getDashArray
public float[] getDashArray()
Gets dash array part of the dash pattern to be used when paths are stroked. Default value is solid line.The line dash pattern is expressed as an array of the form [ dashArray dashPhase ], where dashArray is itself an array and dashPhase is an integer.
An empty dash array (first element in the array) and zero phase (second element in the array) can be used to restore the dash pattern to a solid line.
- Returns:
- float dash array
-
getDashPhase
public float getDashPhase()
Gets dash phase part of the dash pattern to be used when paths are stroked. Default value is solid line.The line dash pattern is expressed as an array of the form [ dashArray dashPhase ], where dashArray is itself an array and dashPhase is an integer.
An empty dash array (first element in the array) and zero phase (second element in the array) can be used to restore the dash pattern to a solid line.
- Returns:
- float dash array
-
setDashPattern
public Underline setDashPattern(float[] dashArray, float dashPhase)
Sets a description of the dash pattern to be used when paths are stroked. Default value is solid line.The line dash pattern is expressed as an array of the form [ dashArray dashPhase ], where dashArray is itself an array and dashPhase is a number.
An empty dash array (first element in the array) and zero phase (second element in the array) can be used to restore the dash pattern to a solid line.
- Parameters:
dashArray
- dash arraydashPhase
- dash phase value- Returns:
- this same
Underline
instance
-
-