|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.fife.ui.rsyntaxtextarea.Token
org.fife.ui.rsyntaxtextarea.VisibleWhitespaceToken
public class VisibleWhitespaceToken
This token class paints spaces and tabs with special symbols so the user can see the whitespace in his document. Rendering hints are honored.
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| Field Summary |
|---|
| Fields inherited from class org.fife.ui.rsyntaxtextarea.Token |
|---|
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 Summary | |
|---|---|
VisibleWhitespaceToken()
Creates a "null token." |
|
VisibleWhitespaceToken(char[] line,
int beg,
int end,
int startOffset,
int type)
Constructor. |
|
VisibleWhitespaceToken(javax.swing.text.Segment line,
int beg,
int end,
int startOffset,
int type)
Constructor. |
|
| Method Summary | |
|---|---|
int |
getListOffset(RSyntaxTextArea textArea,
javax.swing.text.TabExpander e,
float x0,
float x)
Determines the offset into this token list (i.e., into the document) that covers pixel location x if the token list
starts at pixel location x0. |
float |
getWidthUpTo(int numChars,
RSyntaxTextArea textArea,
javax.swing.text.TabExpander e,
float x0)
Returns the width of a specified number of characters in this token. |
java.awt.Rectangle |
listOffsetToView(RSyntaxTextArea textArea,
javax.swing.text.TabExpander e,
int pos,
int x0,
java.awt.Rectangle rect)
Returns the bounding box for the specified document location. |
float |
paint(java.awt.Graphics2D g,
float x,
float y,
RSyntaxTextArea host,
javax.swing.text.TabExpander e,
float clipStart)
Paints this token, using special symbols for whitespace characters. |
| Methods inherited from class org.fife.ui.rsyntaxtextarea.Token |
|---|
containsPosition, copyFrom, documentToToken, getHTMLRepresentation, getLastNonCommentNonWhitespaceToken, getLastPaintableToken, getLexeme, getNextToken, getOffsetBeforeX, getWidth, isHyperlink, isLeftCurly, isPaintable, isRightCurly, isSingleChar, isWhitespace, makeStartAt, moveOffset, paint, paintBackground, set, setHyperlink, setNextToken, tokenToDocument, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public VisibleWhitespaceToken()
public VisibleWhitespaceToken(javax.swing.text.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.| Method Detail |
|---|
public int getListOffset(RSyntaxTextArea textArea,
javax.swing.text.TabExpander e,
float x0,
float x)
x if the token list
starts at pixel location x0.
This method will return the document position "closest" to the
x-coordinate (i.e., if they click on the "right-half" of the
w in awe, the caret will be placed in
between the w and e; similarly, clicking on
the left-half places the caret between the a and
w). This makes it useful for methods such as
viewToModel found in javax.swing.text.View
subclasses.
getListOffset in class TokentextArea - The text area from which the token list was derived.e - How to expand tabs.x0 - The pixel x-location that is the beginning of
tokenList.x - The pixel-position for which you want to get the corresponding
offset.
tokenList is
null or has type Token.NULL, then
-1
public float getWidthUpTo(int numChars,
RSyntaxTextArea textArea,
javax.swing.text.TabExpander e,
float x0)
3
here returns the width of the "whi" portion of the token.This method is overridden to account for the case when "smooth fonts" are enabled; smooth fonts cause the token painting code to align things differently (since we "break" at spaces), so we need to reflect that behavior here as well.
getWidthUpTo in class TokennumChars - The number of characters for which to get the width.textArea - The text area in which this token is being painted.e - How to expand tabs. This value cannot be null.x0 - The pixel-location at which this token begins. This is
needed because of tabs.
Token.getWidth(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea, javax.swing.text.TabExpander, float)
public java.awt.Rectangle listOffsetToView(RSyntaxTextArea textArea,
javax.swing.text.TabExpander e,
int pos,
int x0,
java.awt.Rectangle rect)
null is returned.
listOffsetToView in class TokentextArea - The text area from which the token list was derived.e - How to expand tabs.pos - The position in the document for which to get the bounding
box in the view.x0 - The pixel x-location that is the beginning of
tokenList.rect - The rectangle in which we'll be returning the results. This
object is reused to keep from frequent memory allocations.
public final float paint(java.awt.Graphics2D g,
float x,
float y,
RSyntaxTextArea host,
javax.swing.text.TabExpander e,
float clipStart)
paint in class Tokeng - 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.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||