com.Ostermiller.Syntax
Class HighlightedDocument

java.lang.Object
  extended by javax.swing.text.AbstractDocument
      extended by javax.swing.text.DefaultStyledDocument
          extended by com.Ostermiller.Syntax.HighlightedDocument
All Implemented Interfaces:
Serializable, Document, StyledDocument

public class HighlightedDocument
extends DefaultStyledDocument

A demonstration text editor that uses syntax highlighting.

See Also:
Serialized Form

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 Object C_STYLE
           
static Object GRAYED_OUT_STYLE
           
static Object HTML_KEY_STYLE
           
static Object HTML_STYLE
           
static Object JAVA_STYLE
           
static Object JAVASCRIPT_STYLE
           
static Object LATEX_STYLE
           
static Object PLAIN_STYLE
           
static Object PROPERTIES_STYLE
           
static Object SQL_STYLE
           
 
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
HighlightedDocument()
          Create a new Demo
 
Method Summary
 void color(int position, int adjustment)
          Color a section of the document.
 void colorAll()
          Color or recolor the entire document
 void insertString(int offs, String str, AttributeSet a)
           
 void remove(int offs, int len)
           
 void setGlobalStyle(AttributeSet value)
           
 void setHighlightStyle(Object value)
           
 
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 javax.swing.text.AbstractDocument
addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
 
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

C_STYLE

public static final Object C_STYLE

HTML_STYLE

public static final Object HTML_STYLE

HTML_KEY_STYLE

public static final Object HTML_KEY_STYLE

JAVA_STYLE

public static final Object JAVA_STYLE

JAVASCRIPT_STYLE

public static final Object JAVASCRIPT_STYLE

LATEX_STYLE

public static final Object LATEX_STYLE

PLAIN_STYLE

public static final Object PLAIN_STYLE

PROPERTIES_STYLE

public static final Object PROPERTIES_STYLE

SQL_STYLE

public static final Object SQL_STYLE

GRAYED_OUT_STYLE

public static final Object GRAYED_OUT_STYLE
Constructor Detail

HighlightedDocument

public HighlightedDocument()
Create a new Demo

Method Detail

colorAll

public void colorAll()
Color or recolor the entire document


color

public void color(int position,
                  int adjustment)
Color a section of the document. The actual coloring will start somewhere before the requested position and continue as long as needed.

Parameters:
position - the starting point for the coloring.
adjustment - amount of text inserted or removed at the starting point.

setGlobalStyle

public void setGlobalStyle(AttributeSet value)

setHighlightStyle

public void setHighlightStyle(Object value)

insertString

public void insertString(int offs,
                         String str,
                         AttributeSet a)
                  throws BadLocationException
Specified by:
insertString in interface Document
Overrides:
insertString in class AbstractDocument
Throws:
BadLocationException

remove

public void remove(int offs,
                   int len)
            throws BadLocationException
Specified by:
remove in interface Document
Overrides:
remove in class AbstractDocument
Throws:
BadLocationException