StreamDescriptionProperty, TitleProperty
Constructor and Description |
---|
FormulaDocument() |
Modifier and Type | Method and Description |
---|---|
void |
addDocumentListener(DocumentListener listener)
Registers the given observer to begin receiving notifications when changes are made to the document.
|
void |
addUndoableEditListener(UndoableEditListener listener)
Registers the given observer to begin receiving notifications when undoable edits are made to the document.
|
Position |
createPosition(int offs)
This method allows an application to mark a place in a sequence of character content.
|
protected void |
fireChangeEvent(DocumentEvent event) |
protected void |
fireInsertEvent(DocumentEvent event) |
protected void |
fireRemoveEvent(DocumentEvent event) |
Element |
getDefaultRootElement()
Returns the root element that views should be based upon, unless some other mechanism for assigning views to
element structures is provided.
|
FormulaElement |
getElementAtPosition(int index)
Retrieve the element at specified position.
|
Position |
getEndPosition()
Returns a position that represents the end of the document.
|
FunctionInformation |
getFunctionForPosition(int offset) |
int |
getLength()
Returns number of characters of content currently in the document.
|
Object |
getProperty(Object key)
Gets the properties associated with the document.
|
FormulaRootElement |
getRootElement() |
Element[] |
getRootElements()
Returns all of the root elements that are defined.
|
Position |
getStartPosition()
Returns a position that represents the start of the document.
|
String |
getText() |
String |
getText(int offset,
int length)
Fetches the text contained within the given portion of the document.
|
void |
getText(int offset,
int length,
Segment txt)
Fetches the text contained within the given portion of the document.
|
void |
insertString(int offset,
String str,
AttributeSet a)
Inserts a string of content.
|
void |
putProperty(Object key,
Object value)
Associates a property with the document.
|
void |
remove(int offs,
int len)
Removes a portion of the content of the document.
|
void |
removeDocumentListener(DocumentListener listener)
Unregisters the given observer from the notification list so it will no longer receive change updates.
|
void |
removeUndoableEditListener(UndoableEditListener listener)
Unregisters the given observer from the notification list so it will no longer receive updates.
|
void |
render(Runnable r)
Allows the model to be safely rendered in the presence of concurrency, if the model supports being updated
asynchronously.
|
void |
revalidateStructure() |
void |
setText(String text) |
public int getLength()
public void addDocumentListener(DocumentListener listener)
addDocumentListener
in interface Document
listener
- the observer to registerDocument.removeDocumentListener(javax.swing.event.DocumentListener)
public void removeDocumentListener(DocumentListener listener)
removeDocumentListener
in interface Document
listener
- the observer to registerDocument.addDocumentListener(javax.swing.event.DocumentListener)
protected void fireInsertEvent(DocumentEvent event)
protected void fireRemoveEvent(DocumentEvent event)
protected void fireChangeEvent(DocumentEvent event)
public void addUndoableEditListener(UndoableEditListener listener)
addUndoableEditListener
in interface Document
listener
- the observer to registerUndoableEditEvent
public void removeUndoableEditListener(UndoableEditListener listener)
removeUndoableEditListener
in interface Document
listener
- the observer to registerUndoableEditEvent
public Object getProperty(Object key)
getProperty
in interface Document
key
- a non-null
property keyputProperty(Object, Object)
public void putProperty(Object key, Object value)
StreamDescriptionProperty
and TitleProperty
. Other properties, such as author, may also be defined.putProperty
in interface Document
key
- the non-null
property keyvalue
- the property valuegetProperty(Object)
public Position getStartPosition()
getStartPosition
in interface Document
public Position getEndPosition()
getEndPosition
in interface Document
public Position createPosition(int offs) throws BadLocationException
createPosition
in interface Document
offs
- the offset from the start of the document >= 0BadLocationException
- if the given position does not represent a valid location in the associated documentpublic Element[] getRootElements()
Typically there will be only one document structure, but the interface supports building an arbitrary number of structural projections over the text data. The document can have multiple root elements to support multiple document structures. Some examples might be:
getRootElements
in interface Document
public Element getDefaultRootElement()
getDefaultRootElement
in interface Document
public FormulaRootElement getRootElement()
public void render(Runnable r)
public void remove(int offs, int len) throws BadLocationException
createPosition
have already changed. For a removal, the end of the removal range is
collapsed down to the start of the range, and any marks in the removal range are collapsed down to the start of the
range. If the Document structure changed as result of the removal, the details of what Elements were inserted and removed in response to the change will also be contained in the generated DocumentEvent. It is up to the implementation of a Document to decide how the structure should change in response to a remove. If the Document supports undo/redo, an UndoableEditEvent will also be generated.
remove
in interface Document
offs
- the offset from the beginning >= 0len
- the number of characters to remove >= 0BadLocationException
- some portion of the removal range was not a valid part of the document. The location
in the exception is the first bad position encountered.DocumentEvent
,
DocumentListener
,
UndoableEditEvent
,
UndoableEditListener
public void insertString(int offset, String str, AttributeSet a) throws BadLocationException
If the Document structure changed as result of the insertion, the details of what Elements were inserted and removed in response to the change will also be contained in the generated DocumentEvent. It is up to the implementation of a Document to decide how the structure should change in response to an insertion. If the Document supports undo/redo, an UndoableEditEvent will also be generated.
insertString
in interface Document
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 inserta
- the attributes to associate with the inserted content. This may be null if there are no attributes.BadLocationException
- the given insert position is not a valid position within the documentDocumentEvent
,
DocumentListener
,
UndoableEditEvent
,
UndoableEditListener
public String getText(int offset, int length) throws BadLocationException
getText
in interface Document
offset
- the offset into the document representing the desired start of the text >= 0length
- the length of the desired string >= 0BadLocationException
- some portion of the given range was not a valid part of the document. The location in
the exception is the first bad position encountered.public String getText()
public void getText(int offset, int length, Segment txt) throws BadLocationException
int nleft = doc.getDocumentLength();
Segment text = new Segment();
int offs = 0;
text.setPartialReturn(true);
while (nleft > 0) {
doc.getText(offs, nleft, text);
// do someting with text
nleft -= text.count;
offs += text.count;
}
getText
in interface Document
offset
- the offset into the document representing the desired start of the text >= 0length
- the length of the desired string >= 0txt
- the Segment object to return the text inBadLocationException
- Some portion of the given range was not a valid part of the document. The location in
the exception is the first bad position encountered.public FunctionInformation getFunctionForPosition(int offset)
public void setText(String text)
public FormulaElement getElementAtPosition(int index)
index
- public void revalidateStructure()
Copyright © 2017 Hitachi Vantara. All rights reserved.