public class VisibleWhitespaceToken extends DefaultToken
The current implementation paints as follows:
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 a
float
). The way around this would be to calculate the token's
width in such a way that a float is returned (Font.getStringBounds()?).
Token
,
DefaultToken
COMMENT_DOCUMENTATION, COMMENT_EOL, COMMENT_MULTILINE, DATA_TYPE, ERROR_CHAR, ERROR_IDENTIFIER, ERROR_NUMBER_FORMAT, ERROR_STRING_DOUBLE, FUNCTION, IDENTIFIER, LITERAL_BACKQUOTE, LITERAL_BOOLEAN, LITERAL_CHAR, LITERAL_NUMBER_DECIMAL_INT, LITERAL_NUMBER_FLOAT, LITERAL_NUMBER_HEXADECIMAL, LITERAL_STRING_DOUBLE_QUOTE, MARKUP_TAG_ATTRIBUTE, MARKUP_TAG_DELIMITER, MARKUP_TAG_NAME, NULL, NUM_TOKEN_TYPES, offset, OPERATOR, PREPROCESSOR, RESERVED_WORD, SEPARATOR, text, textCount, textOffset, type, VARIABLE, WHITESPACE
Constructor and Description |
---|
VisibleWhitespaceToken()
Creates a "null token."
|
VisibleWhitespaceToken(char[] line,
int beg,
int end,
int startOffset,
int type)
Constructor.
|
VisibleWhitespaceToken(Segment line,
int beg,
int end,
int startOffset,
int type)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
float |
paint(Graphics2D g,
float x,
float y,
RSyntaxTextArea host,
TabExpander e,
float clipStart)
Paints this token, using special symbols for whitespace characters.
|
getListOffset, getWidthUpTo, listOffsetToView
appendHTMLRepresentation, containsPosition, copyFrom, documentToToken, getHTMLRepresentation, getLastNonCommentNonWhitespaceToken, getLastPaintableToken, getLexeme, getNextToken, getOffsetBeforeX, getWidth, is, isComment, isHyperlink, isLeftCurly, isPaintable, isRightCurly, isSingleChar, isWhitespace, makeStartAt, moveOffset, paint, paintBackground, set, setHyperlink, setNextToken, tokenToDocument, toString
public VisibleWhitespaceToken()
public VisibleWhitespaceToken(Segment line, int beg, int end, int startOffset, int type)
line
- The segment from which to get the token.beg
- The first character's position in line
.end
- The last character's position in line
.startOffset
- The offset into the document at which this
token begins.type
- A token type listed as "generic" above.public VisibleWhitespaceToken(char[] line, int beg, int end, int startOffset, int type)
line
- The segment from which to get the token.beg
- The first character's position in line
.end
- The last character's position in line
.startOffset
- The offset into the document at which this
token begins.type
- A token type listed as "generic" above.public final float paint(Graphics2D g, float x, float y, RSyntaxTextArea host, TabExpander e, float clipStart)
paint
in class DefaultToken
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
not paint when this token is "to the left" of the clip rectangle.