站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

GapBranchElement (Editor Utilities) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.editor.util/1 1.17

org.netbeans.lib.editor.util.swing
Class GapBranchElement

java.lang.Object
  extended by org.netbeans.lib.editor.util.swing.GapBranchElement
All Implemented Interfaces:
Element

public abstract class GapBranchElement
extends Object
implements Element

Branch element that uses gap list to maintain its child elements.


Nested Class Summary
 class GapBranchElement.Edit
           
 class GapBranchElement.LastIndex
          Extension of GapBranchElement that overrides GapBranchElement.LastIndex.getElementIndex(int) which remembers the last returned element index.
 
Field Summary
protected static Element[] EMPTY_ELEMENT_ARRAY
           
 
Constructor Summary
GapBranchElement()
           
 
Method Summary
 void copyElements(int srcBegin, int srcEnd, Element[] dst, int dstBegin)
           
 Element getElement(int index)
           
 int getElementCount()
           
 int getElementIndex(int offset)
          Gets the child element index closest to the given offset.
 boolean isLeaf()
           
protected  void replace(int index, int removeCount, Element[] addedElems)
           
 String toString()
          Get info about DocMarks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.swing.text.Element
getAttributes, getDocument, getEndOffset, getName, getParentElement, getStartOffset
 

Field Detail

EMPTY_ELEMENT_ARRAY

protected static final Element[] EMPTY_ELEMENT_ARRAY
Constructor Detail

GapBranchElement

public GapBranchElement()
Method Detail

getElementCount

public int getElementCount()
Specified by:
getElementCount in interface Element

getElement

public Element getElement(int index)
Specified by:
getElement in interface Element

copyElements

public void copyElements(int srcBegin,
                         int srcEnd,
                         Element[] dst,
                         int dstBegin)

getElementIndex

public int getElementIndex(int offset)
Gets the child element index closest to the given offset. The offset is specified relative to the beginning of the document. Returns -1 if the Element is a leaf, otherwise returns the index of the Element that best represents the given location. Returns 0 if the location is less than the start offset. Returns getElementCount() - 1 if the location is greater than or equal to the end offset.

This implementation is in sync with the original Element.getElementIndex() specification but it differs from AbstractDocument.BranchElement.getElementIndex() which returns 0 in case it does not have any children.
This implementation returns -1 in that case because in fact the element act as a leaf element in such case.
Nonetheless there should be no difference in functionality if this implementation is used for line elements because there is always at least one line element even for empty doc because of the extra '\n' after the end of the AbstractDocument-based implementations.

Specified by:
getElementIndex in interface Element
Parameters:
offset - the specified offset >= 0
Returns:
the element index >= 0

isLeaf

public boolean isLeaf()
Specified by:
isLeaf in interface Element

replace

protected void replace(int index,
                       int removeCount,
                       Element[] addedElems)

toString

public String toString()
Get info about DocMarks.

Overrides:
toString in class Object

org.netbeans.modules.editor.util/1 1.17

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.