edu.princeton.swing.text
Class HighlightedDocument.PositionTriplet

java.lang.Object
  extended by edu.princeton.swing.text.HighlightedDocument.PositionTriplet
Enclosing class:
HighlightedDocument

public class HighlightedDocument.PositionTriplet
extends Object

PositionTriplet maintains three positions which permits efficient synchronous changes.


Field Summary
protected  HighlightedDocument.Position caretPosition
           
static int NO_CHANGE
          The value to pass to set so that the specified position's offset will not change.
protected  HighlightedDocument.Position selectionDot
           
protected  HighlightedDocument.Position selectionMark
           
 
Constructor Summary
protected HighlightedDocument.PositionTriplet(HighlightedDocument.Position selectionDot, HighlightedDocument.Position selectionMark, HighlightedDocument.Position caretPosition)
          Creates a new PositionTriplet.
 
Method Summary
 int getCaretPositionOffset()
          Returns the offset of the caretPosition.
 int getSelectionDotOffset()
          Returns the offset of the selectionDot.
 int getSelectionEndOffset()
          Returns the greater of the offsets of the selectionDot and selectionMark.
 int getSelectionMarkOffset()
          Returns the offset of the selectionMark.
 int getSelectionStartOffset()
          Returns the lesser of the offsets of the selectionDot and selectionMark.
 void set(int selectionDotOffset, int selectionMarkOffset, int caretPositionOffset)
          Moves the offsets of the triplets to the valid position nearest to the specified offset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_CHANGE

public static final int NO_CHANGE
The value to pass to set so that the specified position's offset will not change.

See Also:
Constant Field Values

selectionDot

protected HighlightedDocument.Position selectionDot

selectionMark

protected HighlightedDocument.Position selectionMark

caretPosition

protected HighlightedDocument.Position caretPosition
Constructor Detail

HighlightedDocument.PositionTriplet

protected HighlightedDocument.PositionTriplet(HighlightedDocument.Position selectionDot,
                                              HighlightedDocument.Position selectionMark,
                                              HighlightedDocument.Position caretPosition)
Creates a new PositionTriplet.

Method Detail

set

public void set(int selectionDotOffset,
                int selectionMarkOffset,
                int caretPositionOffset)
Moves the offsets of the triplets to the valid position nearest to the specified offset. Pass the NO_CHANGE value to leave an offset as it is.

Parameters:
selectionDotOffset - The new offset for the selectionDot.
selectionMarkOffset - The new offset for the selectionMark.
caretPositionOffset - The new offset for the caretPosition.

getSelectionDotOffset

public int getSelectionDotOffset()
Returns the offset of the selectionDot.

Returns:
The offset of the selectionDot.

getSelectionMarkOffset

public int getSelectionMarkOffset()
Returns the offset of the selectionMark.

Returns:
The offset of the selectionMark.

getCaretPositionOffset

public int getCaretPositionOffset()
Returns the offset of the caretPosition.

Returns:
The offset of the caretPosition.

getSelectionStartOffset

public int getSelectionStartOffset()
Returns the lesser of the offsets of the selectionDot and selectionMark.

Returns:
The lesser of the offsets of the selectionDot and selectionMark.

getSelectionEndOffset

public int getSelectionEndOffset()
Returns the greater of the offsets of the selectionDot and selectionMark.

Returns:
The greater of the offsets of the selectionDot and selectionMark.