|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.text.AbstractDocument | +--javax.swing.text.DefaultStyledDocument | +--com.bluemarsh.jswat.view.SourceDocument
Class SourceDocument holds the content for a styled source view. It extends the default styled document and adds line-awareness, such that the number of lines, and line offsets can be queried.
Inner classes inherited from class javax.swing.text.DefaultStyledDocument |
javax.swing.text.DefaultStyledDocument.AttributeUndoableEdit, javax.swing.text.DefaultStyledDocument.ElementBuffer, javax.swing.text.DefaultStyledDocument.ElementSpec, javax.swing.text.DefaultStyledDocument.SectionElement |
Inner classes inherited from class javax.swing.text.AbstractDocument |
javax.swing.text.AbstractDocument.AbstractElement, javax.swing.text.AbstractDocument.AttributeContext, javax.swing.text.AbstractDocument.BranchElement, javax.swing.text.AbstractDocument.Content, javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AbstractDocument.ElementEdit, javax.swing.text.AbstractDocument.LeafElement |
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 | |
SourceDocument()
Constructs a SourceDocument. |
Method Summary | |
void |
dump(java.io.PrintStream out)
Prints diagnostic information to the given output stream. |
int |
getLineCount()
Returns the number of lines in this document. |
int |
getLineEndOffset(int line)
Get the offset of the end of the given line. |
int |
getLineOfOffset(int offset)
Find the line containing the given offset. |
int |
getLineStartOffset(int line)
Get the offset of the start of the given line. |
void |
insertString(int offset,
java.lang.String str,
javax.swing.text.AttributeSet a)
Inserts a string of content. |
static java.lang.String |
replaceTabs(java.lang.String str,
int tabWidth)
Find and replace tabs with spaces. |
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, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeUndoableEditListener, render, setAsynchronousLoadPriority, 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, remove, removeUndoableEditListener, render |
Constructor Detail |
public SourceDocument()
Method Detail |
public void dump(java.io.PrintStream out)
dump
in class javax.swing.text.AbstractDocument
out
- stream to dump to.public int getLineCount()
public int getLineEndOffset(int line) throws javax.swing.text.BadLocationException
line
- zero-based line for which to find the end.javax.swing.text.BadLocationException
- Thrown if line is invalid.public int getLineOfOffset(int offset) throws javax.swing.text.BadLocationException
offset
- offset within document >= 0.javax.swing.text.BadLocationException
- Thrown if offset is invalid.public int getLineStartOffset(int line) throws javax.swing.text.BadLocationException
line
- zero-based line for which to find the start.javax.swing.text.BadLocationException
- Thrown if line is invalid.public void insertString(int offset, java.lang.String str, javax.swing.text.AttributeSet a) throws javax.swing.text.BadLocationException
insertString
in class javax.swing.text.AbstractDocument
offset
- the offset into the document to insert the content
>= 0. All positions that track change at or after
the given location will move.str
- the string to insert.a
- the attributes to associate with the inserted content.
This may be null if there are no attributes.javax.swing.text.BadLocationException
- the given insert position is not a valid position
within the documentpublic static java.lang.String replaceTabs(java.lang.String str, int tabWidth)
str
- string on which to operate.tabWidth
- width of tabs.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |