Package org.fife.ui.rsyntaxtextarea
Class VisibleWhitespaceTokenPainter
- java.lang.Object
-
- org.fife.ui.rsyntaxtextarea.DefaultTokenPainter
-
- org.fife.ui.rsyntaxtextarea.VisibleWhitespaceTokenPainter
-
- All Implemented Interfaces:
TokenPainter
class VisibleWhitespaceTokenPainter extends DefaultTokenPainter
A token painter that visibly renders whitespace (spaces and tabs).The current implementation paints as follows:
- The first tab or space, if any, is found in the token.
- If a tab was found, all characters up to it are painted as a group.
- If a space was found, all characters up to and including it are painted (it is painted with a special symbol to denote it as a space).
- If neither a tab nor a whitespace was found, all characters in the token are painted.
- Repeat until all characters are painted.
A problem with this implementation is that FontMetrics.charsWidth() is still used to calculate the width of a group of chars painted. Thus, the group of characters will be painted with the rendering hints specified, but the following tab (or group of characters if the current group was the end of a token) will not necessarily be painted at the proper x-coordinate (as FontMetrics.charsWidth() returns an
int
and not afloat
). The way around this would be to calculate the token's width in such a way that a float is returned (Font.getStringBounds()?).- Version:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description VisibleWhitespaceTokenPainter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected float
paintImpl(Token token, java.awt.Graphics2D g, float x, float y, RSyntaxTextArea host, javax.swing.text.TabExpander e, float clipStart, boolean selected, boolean useSTC)
Does the dirty-work of actually painting the token.-
Methods inherited from class org.fife.ui.rsyntaxtextarea.DefaultTokenPainter
paint, paint, paint, paintBackground, paintSelected, paintSelected, paintTabLines
-
-
-
-
Method Detail
-
paintImpl
protected float paintImpl(Token token, java.awt.Graphics2D g, float x, float y, RSyntaxTextArea host, javax.swing.text.TabExpander e, float clipStart, boolean selected, boolean useSTC)
Description copied from class:DefaultTokenPainter
Does the dirty-work of actually painting the token.- Overrides:
paintImpl
in classDefaultTokenPainter
-
-