de.hunsicker.jalopy.swing.syntax
Class DefaultSyntaxDocument

java.lang.Object
  |
  +--javax.swing.text.AbstractDocument
        |
        +--javax.swing.text.PlainDocument
              |
              +--de.hunsicker.jalopy.swing.syntax.DefaultSyntaxDocument
All Implemented Interfaces:
javax.swing.text.Document, java.io.Serializable, SyntaxDocument

public class DefaultSyntaxDocument
extends javax.swing.text.PlainDocument
implements SyntaxDocument

A simple implementation of SyntaxDocument. It takes care of inserting and deleting lines from the token marker's state.

Version:
$Id: DefaultSyntaxDocument.java,v 1.1.2.1 2005/02/18 21:50:21 notzippy Exp $
Author:
Slava Pestov
See Also:
org.gjt.sp.jedit.syntax.SyntaxDocument, Serialized Form

Nested Class Summary
 class DefaultSyntaxDocument.DocumentHandler
          An implementation of DocumentListener that inserts and deletes lines from the token marker's state.
 
Field Summary
protected  java.awt.Color[] colors
          The colors
protected  TokenMarker tokenMarker
          The token marker
 
Fields inherited from class javax.swing.text.PlainDocument
lineLimitAttribute, tabSizeAttribute
 
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
DefaultSyntaxDocument()
          Creates a new DefaultSyntaxDocument instance.
 
Method Summary
 java.awt.Color[] getColors()
          Returns the color array that maps token identifiers to java.awt.Color objects.
 TokenMarker getTokenMarker()
          Returns the token marker that is to be used to split lines of this document up into tokens.
 void setColors(java.awt.Color[] colors)
          Sets the color array that maps token identifiers to java.awt.Color ojects.
 void setTokenMarker(TokenMarker tm)
          Sets the token marker that is to be used to split lines of this document up into tokens.
 void tokenizeLines()
          Reparses the document, by passing all lines to the token marker.
 void tokenizeLines(int start, int len)
          Reparses the document, by passing the specified lines to the token marker.
 
Methods inherited from class javax.swing.text.PlainDocument
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertString, insertUpdate, removeUpdate
 
Methods inherited from class javax.swing.text.AbstractDocument
addDocumentListener, 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, remove, removeDocumentListener, 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
addDocumentListener, addUndoableEditListener, createPosition, getDefaultRootElement, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, insertString, putProperty, remove, removeDocumentListener, removeUndoableEditListener, render
 

Field Detail

tokenMarker

protected TokenMarker tokenMarker
The token marker


colors

protected java.awt.Color[] colors
The colors

Constructor Detail

DefaultSyntaxDocument

public DefaultSyntaxDocument()
Creates a new DefaultSyntaxDocument instance.

Method Detail

setColors

public void setColors(java.awt.Color[] colors)
Sets the color array that maps token identifiers to java.awt.Color ojects. May throw an exception if this is not supported for this type of document.

Specified by:
setColors in interface SyntaxDocument
Parameters:
colors - The new color list

getColors

public java.awt.Color[] getColors()
Returns the color array that maps token identifiers to java.awt.Color objects.

Specified by:
getColors in interface SyntaxDocument
Returns:
The colors

setTokenMarker

public void setTokenMarker(TokenMarker tm)
Sets the token marker that is to be used to split lines of this document up into tokens. May throw an exception if this is not supported for this type of document.

Specified by:
setTokenMarker in interface SyntaxDocument
Parameters:
tm - The new token marker

getTokenMarker

public TokenMarker getTokenMarker()
Returns the token marker that is to be used to split lines of this document up into tokens. May return null if this document is not to be colorized.

Specified by:
getTokenMarker in interface SyntaxDocument
Returns:
The token marker

tokenizeLines

public void tokenizeLines()
Reparses the document, by passing all lines to the token marker. This should be called after the document is first loaded.

Specified by:
tokenizeLines in interface SyntaxDocument

tokenizeLines

public void tokenizeLines(int start,
                          int len)
Reparses the document, by passing the specified lines to the token marker. This should be called after a large quantity of text is first inserted.

Specified by:
tokenizeLines in interface SyntaxDocument
Parameters:
start - The first line to parse
len - The number of lines, after the first one to parse


Copyright © 1997-2005 Jalopy. All Rights Reserved.