package edu.princeton.swing.text; /** * DefaultHighlightedDocument is a simple subclass of HighlightedDocument. * * @author Brian Tsang * @version 1.0 */ public class DefaultHighlightedDocument extends HighlightedDocument { /** * The only style in a DefaultHighlightedDocument. */ public static final byte STYLE_PLAIN = (byte)0; /** * Constructs a DefaultHighlightedDocument. */ public DefaultHighlightedDocument() { this(""); } /** * Constructs a DefaultHighlightedDocument. */ public DefaultHighlightedDocument(String text) { super(); setText(text); } /** * Returns the number of distinct styles used by this type of document. This must always * return the same number. * * @return The number of distinct styles used by this type of document. */ public int getStyleCount() { return 1; } /** * Returns the number of spaces to replace all tabs with. * * @return The number of spaces to replace all tabs with. */ public int getTabSize() { return 4; } /** * Updates the charStyles array based on chars, charCount, lineOffsets, and lineCount. The * implementation should assume that a write lock will have been obtained by the caller of this * function. */ protected void assignStyles() { for (int ctr = 0; ctr < charCount; ctr++) charStyles[ctr] = STYLE_PLAIN; } }