|
miSim | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--misim.editor.Token
A Token represents a section of text in a file. The token class may be subclassed to define particular behaviour of the token - such as it's visual characteristics, or the way in which the token is parsed. Tokens are immutable - that is, the text value of the token cannot be altered once set. This is relied upon for undo and redo operations in the EditorPanel. Tokens support cloning which is used by the Parser to create new instances of parsed tokens.
Field Summary | |
protected char[] |
display
|
protected java.lang.String |
text
The text value of this token |
static int |
TYPE_ALIAS
|
static int |
TYPE_COLON
|
static int |
TYPE_COMMA
|
static int |
TYPE_COMMAND
|
static int |
TYPE_COMMENT
|
static int |
TYPE_INSTRUCTION
|
static int |
TYPE_LISTING
|
static int |
TYPE_NUMBER
|
static int |
TYPE_OPERATOR
|
static int |
TYPE_STRING
|
static int |
TYPE_TOKEN
Constants for the token types |
static int |
TYPE_WHITESPACE
|
Constructor Summary | |
Token()
|
|
Token(java.lang.String text,
EditorPrefs prefs)
|
Method Summary | |
Token |
clone(java.lang.String source,
int index)
|
static Token |
consume(Token aToken,
int start)
Parsing method - to be implemented by subclasses. |
int |
draw(java.awt.Graphics g,
int x,
int y,
int startPos)
|
int |
drawChars(java.awt.Graphics g,
char[] charArray,
int x,
int y,
int startPos)
|
java.awt.Color |
getColour()
Return the text colour for this token |
int |
getColumn(int position,
int startPos)
Find the character column for the given position. |
int |
getLength()
Return the length of the token |
int |
getPixelPos(int column,
int startPos)
Return the pixel position of the given character |
EditorPrefs |
getPrefs()
Return the preferences object for this token |
int |
getType()
Return the type of this token |
java.lang.String |
getValue()
Return the value of the token |
void |
init(java.lang.String text,
EditorPrefs prefs,
int tokenType,
boolean uppercase)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int TYPE_TOKEN
public static final int TYPE_WHITESPACE
public static final int TYPE_COMMA
public static final int TYPE_COMMENT
public static final int TYPE_COMMAND
public static final int TYPE_INSTRUCTION
public static final int TYPE_ALIAS
public static final int TYPE_NUMBER
public static final int TYPE_OPERATOR
public static final int TYPE_STRING
public static final int TYPE_LISTING
public static final int TYPE_COLON
protected java.lang.String text
protected char[] display
Constructor Detail |
public Token()
public Token(java.lang.String text, EditorPrefs prefs)
Method Detail |
public void init(java.lang.String text, EditorPrefs prefs, int tokenType, boolean uppercase)
public static Token consume(Token aToken, int start)
aToken
- The token to consumestart
- The start indexpublic EditorPrefs getPrefs()
public java.lang.String getValue()
public java.awt.Color getColour()
public int getLength()
public int getType()
public int draw(java.awt.Graphics g, int x, int y, int startPos)
public int drawChars(java.awt.Graphics g, char[] charArray, int x, int y, int startPos)
public int getPixelPos(int column, int startPos)
column
- The character indexpublic int getColumn(int position, int startPos)
position
- The pixel position to findstartPos
- The pixel position of the start of the tokenpublic Token clone(java.lang.String source, int index) throws java.lang.CloneNotSupportedException
|
miSim | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |