public class SimpleLinePainter extends java.lang.Object implements UnderlinePainter
SimpleLinePainter is an implementation of the UnderlinePainter which paints a straight underline or separator of a given thickness.| Modifier and Type | Field and Description |
|---|---|
protected int |
_thickness
The thickness of the line to paint.
|
protected int |
_underlineType
The type of underline, such as TYPE_UNDERLINE or TYPE_SEPARATOR.
|
static int |
MAX_THICKNESS
The maximum thickness that can be specified to the line painter.
|
TYPE_SEPARATOR, TYPE_STRIKETHRU, TYPE_UNDERLINE| Constructor and Description |
|---|
SimpleLinePainter(int thickness, int underlineType)
Constructs a new
SimpleLinePainter of the specified thickness. |
| Modifier and Type | Method and Description |
|---|---|
int |
getUnderlineType()
Fetch the type of underline, such as TYPE_SEPARATOR.
|
protected int |
getYPos(int yTop, int yBaseline, int descent)
Utility routine to calculate the appropriate y position to start painting downwards from, based on the requested paint position (from baseline or from bottom), and the yBaseline coordinate and the descent.)
|
void |
paintUnderline(java.awt.Graphics graphics, java.awt.Color color, int xPos, int width, int yTop, int yBaseline, int descent)
Paints the underline using this implementation of the
UnderlinePainter. |
public static final int MAX_THICKNESS
protected final int _thickness
protected final int _underlineType
public SimpleLinePainter(int thickness,
int underlineType)
SimpleLinePainter of the specified thickness. Any thickness greater than MAX_THICKNESS will be automatically reduced. The type of underline indicates where the underline will be painted.thickness - the thickness of the line to paintunderlineType - the type of underline, such as TYPE_SEPARATOR
protected int getYPos(int yTop,
int yBaseline,
int descent)
yBaseline - the y position of the baselinedescent - the descent of the text below the baseline
public void paintUnderline(java.awt.Graphics graphics,
java.awt.Color color,
int xPos,
int width,
int yTop,
int yBaseline,
int descent)
UnderlinePainter.paintUnderline in interface UnderlinePaintergraphics - the graphics context to paint intocolor - the color to use for painting the underlinexPos - the x position to start painting fromwidth - the width of the underline to paintyTop - the y position of the top of the textyBaseline - the y position of the baseline of the text we are drawing an underline fordescent - the descent of the font the text was drawn withpublic int getUnderlineType()
getUnderlineType in interface UnderlinePainter