Home » openjdk-7 » javax » swing » text » [javadoc | source]
javax.swing.text
public class: DefaultStyledDocument.ElementBuffer [javadoc | source]
java.lang.Object
   javax.swing.text.DefaultStyledDocument$ElementBuffer

All Implemented Interfaces:
    java$io$Serializable

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 java.beans.XMLEncoder .
Nested Class Summary:
class  ElementBuffer.ElemChanges   
Field Summary
 Element root     
transient  int pos     
transient  int offset     
transient  int length     
transient  int endOffset     
transient  Vector<ElemChanges> changes     
transient  Stack<ElemChanges> path     
transient  boolean insertOp     
transient  boolean recreateLeafs     
transient  ElemChanges[] insertPath    For insert, path to inserted elements. 
transient  boolean createdFracture    Only for insert, set to true when the fracture has been created. 
transient  Element fracturedParent    Parent that contains the fractured child. 
transient  Element fracturedChild    Fractured child. 
transient  boolean offsetLastIndex    Used to indicate when fracturing that the last leaf should be skipped. 
transient  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. 
Constructor:
 public ElementBuffer(Element root) 
    Creates a new ElementBuffer.
    Parameters:
    root - the root element
    since: 1.4 -
Method from javax.swing.text.DefaultStyledDocument$ElementBuffer Summary:
advance,   beginEdits,   canJoin,   change,   changeUpdate,   clone,   cloneAsNecessary,   create,   endEdits,   fracture,   fractureDeepestLeaf,   fractureFrom,   getRootElement,   insert,   insertElement,   insertFirstContent,   insertUpdate,   join,   pop,   push,   push,   recreateFracturedElement,   remove,   removeElements,   removeUpdate,   split
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.text.DefaultStyledDocument$ElementBuffer Detail:
  void advance(int n) 
    move the current offset forward by n.
  void beginEdits(int offset,
    int length) 
    Initialize the buffer
 boolean canJoin(Element e0,
    Element e1) 
    Can the two given elements be coelesced together into one element?
 public  void change(int offset,
    int length,
    DefaultDocumentEvent de) 
    Changes content.
 protected  void changeUpdate() 
    Updates the element structure in response to a change in the document.
 public Element clone(Element parent,
    Element clonee) 
    Creates a copy of this element, with a different parent.
 Element cloneAsNecessary(Element parent,
    Element clonee,
    int rmOffs0,
    int rmOffs1) 
    Creates a copy of this element, with a different parent. Children of this element included in the removal range will be discarded.
  void create(int length,
    ElementSpec[] data,
    DefaultDocumentEvent de) 
  void endEdits(DefaultDocumentEvent de) 
    Creates the UndoableEdit record for the edits made in the buffer.
  void fracture(int depth) 
    Determines if a fracture needs to be performed. A fracture can be thought of as moving the right part of a tree to a new location, where the right part is determined by what has been inserted. 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 fractureDeepestLeaf(ElementSpec[] specs) 
    Splits the bottommost leaf in path. This is called from insert when the first element is NOT content.
  void fractureFrom(ElemChanges[] changed,
    int startIndex,
    int endFractureIndex) 
    Recreates the elements to the right of the insertion point. This starts at 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.
 public Element getRootElement() 
    Gets the root element.
 public  void insert(int offset,
    int length,
    ElementSpec[] data,
    DefaultDocumentEvent de) 
    Inserts new content.
  void insertElement(ElementSpec es) 
  void insertFirstContent(ElementSpec[] specs) 
    Inserts the first content. This needs to be separate to handle joining.
 protected  void insertUpdate(ElementSpec[] data) 
    Inserts an update into the document.
 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.
  void pop() 
  void push(Element e,
    int index) 
  void push(Element e,
    int index,
    boolean isFracture) 
    Pushes a new element onto the stack that represents the current path.
 Element recreateFracturedElement(Element parent,
    Element toDuplicate) 
    Recreates 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.
 public  void remove(int offset,
    int length,
    DefaultDocumentEvent de) 
    Removes content.
 boolean removeElements(Element elem,
    int rmOffs0,
    int rmOffs1) 
    Remove the elements from elem in range rmOffs0, rmOffs1. This uses canJoin and join to handle joining the endpoints of the insertion.
 protected  void removeUpdate() 
    Updates the element structure in response to a removal from the associated sequence in the document. Any elements consumed by the span of the removal are removed.
 boolean split(int offs,
    int len)