|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.text.AbstractDocument javax.swing.text.DefaultStyledDocument jwo.landserf.script.ScriptDocument
public class ScriptDocument
Creates a styled document for syntax highlighting of LandScript files. Based on the code originally described by Crafton, 1999. java.sys-con.com/read/36509.htm
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.text.DefaultStyledDocument |
---|
DefaultStyledDocument.AttributeUndoableEdit, DefaultStyledDocument.ElementBuffer, DefaultStyledDocument.ElementSpec, DefaultStyledDocument.SectionElement |
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 int |
COMMENT_MODE
Indicates the display of a comment in the script. |
static int |
NUMBER_MODE
Indicates display of a number in script. |
static int |
STRING_MODE
Indicates display of string text in script. |
static int |
TEXT_MODE
Indicates display of normal text in script. |
Fields inherited from class javax.swing.text.DefaultStyledDocument |
---|
buffer, BUFFER_SIZE_DEFAULT |
Fields inherited from class javax.swing.text.AbstractDocument |
---|
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName |
Fields inherited from interface javax.swing.text.Document |
---|
StreamDescriptionProperty, TitleProperty |
Constructor Summary | |
---|---|
ScriptDocument(JTextPane textPane)
Creates the styled document for displaying syntax highlighted landScript. |
Method Summary | |
---|---|
HashSet |
getKeywords()
Reports a list of reserved keywords that will be highlighted. |
void |
insertString(int offset,
String str,
AttributeSet attSet)
Inserts text at the given offset with the given attributes into the document. |
void |
remove(int offset,
int length)
Removes text at the given offset and length from the document. |
void |
setKeywords(HashSet keywords)
Sets the list of reserved keywords that will be highlighted. |
Methods inherited from class javax.swing.text.DefaultStyledDocument |
---|
addDocumentListener, addStyle, create, createDefaultRoot, getBackground, getCharacterElement, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getParagraphElement, getStyle, getStyleNames, insert, insertUpdate, removeDocumentListener, removeStyle, removeUpdate, setCharacterAttributes, setLogicalStyle, setParagraphAttributes, styleChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, 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 STRING_MODE
public static final int TEXT_MODE
public static final int NUMBER_MODE
public static final int COMMENT_MODE
Constructor Detail |
---|
public ScriptDocument(JTextPane textPane)
textPane
- Panel in which to display text.Method Detail |
---|
public void insertString(int offset, String str, AttributeSet attSet) throws BadLocationException
insertString
in interface Document
insertString
in class AbstractDocument
offset
- Offset from start of document at which to insert text.str
- Text to insert.attSet
- Attribute set to attach to string. Ignored.
BadLocationException
public void remove(int offset, int length) throws BadLocationException
remove
in interface Document
remove
in class AbstractDocument
offset
- Offset from start of document at which to remove text.length
- Length of text to remove.
BadLocationException
public HashSet getKeywords()
public void setKeywords(HashSet keywords)
keywords
- List of keywords that can be highlighted in document.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |