javax.swing.text
public class DefaultStyledDocument.ElementBuffer extends Object implements Serializable
Element
hierarchy. This class was implemented with much help from the document:
http://java.sun.com/products/jfc/tsc/articles/text/element_buffer/index.html.
Constructor Summary | |
---|---|
ElementBuffer(Element root)
Creates a new ElementBuffer for the specified
root element.
|
Method Summary | |
---|---|
void | change(int offset, int length, DefaultDocumentEvent ev)
Modifies the element structure so that the specified interval starts and
ends at an element boundary. |
protected void | changeUpdate()
Performs the actual work for {@link #change}. |
Element | clone(Element parent, Element clonee)
Creates and returns a deep clone of the specified clonee
with the specified parent as new parent.
|
Element | getRootElement()
Returns the root element of this ElementBuffer .
|
void | insert(int offset, int length, DefaultStyledDocument.ElementSpec[] data, DefaultDocumentEvent ev)
Inserts new Element in the document at the specified
position. |
protected void | insertUpdate(DefaultStyledDocument.ElementSpec[] data)
Inserts new content.
|
void | remove(int offs, int len, DefaultDocumentEvent ev)
Removes the content. |
protected void | removeUpdate()
Updates the element structure of the document in response to removal of
content. |
ElementBuffer
for the specified
root
element.
Parameters: root
the root element for this ElementBuffer
DefaultDocumentEvent
to reflect the structural changes.
The bulk work is delegated to {@link #changeUpdate()}.
Parameters: offset
the start index of the interval to be changed length
the length of the interval to be changed ev
the DefaultDocumentEvent
describing the change
clonee
with the specified parent as new parent.
This method can only clone direct instances of {@link BranchElement}
or {@link LeafElement}.
Parameters: parent the new parent clonee the element to be cloned
Returns: the cloned element with the new parent
ElementBuffer
.
Returns: the root element of this ElementBuffer
Element
in the document at the specified
position. Most of the work is done by {@link #insertUpdate}, after some
fields have been prepared for it.
Parameters: offset the location in the document at which the content is inserted length the length of the inserted content data the element specifications for the content to be inserted ev the document event that is updated to reflect the structural changes
Parameters: data the element specifications for the elements to be inserted
Parameters: offs the offset from which content is remove len the length of the removed content ev the document event that records the changes