|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.text.DefaultStyledDocument.ElementBuffer
Class to manage changes to the element hierarchy.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans
package.
Please see XMLEncoder
.
Nested Class Summary | |
(package private) class |
DefaultStyledDocument.ElementBuffer.ElemChanges
|
Field Summary | |
(package private) Vector |
changes
|
(package private) boolean |
createdFracture
Only for insert, set to true when the fracture has been created. |
(package private) int |
endOffset
|
(package private) Element |
fracturedChild
Fractured child. |
(package private) Element |
fracturedParent
Parent that contains the fractured child. |
(package private) boolean |
insertOp
|
(package private) DefaultStyledDocument.ElementBuffer.ElemChanges[] |
insertPath
For insert, path to inserted elements. |
(package private) int |
length
|
(package private) int |
offset
|
(package private) boolean |
offsetLastIndex
Used to indicate when fracturing that the last leaf should be skipped. |
(package private) boolean |
offsetLastIndexOnReplace
Used to indicate that the parent of the deepest leaf should offset the index by 1 when adding/removing elements in an insert. |
(package private) Stack |
path
|
(package private) int |
pos
|
(package private) boolean |
recreateLeafs
|
(package private) Element |
root
|
Constructor Summary | |
DefaultStyledDocument.ElementBuffer(Element root)
Creates a new ElementBuffer. |
Method Summary | |
(package private) void |
advance(int n)
move the current offset forward by n. |
(package private) void |
beginEdits(int offset,
int length)
Initialize the buffer |
(package private) boolean |
canJoin(Element e0,
Element e1)
Can the two given elements be coelesced together into one element? |
void |
change(int offset,
int length,
AbstractDocument.DefaultDocumentEvent de)
Changes content. |
protected void |
changeUpdate()
Updates the element structure in response to a change in the document. |
Element |
clone(Element parent,
Element clonee)
Creates a copy of this element, with a different parent. |
(package private) Element |
cloneAsNecessary(Element parent,
Element clonee,
int rmOffs0,
int rmOffs1)
Creates a copy of this element, with a different parent. |
(package private) void |
create(int length,
DefaultStyledDocument.ElementSpec[] data,
AbstractDocument.DefaultDocumentEvent de)
|
(package private) void |
endEdits(AbstractDocument.DefaultDocumentEvent de)
Creates the UndoableEdit record for the edits made in the buffer. |
(package private) void |
fracture(int depth)
Determines if a fracture needs to be performed. |
(package private) void |
fractureDeepestLeaf(DefaultStyledDocument.ElementSpec[] specs)
Splits the bottommost leaf in path .
|
(package private) void |
fractureFrom(DefaultStyledDocument.ElementBuffer.ElemChanges[] changed,
int startIndex,
int endFractureIndex)
Recreates the elements to the right of the insertion point. |
Element |
getRootElement()
Gets the root element. |
void |
insert(int offset,
int length,
DefaultStyledDocument.ElementSpec[] data,
AbstractDocument.DefaultDocumentEvent de)
Inserts new content. |
(package private) void |
insertElement(DefaultStyledDocument.ElementSpec es)
|
(package private) void |
insertFirstContent(DefaultStyledDocument.ElementSpec[] specs)
Inserts the first content. |
protected void |
insertUpdate(DefaultStyledDocument.ElementSpec[] data)
Inserts an update into the document. |
(package private) Element |
join(Element p,
Element left,
Element right,
int rmOffs0,
int rmOffs1)
Joins the two elements carving out a hole for the given removed range. |
(package private) void |
pop()
|
(package private) void |
push(Element e,
int index)
|
(package private) void |
push(Element e,
int index,
boolean isFracture)
Pushes a new element onto the stack that represents the current path. |
(package private) Element |
recreateFracturedElement(Element parent,
Element toDuplicate)
Recreates toDuplicate . |
void |
remove(int offset,
int length,
AbstractDocument.DefaultDocumentEvent de)
Removes content. |
(package private) boolean |
removeElements(Element elem,
int rmOffs0,
int rmOffs1)
Remove the elements from elem in range
rmOffs0 , rmOffs1 . |
protected void |
removeUpdate()
Updates the element structure in response to a removal from the associated sequence in the document. |
(package private) boolean |
split(int offs,
int len)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
Element root
transient int pos
transient int offset
transient int length
transient int endOffset
transient Vector changes
transient Stack path
transient boolean insertOp
transient boolean recreateLeafs
transient DefaultStyledDocument.ElementBuffer.ElemChanges[] insertPath
transient boolean createdFracture
transient Element fracturedParent
transient Element fracturedChild
transient boolean offsetLastIndex
transient boolean offsetLastIndexOnReplace
Constructor Detail |
public DefaultStyledDocument.ElementBuffer(Element root)
root
- the root elementMethod Detail |
public Element getRootElement()
public void insert(int offset, int length, DefaultStyledDocument.ElementSpec[] data, AbstractDocument.DefaultDocumentEvent de)
offset
- the starting offset >= 0length
- the length >= 0data
- the data to insertde
- the event capturing this editvoid create(int length, DefaultStyledDocument.ElementSpec[] data, AbstractDocument.DefaultDocumentEvent de)
public void remove(int offset, int length, AbstractDocument.DefaultDocumentEvent de)
offset
- the starting offset >= 0length
- the length >= 0de
- the event capturing this editpublic void change(int offset, int length, AbstractDocument.DefaultDocumentEvent de)
offset
- the starting offset >= 0length
- the length >= 0de
- the event capturing this editprotected void insertUpdate(DefaultStyledDocument.ElementSpec[] data)
data
- the elements to insertprotected void removeUpdate()
protected void changeUpdate()
boolean split(int offs, int len)
void endEdits(AbstractDocument.DefaultDocumentEvent de)
void beginEdits(int offset, int length)
void push(Element e, int index, boolean isFracture)
isFracture
- true if pushing on an element that was created
as the result of a fracture.void push(Element e, int index)
void pop()
void advance(int n)
void insertElement(DefaultStyledDocument.ElementSpec es)
boolean removeElements(Element elem, int rmOffs0, int rmOffs1)
elem
in range
rmOffs0
, rmOffs1
. This uses
canJoin
and join
to handle joining
the endpoints of the insertion.
boolean canJoin(Element e0, Element e1)
Element join(Element p, Element left, Element right, int rmOffs0, int rmOffs1)
public Element clone(Element parent, Element clonee)
parent
- the parent elementclonee
- the element to be cloned
Element cloneAsNecessary(Element parent, Element clonee, int rmOffs0, int rmOffs1)
void fracture(int depth)
depth
is used to indicate a
JoinToFracture is needed to an element at a depth
of depth
. Where the root is 0, 1 is the children
of the root...
This will invoke fractureFrom
if it is determined
a fracture needs to happen.
void fractureFrom(DefaultStyledDocument.ElementBuffer.ElemChanges[] changed, int startIndex, int endFractureIndex)
startIndex
in changed
,
and calls duplicate to duplicate existing elements.
This will also duplicate the elements along the insertion
point, until a depth of endFractureIndex
is
reached, at which point only the elements to the right of
the insertion point are duplicated.
Element recreateFracturedElement(Element parent, Element toDuplicate)
toDuplicate
. This is called when an
element needs to be created as the result of an insertion. This
will recurse and create all the children. This is similiar to
clone
, but deteremines the offsets differently.
void fractureDeepestLeaf(DefaultStyledDocument.ElementSpec[] specs)
path
.
This is called from insert when the first element is NOT content.
void insertFirstContent(DefaultStyledDocument.ElementSpec[] specs)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |