| java.lang.Object javax.swing.text.EditorKit javax.swing.text.DefaultEditorKit oscript.swing.text.ODEEditorKit
ODEEditorKit | public class ODEEditorKit extends DefaultEditorKit (Code) | | An editor-kit for an ODE src code editor. The document used is just
a plain-old
PlainDocument . Rather than trying to integrate the
parser with the
Document 's
Element structure, the parsed
representation of the document is stored seperately as an array of tokens.
We create a
View for rendering the document that takes into account
the token that overlays a section of text, and the
AttributeSet which that token maps to, as it renders the text.
For performance reasons, parsing happens asynchronously, which means that
whenever the document is mutated. So, when there is an insert, we update
the (now out of date) tokens by increasing the end-offset of the current
token, and the begin-offset and end-offset of all subsequent tokens by the
number of characters inserted. When there is a remove, the process is
essentially the reverse.
The script side of things handles creating the parsing thread, and it uses
DocumentListener s to determine when reparsing is needed.
author: Rob Clark (rob@ti.com) author: version: 1.10 See Also: ODEEditorKit.createDefaultDocument |
Constructor Summary | |
public | ODEEditorKit() Class Constructor. |
ODEEditorKit | public ODEEditorKit()(Code) | | Class Constructor.
|
createDefaultDocument | public Document createDefaultDocument()(Code) | | Create a uninitialized document. The
Document used by this editor
kit is basically just a
PlainDocument that has been extended to
synchronously update the offsets of the tokens in response to document
mutations (insert/remove). This is important to ensure that the token's
offset maps to sensible positions in the document during the period between
when the document is edited, and when the parser has finished re-parsing it
an unitialized document |
getToken | public synchronized NodeToken getToken(int off)(Code) | | Given an offset into the document, find the corresponding token.
This is the API used by everything else for accessing the tokens.
The remaining methods are just used to implement this method.
Parameters: off - the offset into the document |
getViewFactory | public ViewFactory getViewFactory()(Code) | | Get a factory for producing
View s for rendering
Document s
created by this editor-kit.
the view-factory |
offsetToNodeToken | public String offsetToNodeToken(int off)(Code) | | |
setAttributeSetTable | public void setAttributeSetTable(SymbolMap attrSetTable)(Code) | | Set the attribute set table.
Parameters: attrSetTable - the table that maps NodeToken.kind to an attributeset. This table is created and maintained from script code, butused here while rendering the text. |
setDefaultFgColor | public static void setDefaultFgColor(Color c)(Code) | | |
setNodeTokens | public synchronized void setNodeTokens(Vector v)(Code) | | Called from script code after parsing is completed. For performance
reasons the tokens are stored here, after they are generated by script.
|
Methods inherited from javax.swing.text.DefaultEditorKit | public Caret createCaret()(Code)(Java Doc) public Document createDefaultDocument()(Code)(Java Doc) public Action[] getActions()(Code)(Java Doc) public String getContentType()(Code)(Java Doc) public ViewFactory getViewFactory()(Code)(Java Doc) public void read(InputStream in, Document doc, int pos) throws IOException, BadLocationException(Code)(Java Doc) public void read(Reader in, Document doc, int pos) throws IOException, BadLocationException(Code)(Java Doc) public void write(OutputStream out, Document doc, int pos, int len) throws IOException, BadLocationException(Code)(Java Doc) public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException(Code)(Java Doc)
|
Methods inherited from javax.swing.text.EditorKit | public Object clone()(Code)(Java Doc) abstract public Caret createCaret()(Code)(Java Doc) abstract public Document createDefaultDocument()(Code)(Java Doc) public void deinstall(JEditorPane c)(Code)(Java Doc) abstract public Action[] getActions()(Code)(Java Doc) abstract public String getContentType()(Code)(Java Doc) abstract public ViewFactory getViewFactory()(Code)(Java Doc) public void install(JEditorPane c)(Code)(Java Doc) abstract public void read(InputStream in, Document doc, int pos) throws IOException, BadLocationException(Code)(Java Doc) abstract public void read(Reader in, Document doc, int pos) throws IOException, BadLocationException(Code)(Java Doc) abstract public void write(OutputStream out, Document doc, int pos, int len) throws IOException, BadLocationException(Code)(Java Doc) abstract public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException(Code)(Java Doc)
|
|
|