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

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

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

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

java.lang.Object
  extended by org.netbeans.lib.editor.util.swing.PositionRegion
Direct Known Subclasses:
MutablePositionRegion

public class PositionRegion
extends Object

A pair of positions delimiting a text region in a swing document.
At all times it should be satisfied that getStartOffset() <= getEndOffset().

Since:
1.6

Constructor Summary
PositionRegion(Document doc, int startOffset, int endOffset)
          Construct new position region based on the knowledge of the document and starting and ending offset.
PositionRegion(Position startPosition, Position endPosition)
          Construct new position region.
 
Method Summary
static Position createFixedPosition(int offset)
          Create a fixed position instance that just wraps a given integer offset.
static Comparator<PositionRegion> getComparator()
          Get comparator for position regions comparing start offsets of the two given regions.
 int getEndOffset()
          Get ending offset of this region.
 Position getEndPosition()
          Get ending position of this region.
 int getLength()
          Get length of this region.
 int getStartOffset()
          Get starting offset of this region.
 Position getStartPosition()
          Get starting position of this region.
static boolean isRegionsSorted(List<PositionRegion> positionRegionList)
          Check whether a list of position regions is sorted according the start offsets of the regions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PositionRegion

public PositionRegion(Position startPosition,
                      Position endPosition)
Construct new position region.

Parameters:
startPosition - non-null start position of the region <= end position.
endPosition - non-null end position of the region >= start position.

PositionRegion

public PositionRegion(Document doc,
                      int startOffset,
                      int endOffset)
               throws BadLocationException
Construct new position region based on the knowledge of the document and starting and ending offset.

Throws:
BadLocationException
Method Detail

getComparator

public static final Comparator<PositionRegion> getComparator()
Get comparator for position regions comparing start offsets of the two given regions.

Returns:
non-null comparator comparing the start offsets of the two given regions.

createFixedPosition

public static Position createFixedPosition(int offset)
Create a fixed position instance that just wraps a given integer offset.
This may be useful for situations where a position needs to be used but the document is not available yet. Once the document becomes available the regular position instance (over an existing document) may be used instead.

Parameters:
offset - >=0 offset at which the position should be created.
Since:
1.10

isRegionsSorted

public static boolean isRegionsSorted(List<PositionRegion> positionRegionList)
Check whether a list of position regions is sorted according the start offsets of the regions.

Parameters:
positionRegionList - list of the regions to be compared.
Returns:
true if the regions are sorted according to the starting offset of the given regions or false otherwise.

getStartOffset

public final int getStartOffset()
Get starting offset of this region.

Returns:
>=0 starting offset of this region.

getStartPosition

public final Position getStartPosition()
Get starting position of this region.

Returns:
non-null starting position of this region.

getEndOffset

public final int getEndOffset()
Get ending offset of this region.

Returns:
>=0 ending offset of this region.

getEndPosition

public final Position getEndPosition()
Get ending position of this region.

Returns:
non-null ending position of this region.

getLength

public final int getLength()
Get length of this region.

Returns:
>=0 length of this region computed as getEndOffset() - getStartOffset().

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

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