Class ColorHighlightPainter
- java.lang.Object
-
- ro.sync.ecss.extensions.api.highlights.ColorHighlightPainter
-
- All Implemented Interfaces:
HighlightPainter
,PrioritizableHighlightPainter
,TextForegroundHighlighterPainter
@API(type=EXTENDABLE, src=PUBLIC) public class ColorHighlightPainter extends java.lang.Object implements TextForegroundHighlighterPainter, PrioritizableHighlightPainter
Painter that can be used to customize the way that a highlight is displayed by setting custom text decoration, text decoration stroke, background color or stroke color.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ColorHighlightPainter.TextDecoration
The decoration added to text.-
Nested classes/interfaces inherited from interface ro.sync.ecss.extensions.api.highlights.PrioritizableHighlightPainter
PrioritizableHighlightPainter.ZLayer
-
-
Constructor Summary
Constructors Constructor Description ColorHighlightPainter()
Default constructor.ColorHighlightPainter(Color color, int height, int totalHeight)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Color
getBgColor()
Color
getColor()
protected int
getHighlightLength(HighlightPainterInfo pi)
Get the length to highlight.Color
getTextForegroundColor()
Get the text foreground color.PrioritizableHighlightPainter.ZLayer
getZLayer()
All in the first layer.void
paint(HighlightPainterInfo pi)
Renders the highlight.void
setBgColor(Color bgColor)
void
setBgColor(Color bgColor, boolean useLineBoxHeight)
void
setColor(Color c)
Set the color used for decoration (strike out or underline)void
setStrikeOut(boolean strikeOut)
Deprecated.UsesetTextDecoration(TextDecoration)
instead.void
setTextDecoration(ColorHighlightPainter.TextDecoration decoration)
Set the text decoration.void
setTextDecorationStroke(int stroke)
Set the text decoration stroke.void
setTextForegroundColor(Color foregroundColor)
Set the text foreground color.boolean
useBaseLineForUnderline()
-
-
-
Constructor Detail
-
ColorHighlightPainter
public ColorHighlightPainter()
Default constructor. The color is red.
-
ColorHighlightPainter
public ColorHighlightPainter(Color color, int height, int totalHeight)
Constructor.- Parameters:
color
- The color to use for highlight.height
- The height of the highlight line. This may be smaller than the total height. If it is, the extra space will remain under the line.totalHeight
- The height of the highlight.
-
-
Method Detail
-
getZLayer
public PrioritizableHighlightPainter.ZLayer getZLayer()
All in the first layer.- Specified by:
getZLayer
in interfacePrioritizableHighlightPainter
- Returns:
- the base layer.
- See Also:
PrioritizableHighlightPainter.getZLayer()
-
paint
public void paint(HighlightPainterInfo pi)
Description copied from interface:HighlightPainter
Renders the highlight.- Specified by:
paint
in interfaceHighlightPainter
- Parameters:
pi
- Information used by highlight- See Also:
HighlightPainter.paint(ro.sync.ecss.extensions.api.highlights.HighlightPainterInfo)
-
getHighlightLength
protected int getHighlightLength(HighlightPainterInfo pi)
Get the length to highlight.- Parameters:
pi
- The painter info.- Returns:
- the length to highlight.
-
setColor
public void setColor(Color c)
Set the color used for decoration (strike out or underline)- Parameters:
c
- The decoration color.
-
setTextDecoration
public void setTextDecoration(ColorHighlightPainter.TextDecoration decoration)
Set the text decoration. If is set toColorHighlightPainter.TextDecoration.NONE
no line will be drawn.- Parameters:
decoration
- The new text decoration.
-
setBgColor
public void setBgColor(Color bgColor)
- Parameters:
bgColor
- The background color to set.
-
setBgColor
public void setBgColor(Color bgColor, boolean useLineBoxHeight)
- Parameters:
bgColor
- The background color to set.useLineBoxHeight
-true
to use the parent line height for drawing the background color.
-
useBaseLineForUnderline
public boolean useBaseLineForUnderline()
- Returns:
- true if use the base line for underlining
-
setTextDecorationStroke
public void setTextDecorationStroke(int stroke)
Set the text decoration stroke.- Parameters:
stroke
- The new Stroke type. Constants are defined inGraphics
.
-
setStrikeOut
@Deprecated public void setStrikeOut(boolean strikeOut)
Deprecated.UsesetTextDecoration(TextDecoration)
instead.- Parameters:
strikeOut
- Set this highlight as strike out.
-
getBgColor
public Color getBgColor()
- Returns:
- Returns the background color.
-
getColor
public Color getColor()
- Returns:
- Returns the color used for decoration (strike out or underline)
-
setTextForegroundColor
public void setTextForegroundColor(Color foregroundColor)
Set the text foreground color.- Parameters:
foregroundColor
- The foreground color to set.- Since:
- 13.2
-
getTextForegroundColor
public Color getTextForegroundColor()
Get the text foreground color.- Specified by:
getTextForegroundColor
in interfaceTextForegroundHighlighterPainter
- Returns:
- the color for the text foreground. NULL for inhibiting this feature.
- Since:
- 13.2
- See Also:
TextForegroundHighlighterPainter.getTextForegroundColor()
-
-