当前页面:
在线文档首页 >
NetBeans API Javadoc (Current Development Version)
GapBranchElement (Editor Utilities) - NetBeans API Javadoc (Current Development Version)
org.netbeans.lib.editor.util.swing
Class GapBranchElement
java.lang.Object
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.
EMPTY_ELEMENT_ARRAY
protected static final Element[] EMPTY_ELEMENT_ARRAY
GapBranchElement
public GapBranchElement()
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