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 and Description |
---|
DefaultStyledDocument.ElementBuffer(Element root)
Creates a new
ElementBuffer for the specified
root element. |
Modifier and Type | Method and Description |
---|---|
void |
change(int offset,
int length,
AbstractDocument.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
change(int, int, javax.swing.text.AbstractDocument.DefaultDocumentEvent) . |
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,
AbstractDocument.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,
AbstractDocument.DefaultDocumentEvent ev)
Removes the content.
|
protected void |
removeUpdate()
Updates the element structure of the document in response to removal of
content.
|
public DefaultStyledDocument.ElementBuffer(Element root)
ElementBuffer
for the specified
root
element.root
- the root element for this ElementBuffer
public Element getRootElement()
ElementBuffer
.ElementBuffer
public void remove(int offs, int len, AbstractDocument.DefaultDocumentEvent ev)
removeUpdate()
.offs
- the offset from which content is removelen
- the length of the removed contentev
- the document event that records the changesprotected void removeUpdate()
Element
s from the document
structure.protected void changeUpdate()
change(int, int, javax.swing.text.AbstractDocument.DefaultDocumentEvent)
. The elements at the
interval boundaries are split up (if necessary) so that the interval
boundaries are located at element boundaries.public void change(int offset, int length, AbstractDocument.DefaultDocumentEvent ev)
DefaultDocumentEvent
to reflect the structural changes.
The bulk work is delegated to changeUpdate()
.offset
- the start index of the interval to be changedlength
- the length of the interval to be changedev
- the DefaultDocumentEvent
describing the changepublic Element clone(Element parent, Element clonee)
clonee
with the specified parent as new parent.
This method can only clone direct instances of BranchElement
or LeafElement
.parent
- the new parentclonee
- the element to be clonedpublic void insert(int offset, int length, DefaultStyledDocument.ElementSpec[] data, AbstractDocument.DefaultDocumentEvent ev)
Element
in the document at the specified
position. Most of the work is done by insertUpdate(javax.swing.text.DefaultStyledDocument.ElementSpec[])
, after some
fields have been prepared for it.offset
- the location in the document at which the content is insertedlength
- the length of the inserted contentdata
- the element specifications for the content to be insertedev
- the document event that is updated to reflect the structural
changesprotected void insertUpdate(DefaultStyledDocument.ElementSpec[] data)
data
- the element specifications for the elements to be inserted