|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.text.AbstractDocument
javax.swing.text.DefaultStyledDocument
weka.gui.scripting.SyntaxDocument
public class SyntaxDocument
Highlights syntax in a DefaultStyledDocument. Allows any number of keywords to be formatted in any number of user-defined styles.
| Nested Class Summary | |
|---|---|
static class |
SyntaxDocument.ATTR_TYPE
The attribute type. |
| Nested classes/interfaces inherited from class javax.swing.text.DefaultStyledDocument |
|---|
DefaultStyledDocument.AttributeUndoableEdit, DefaultStyledDocument.ElementBuffer, DefaultStyledDocument.ElementSpec |
| Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument |
|---|
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement |
| Field Summary | |
|---|---|
static SimpleAttributeSet |
DEFAULT_COMMENT
the attribute set for comments. |
static String |
DEFAULT_FONT_FAMILY
the font family. |
static int |
DEFAULT_FONT_SIZE
the font size. |
static SimpleAttributeSet |
DEFAULT_KEYWORD
the attribute set for keywords. |
static SimpleAttributeSet |
DEFAULT_NORMAL
the attribute set for normal code. |
static SimpleAttributeSet |
DEFAULT_STRING
the attribute set for strings. |
static int |
MAX_TABS
the maximum number of tabs. |
| Fields inherited from class javax.swing.text.DefaultStyledDocument |
|---|
BUFFER_SIZE_DEFAULT |
| Fields inherited from class javax.swing.text.AbstractDocument |
|---|
BidiElementName, ContentElementName, ElementNameAttribute, ParagraphElementName, SectionElementName |
| Fields inherited from interface javax.swing.text.Document |
|---|
StreamDescriptionProperty, TitleProperty |
| Constructor Summary | |
|---|---|
SyntaxDocument(Properties props)
Initializes the document. |
|
| Method Summary | |
|---|---|
void |
addKeyword(String keyword,
MutableAttributeSet attr)
Associates a keyword with a particular formatting style. |
void |
addKeywords(String[] keywords,
MutableAttributeSet attr)
Associates the keywords with a particular formatting style. |
String |
escapeQuote(String quoteDelimiter)
Escapes the quote delimiter. |
boolean |
getAddMatchingEndBlocks()
Returns whether matching block ends are inserted or not. |
Color |
getBackgroundColor()
Returns the background color. |
String |
getBlockEnd()
Returns the end of a block. |
String |
getBlockStart()
Returns the start of a block. |
boolean |
getCaseSensitive()
Returns whether blanks are used instead of tabs. |
String |
getDelimiters()
Returns the delimiter characters to use. |
String |
getFontName()
gets the current font family. |
int |
getFontSize()
gets the current font size. |
int |
getIndentationSize()
Returns the number of blanks used for indentation. |
MutableAttributeSet |
getKeywordFormatting(String keyword)
Gets the formatting for a keyword. |
boolean |
getMultiLineComment()
Returns whether multi-line comments are enabled. |
String |
getMultiLineCommentEnd()
Returns the end of a multi-line comment. |
String |
getMultiLineCommentStart()
Returns the string that is the start of a multi-line comment. |
String |
getQuoteDelimiters()
Returns the quote delimiter characters to use. |
String |
getQuoteEscape()
Returns the character for escaping a quote delimiter. |
String |
getSingleLineCommentStart()
Retrusn the single line comment start string. |
boolean |
getUseBlanks()
Returns whether blanks are used instead of tabs. |
void |
insertString(int offset,
String str,
AttributeSet a)
Override to apply syntax highlighting after the document has been updated. |
boolean |
isDelimiter(String character)
Checks whether the character is a delimiter. |
boolean |
isQuoteDelimiter(String character)
Checks whether the character is quote delimiter. |
void |
processChangedLines(int offset,
int length)
Determine how many lines have been changed, then apply highlighting to each line. |
void |
remove(int offset,
int length)
Applies syntax highlighting after the document has been updated. |
void |
removeKeyword(String keyword)
Removes an association between a keyword with a particular formatting style. |
void |
setAddMatchingEndBlocks(boolean value)
Sets whether matching block ends are inserted or not. |
static void |
setAttributeColor(MutableAttributeSet attr,
Color c)
Sets the foreground (font) color of the specified attribute. |
void |
setAttributeColor(SyntaxDocument.ATTR_TYPE attr,
Color c)
Sets the foreground (font) color of the specified attribute. |
static void |
setAttributeFont(MutableAttributeSet attr,
Font f)
Sets the font of the specified attribute. |
void |
setAttributeFont(SyntaxDocument.ATTR_TYPE attr,
int style)
Sets the font of the specified attribute. |
void |
setBackgroundColor(Color value)
Sets the background color. |
void |
setBlockEnd(String value)
Sets the string that is the end of a block. |
void |
setBlockStart(String value)
Sets the string that is the start of a block. |
void |
setCaseSensitive(boolean value)
Sets whether the keywords are case-sensitive or not. |
void |
setDelimiters(String value)
Sets the delimiter characters to use. |
void |
setFontName(String fontName)
sets the current font family (affects all built-in styles). |
void |
setFontSize(int fontSize)
sets the current font size (affects all built-in styles). |
void |
setIndentationSize(int value)
Sets the number of blanks to use for indentation. |
void |
setMultiLineComment(boolean value)
Sets whether to enable multi-line comments. |
void |
setMultiLineCommentEnd(String value)
Sets the string that is the end of a multi-line comment. |
void |
setMultiLineCommentStart(String value)
Sets the string that is the start of a multi-line comment. |
void |
setQuoteDelimiters(String value)
Sets the quote delimiter characters to use. |
void |
setQuoteEscape(String value)
Sets the character to use for escaping a quote character. |
void |
setSingleLineCommentStart(String value)
Sets the string that is the start of a single-line comment. |
void |
setTabs(int charactersPerTab)
sets the number of characters per tab. |
void |
setUseBlanks(boolean value)
Sets whether to use blanks instead of tabs. |
| Methods inherited from class javax.swing.text.DefaultStyledDocument |
|---|
addDocumentListener, addStyle, getBackground, getCharacterElement, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getParagraphElement, getStyle, getStyleNames, removeDocumentListener, removeStyle, setCharacterAttributes, setLogicalStyle, setParagraphAttributes |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.swing.text.Document |
|---|
addUndoableEditListener, createPosition, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, putProperty, removeUndoableEditListener, render |
| Field Detail |
|---|
public static final int MAX_TABS
public static final String DEFAULT_FONT_FAMILY
public static final int DEFAULT_FONT_SIZE
public static final SimpleAttributeSet DEFAULT_NORMAL
public static final SimpleAttributeSet DEFAULT_COMMENT
public static final SimpleAttributeSet DEFAULT_STRING
public static final SimpleAttributeSet DEFAULT_KEYWORD
| Constructor Detail |
|---|
public SyntaxDocument(Properties props)
props - the properties to obtain the setup from| Method Detail |
|---|
public void setAttributeFont(SyntaxDocument.ATTR_TYPE attr,
int style)
attr - the attribute to apply this font to (normal, comment, string)style - font style (Font.BOLD, Font.ITALIC, Font.PLAIN)
public static void setAttributeFont(MutableAttributeSet attr,
Font f)
attr - attribute to apply this font tof - the font to use
public void setAttributeColor(SyntaxDocument.ATTR_TYPE attr,
Color c)
attr - the attribute to apply this font to (normal, comment, string)c - the color to use
public static void setAttributeColor(MutableAttributeSet attr,
Color c)
attr - attribute to apply this color toc - the color to use
public void addKeywords(String[] keywords,
MutableAttributeSet attr)
keywords - the tokens or words to formatattr - how to format the keywords
public void addKeyword(String keyword,
MutableAttributeSet attr)
keyword - the token or word to formatattr - how to format keywordpublic MutableAttributeSet getKeywordFormatting(String keyword)
keyword - the token or word to stop formatting
public void removeKeyword(String keyword)
keyword - the token or word to stop formattingpublic void setTabs(int charactersPerTab)
charactersPerTab - the characters per tab
public void insertString(int offset,
String str,
AttributeSet a)
throws BadLocationException
insertString in interface DocumentinsertString in class AbstractDocumentoffset - the offsetstr - the string to inserta - the attribute set, can be null
BadLocationException - if offset is invalid
public void remove(int offset,
int length)
throws BadLocationException
remove in interface Documentremove in class AbstractDocumentoffset - the offset of the deletionlength - the length of the deletion
BadLocationException - if offsets are invalid
public void processChangedLines(int offset,
int length)
throws BadLocationException
offset - the offset of the changed lineslength - the length of the change
BadLocationException - if offset is invalidpublic boolean isDelimiter(String character)
character - the character to check
public boolean isQuoteDelimiter(String character)
character - the character to check
public String escapeQuote(String quoteDelimiter)
quoteDelimiter - the string to escape
public int getFontSize()
public void setFontSize(int fontSize)
fontSize - the sizepublic String getFontName()
public void setFontName(String fontName)
fontName - the font namepublic void setIndentationSize(int value)
value - the number of blankspublic int getIndentationSize()
public void setDelimiters(String value)
value - the characterspublic String getDelimiters()
public void setQuoteDelimiters(String value)
value - the characterspublic String getQuoteDelimiters()
public void setQuoteEscape(String value)
value - the characterpublic String getQuoteEscape()
public void setSingleLineCommentStart(String value)
value - the stringpublic String getSingleLineCommentStart()
public void setMultiLineCommentStart(String value)
value - the stringpublic String getMultiLineCommentStart()
public void setMultiLineCommentEnd(String value)
value - the stringpublic String getMultiLineCommentEnd()
public void setBlockStart(String value)
value - the stringpublic String getBlockStart()
public void setBlockEnd(String value)
value - the stringpublic String getBlockEnd()
public void setAddMatchingEndBlocks(boolean value)
value - if true then matching block ends are insertedpublic boolean getAddMatchingEndBlocks()
public void setUseBlanks(boolean value)
value - if true then blanks are used instead of tabspublic boolean getUseBlanks()
public void setBackgroundColor(Color value)
value - the background colorpublic Color getBackgroundColor()
public void setMultiLineComment(boolean value)
value - if true then multi-line comments are enabledpublic boolean getMultiLineComment()
public void setCaseSensitive(boolean value)
value - if true then keywords are treated case-sensitivepublic boolean getCaseSensitive()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||