Package org.fife.ui.rsyntaxtextarea
Class DefaultTokenPainter
java.lang.Object
org.fife.ui.rsyntaxtextarea.DefaultTokenPainter
- All Implemented Interfaces:
TokenPainter
- Direct Known Subclasses:
VisibleWhitespaceTokenPainter
Standard implementation of a token painter.
- Version:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Rectangle2D.Float
Rectangle used for filling token backgrounds.private static char[]
Micro-optimization; buffer used to compute tab width. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal float
paint
(Token token, Graphics2D g, float x, float y, RSyntaxTextArea host, TabExpander e) Paints this token.float
paint
(Token token, Graphics2D g, float x, float y, RSyntaxTextArea host, TabExpander e, float clipStart) Paints this token.float
paint
(Token token, Graphics2D g, float x, float y, RSyntaxTextArea host, TabExpander e, float clipStart, boolean paintBG) Paints this token.protected void
paintBackground
(float x, float y, float width, float height, Graphics2D g, int fontAscent, RSyntaxTextArea host, Color color) Paints the background of a token.protected float
paintImpl
(Token token, Graphics2D g, float x, float y, RSyntaxTextArea host, TabExpander e, float clipStart, boolean selected, boolean useSTC) Does the dirty-work of actually painting the token.float
paintSelected
(Token token, Graphics2D g, float x, float y, RSyntaxTextArea host, TabExpander e, boolean useSTC) Paints this token as it should appear in a selected region of text (assuming painting with a selection-foreground color is enabled in the parentRSyntaxTextArea
).float
paintSelected
(Token token, Graphics2D g, float x, float y, RSyntaxTextArea host, TabExpander e, float clipStart, boolean useSTC) Paints this token as it should appear in a selected region of text (assuming painting with a selection-foreground color is enabled in the parentRSyntaxTextArea
).protected void
paintTabLines
(Token token, int x, int y, int endX, Graphics2D g, TabExpander e, RSyntaxTextArea host) Paints dotted "tab" lines; that is, lines that show where your caret would go to on the line if you hit "tab".
-
Field Details
-
bgRect
Rectangle used for filling token backgrounds. -
tabBuf
private static char[] tabBufMicro-optimization; buffer used to compute tab width. If the width is correct it's not re-allocated, to prevent lots of very small garbage. Only used when painting tab lines.
-
-
Constructor Details
-
DefaultTokenPainter
DefaultTokenPainter()
-
-
Method Details
-
paint
public final float paint(Token token, Graphics2D g, float x, float y, RSyntaxTextArea host, TabExpander e) Description copied from interface:TokenPainter
Paints this token.- Specified by:
paint
in interfaceTokenPainter
- Parameters:
token
- The token to render.g
- The graphics context in which to paint.x
- The x-coordinate at which to paint.y
- The y-coordinate at which to paint.host
- The text area this token is in.e
- How to expand tabs.- Returns:
- The x-coordinate representing the end of the painted text.
-
paint
public float paint(Token token, Graphics2D g, float x, float y, RSyntaxTextArea host, TabExpander e, float clipStart) Description copied from interface:TokenPainter
Paints this token.- Specified by:
paint
in interfaceTokenPainter
- Parameters:
token
- The token to render.g
- The graphics context in which to paint.x
- The x-coordinate at which to paint.y
- The y-coordinate at which to paint.host
- The text area this token is in.e
- How to expand tabs.clipStart
- The left boundary of the clip rectangle in which we're painting. This optimizes painting by allowing us to not paint when this token is "to the left" of the clip rectangle.- Returns:
- The x-coordinate representing the end of the painted text.
-
paint
public float paint(Token token, Graphics2D g, float x, float y, RSyntaxTextArea host, TabExpander e, float clipStart, boolean paintBG) Description copied from interface:TokenPainter
Paints this token.- Specified by:
paint
in interfaceTokenPainter
- Parameters:
token
- The token to render.g
- The graphics context in which to paint.x
- The x-coordinate at which to paint.y
- The y-coordinate at which to paint.host
- The text area this token is in.e
- How to expand tabs.clipStart
- The left boundary of the clip rectangle in which we're painting. This optimizes painting by allowing us to not paint when this token is "to the left" of the clip rectangle.paintBG
- Whether to paint the background.- Returns:
- The x-coordinate representing the end of the painted text.
-
paintBackground
protected void paintBackground(float x, float y, float width, float height, Graphics2D g, int fontAscent, RSyntaxTextArea host, Color color) Paints the background of a token.- Parameters:
x
- The x-coordinate of the token.y
- The y-coordinate of the token.width
- The width of the token (actually, the width of the part of the token to paint).height
- The height of the token.g
- The graphics context with which to paint.fontAscent
- The ascent of the token's font.host
- The text area.color
- The color with which to paint.
-
paintImpl
protected float paintImpl(Token token, Graphics2D g, float x, float y, RSyntaxTextArea host, TabExpander e, float clipStart, boolean selected, boolean useSTC) Does the dirty-work of actually painting the token. -
paintSelected
public float paintSelected(Token token, Graphics2D g, float x, float y, RSyntaxTextArea host, TabExpander e, boolean useSTC) Description copied from interface:TokenPainter
Paints this token as it should appear in a selected region of text (assuming painting with a selection-foreground color is enabled in the parentRSyntaxTextArea
).- Specified by:
paintSelected
in interfaceTokenPainter
- Parameters:
token
- The token to render.g
- The graphics context in which to paint.x
- The x-coordinate at which to paint.y
- The y-coordinate at which to paint.host
- The text area this token is in.e
- How to expand tabs.useSTC
- Whether to use the text area's "selected text color."- Returns:
- The x-coordinate representing the end of the painted text.
-
paintSelected
public float paintSelected(Token token, Graphics2D g, float x, float y, RSyntaxTextArea host, TabExpander e, float clipStart, boolean useSTC) Description copied from interface:TokenPainter
Paints this token as it should appear in a selected region of text (assuming painting with a selection-foreground color is enabled in the parentRSyntaxTextArea
).- Specified by:
paintSelected
in interfaceTokenPainter
- Parameters:
token
- The token to render.g
- The graphics context in which to paint.x
- The x-coordinate at which to paint.y
- The y-coordinate at which to paint.host
- The text area this token is in.e
- How to expand tabs.clipStart
- The left boundary of the clip rectangle in which we're painting. This optimizes painting by allowing us to not paint when this token is "to the left" of the clip rectangle.useSTC
- Whether to use the text area's "selected text color."- Returns:
- The x-coordinate representing the end of the painted text.
-
paintTabLines
protected void paintTabLines(Token token, int x, int y, int endX, Graphics2D g, TabExpander e, RSyntaxTextArea host) Paints dotted "tab" lines; that is, lines that show where your caret would go to on the line if you hit "tab". This visual effect is usually done in the leading whitespace token(s) of lines.- Parameters:
token
- The token to render.x
- The starting x-offset of this token. It is assumed that this is the left margin of the text area (may be non-zero due to insets), since tab lines are only painted for leading whitespace.y
- The baseline where this token was painted.endX
- The ending x-offset of this token.g
- The graphics context.e
- Used to expand tabs.host
- The text area.
-