public class SyntaxColoringModel extends DefaultTextEditModel
SyntaxColoringModel class implements the
TextEditModel interface. The SyntaxColoringModel
object hilights the syntax of the text representing a program written in
a computer language.DefaultTextEditModel.ParagraphStyleUndo, DefaultTextEditModel.ReplaceUndo, DefaultTextEditModel.TextStyleUndo| 修飾子とタイプ | フィールドと説明 |
|---|---|
protected java.awt.Font |
baseFont |
protected static java.lang.String |
COMMENT_STYLE
The comment style name.
|
protected NamedTextStyle |
commentStyle |
protected static java.lang.String |
CONSTANT_STYLE
The constant style name.
|
protected NamedTextStyle |
constantStyle |
protected LanguageTokenizerFactory |
factory |
protected static java.lang.String |
KEYWORD_STYLE
The keyword style name.
|
protected NamedTextStyle |
keywordStyle |
protected NamedTextStyle |
mlCommentStyle |
protected NamedTextStyle |
mlConstantStyle |
protected static java.lang.String |
MULTILINE_COMMENT_STYLE
The multiline comment style name.
|
protected static java.lang.String |
MULTILINE_CONSTANT_STYLE
The multiline constant style name.
|
protected static java.lang.String |
NORMAL_STYLE
The normal style name.
|
protected NamedTextStyle |
normalStyle |
protected boolean |
syntaxColoringEnabled |
textListener, textListenerKrichText, textModelListeners| 修飾子 | コンストラクタと説明 |
|---|---|
protected |
SyntaxColoringModel()
Constructs an empty model.
|
|
SyntaxColoringModel(RichText richText,
LanguageTokenizerFactory factory)
Constructs a model with the specified rich text and factory of the
language tokenizer.
|
|
SyntaxColoringModel(RichText richText,
LanguageTokenizerFactory factory,
java.awt.Font baseFont)
Constructs a model with the specified rich text, factory of the
language tokenizer, and base font.
|
| 修飾子とタイプ | メソッドと説明 |
|---|---|
protected int |
coloringSyntax(LanguageTokenizer tokenizer,
Text text)
Hilights the syntax of the specified text with the specified tokenizer.
|
protected int |
coloringSyntax(LanguageTokenizer tokenizer,
Text text,
boolean stopAtNotMultiLineConstant,
boolean stopAtNotMultiLineComment)
Hilights the syntax of the specified text with the specified tokenizer
and flags.
|
java.awt.Font |
getBaseFont()
Returns the base font of this model.
|
java.awt.Color |
getCommentColor()
Returns the font color for the comment tokens.
|
int |
getCommentStyle()
Returns the font style for the comment tokens.
|
java.awt.Color |
getConstantColor()
Returns the font color for the constant tokens.
|
int |
getConstantStyle()
Returns the font style for the constant tokens.
|
protected java.awt.Color |
getDefaultCommentColor()
Returns the default font color for the constant tokens.
|
protected int |
getDefaultCommentStyle()
Returns the default font style for the constant tokens.
|
protected java.awt.Color |
getDefaultConstantColor()
Returns the default font color for the constant tokens.
|
protected int |
getDefaultConstantStyle()
Returns the default font style for the constant tokens.
|
protected java.awt.Color |
getDefaultKeywordColor()
Returns the default font color for the keyword tokens.
|
protected int |
getDefaultKeywordStyle()
Returns the default font style for the keyword tokens.
|
protected java.awt.Color |
getDefaultNormalColor()
Returns the default font color for the normal tokens.
|
protected int |
getDefaultNormalStyle()
Returns the default font style for the normal tokens.
|
java.awt.Color |
getKeywordColor()
Returns the font color for the keyword tokens.
|
int |
getKeywordStyle()
Returns the font style for the keyword tokens.
|
java.awt.Color |
getNormalColor()
Returns the font color for the normal tokens.
|
int |
getNormalStyle()
Returns the font style for the normal tokens.
|
protected LanguageTokenizer |
getTokenizer(Text text,
int begin,
int end)
Creates new tokenizer from the factory.
|
protected int |
getTokenType(Text text,
int index)
Gets the token type at the specified index of the specified text.
|
boolean |
isSyntaxColoringEnabled()
Tests if the syntax coloring is enabled.
|
Undo |
modifyTextStyle(int begin,
int end,
TextStyleModifier modifier) |
protected void |
notifyTextModelListeners(int begin,
int end,
TextChange change)
Notifies the text model event to the text model listeners.
|
protected Undo |
replace(int repBegin,
int repEnd,
RichText rep)
Replaces the specified range of the rich text of this model with
the specified replacement rich text object.
|
Undo |
replace(int repBegin,
int repEnd,
Text rep)
Replaces the specified range of the rich text of this model with
the specified replacement text object.
|
void |
setBaseFont(java.awt.Font baseFont)
Sets the base font of this model.
|
void |
setCommentColor(java.awt.Color color)
Sets the font color for the comment tokens.
|
void |
setCommentStyle(int fontStyle)
Sets the font style for the comment tokens.
|
void |
setCommentStyleAndColor(int fontStyle,
java.awt.Color color)
Sets the font style and color for the comment tokens.
|
void |
setConstantColor(java.awt.Color color)
Sets the font color for the constant tokens.
|
void |
setConstantStyle(int fontStyle)
Sets the font style for the constant tokens.
|
void |
setConstantStyleAndColor(int fontStyle,
java.awt.Color color)
Sets the font style and color for the constant tokens.
|
void |
setKeywordColor(java.awt.Color color)
Sets the font color for the keyword tokens.
|
void |
setKeywordStyle(int fontStyle)
Sets the font style for the keyword tokens.
|
void |
setKeywordStyleAndColor(int fontStyle,
java.awt.Color color)
Sets the font style and color for the keyword tokens.
|
void |
setNormalColor(java.awt.Color color)
Sets the font color for the normal tokens.
|
void |
setNormalStyle(int fontStyle)
Sets the font style for the normal tokens.
|
void |
setNormalStyleAndColor(int fontStyle,
java.awt.Color color)
Sets the font style and color for the normal tokens.
|
void |
setRichText(RichText richText)
Sets the rich text of this model to be the specified rich text.
|
void |
setSyntaxColoringEnabled(boolean b)
Enables or disables the syntax coloring.
|
Undo |
setTextStyle(int begin,
int end,
TextStyle textStyle) |
addTextListener, modifyParagraphStyle, notifyTextListeners, removeTextListener, setParagraphStyle, setParagraphStyles, setTextStylesaddTextModelListener, getRichText, notifyTextModelListeners, removeTextModelListenerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddTextModelListener, getRichText, removeTextModelListenerprotected LanguageTokenizerFactory factory
protected boolean syntaxColoringEnabled
protected java.awt.Font baseFont
protected NamedTextStyle normalStyle
protected NamedTextStyle keywordStyle
protected NamedTextStyle constantStyle
protected NamedTextStyle mlConstantStyle
protected NamedTextStyle commentStyle
protected NamedTextStyle mlCommentStyle
protected static final java.lang.String NORMAL_STYLE
protected static final java.lang.String KEYWORD_STYLE
protected static final java.lang.String CONSTANT_STYLE
protected static final java.lang.String MULTILINE_CONSTANT_STYLE
protected static final java.lang.String COMMENT_STYLE
protected static final java.lang.String MULTILINE_COMMENT_STYLE
public SyntaxColoringModel(RichText richText, LanguageTokenizerFactory factory)
richText - the rich text.factory - the factory of the language tokenizer.public SyntaxColoringModel(RichText richText, LanguageTokenizerFactory factory, java.awt.Font baseFont)
richText - the rich text.factory - the factory of the language tokenizer.baseFont - the base font of the model.protected SyntaxColoringModel()
public boolean isSyntaxColoringEnabled()
public void setSyntaxColoringEnabled(boolean b)
public int getNormalStyle()
public java.awt.Color getNormalColor()
public int getKeywordStyle()
public java.awt.Color getKeywordColor()
public int getConstantStyle()
public java.awt.Color getConstantColor()
public int getCommentStyle()
public java.awt.Color getCommentColor()
public void setNormalStyle(int fontStyle)
public void setNormalColor(java.awt.Color color)
public void setNormalStyleAndColor(int fontStyle,
java.awt.Color color)
public void setKeywordStyle(int fontStyle)
public void setKeywordColor(java.awt.Color color)
public void setKeywordStyleAndColor(int fontStyle,
java.awt.Color color)
public void setConstantStyle(int fontStyle)
public void setConstantColor(java.awt.Color color)
public void setConstantStyleAndColor(int fontStyle,
java.awt.Color color)
public void setCommentStyle(int fontStyle)
public void setCommentColor(java.awt.Color color)
public void setCommentStyleAndColor(int fontStyle,
java.awt.Color color)
public java.awt.Font getBaseFont()
public void setBaseFont(java.awt.Font baseFont)
public void setRichText(RichText richText)
setRichText インタフェース内 TextModelsetRichText クラス内 DefaultTextEditModelrichText - the rich text.public Undo replace(int repBegin, int repEnd, Text rep)
replace インタフェース内 TextEditModelreplace クラス内 DefaultTextEditModelrepBegin - the beginning text position to replace, inclusive.repEnd - the ending text position to replace, exclusive.rep - a replacement Text object.null if
the undo is not supported.protected void notifyTextModelListeners(int begin,
int end,
TextChange change)
public Undo setTextStyle(int begin, int end, TextStyle textStyle)
setTextStyle インタフェース内 TextEditModelsetTextStyle クラス内 DefaultTextEditModelpublic Undo modifyTextStyle(int begin, int end, TextStyleModifier modifier)
modifyTextStyle インタフェース内 TextEditModelmodifyTextStyle クラス内 DefaultTextEditModelprotected Undo replace(int repBegin, int repEnd, RichText rep)
replace クラス内 DefaultTextEditModelrepBegin - the beginning text position to replace, inclusive.repEnd - the ending text position to replace, exclusive.rep - a replacement RichText object.null if
the undo is not supported.protected int coloringSyntax(LanguageTokenizer tokenizer, Text text)
protected int coloringSyntax(LanguageTokenizer tokenizer, Text text, boolean stopAtNotMultiLineConstant, boolean stopAtNotMultiLineComment)
protected int getDefaultNormalStyle()
protected java.awt.Color getDefaultNormalColor()
protected int getDefaultKeywordStyle()
protected java.awt.Color getDefaultKeywordColor()
protected int getDefaultConstantStyle()
protected java.awt.Color getDefaultConstantColor()
protected int getDefaultCommentStyle()
protected java.awt.Color getDefaultCommentColor()
protected LanguageTokenizer getTokenizer(Text text, int begin, int end)
protected int getTokenType(Text text, int index)