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 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 ClassesModifier and TypeClassDescriptionstatic enum
The decoration added to text.Nested classes/interfaces inherited from interface ro.sync.ecss.extensions.api.highlights.PrioritizableHighlightPainter
PrioritizableHighlightPainter.ZLayer
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.ColorHighlightPainter
(Color color, int height, int totalHeight) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiongetColor()
protected int
Get the length to highlight.Get the text foreground color.All in the first layer.void
Renders the highlight.void
setBgColor
(Color bgColor) void
setBgColor
(Color bgColor, boolean useLineBoxHeight) void
Set the color used for decoration (strike out or underline)void
setStrikeOut
(boolean strikeOut) Deprecated.void
Set the text decoration.void
setTextDecorationStroke
(int stroke) Set the text decoration stroke.void
setTextForegroundColor
(Color foregroundColor) Set the text foreground color.boolean
-
Constructor Details
-
ColorHighlightPainter
public ColorHighlightPainter()Default constructor. The color is red. -
ColorHighlightPainter
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 Details
-
getZLayer
All in the first layer.- Specified by:
getZLayer
in interfacePrioritizableHighlightPainter
- Returns:
- the base layer.
- See Also:
-
paint
Description copied from interface:HighlightPainter
Renders the highlight.- Specified by:
paint
in interfaceHighlightPainter
- Parameters:
pi
- Information used by highlight- See Also:
-
getHighlightLength
Get the length to highlight.- Parameters:
pi
- The painter info.- Returns:
- the length to highlight.
-
setColor
Set the color used for decoration (strike out or underline)- Parameters:
c
- The decoration color.
-
setTextDecoration
Set the text decoration. If is set toColorHighlightPainter.TextDecoration.NONE
no line will be drawn.- Parameters:
decoration
- The new text decoration.
-
setBgColor
- Parameters:
bgColor
- The background color to set.
-
setBgColor
- 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.UsesetTextDecoration(TextDecoration)
instead.- Parameters:
strikeOut
- Set this highlight as strike out.
-
getBgColor
- Returns:
- Returns the background color.
-
getColor
- Returns:
- Returns the color used for decoration (strike out or underline)
-
setTextForegroundColor
Set the text foreground color.- Parameters:
foregroundColor
- The foreground color to set.- Since:
- 13.2
-
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:
-
setTextDecoration(TextDecoration)
instead.