com.bluemarsh.jswat.view
Class SelectionDrawLayer

java.lang.Object
  |
  +--com.bluemarsh.jswat.view.BasicDrawLayer
        |
        +--com.bluemarsh.jswat.view.HighlightDrawLayer
              |
              +--com.bluemarsh.jswat.view.SelectionDrawLayer
All Implemented Interfaces:
DrawLayer

public class SelectionDrawLayer
extends HighlightDrawLayer

SelectionDrawLayer is responsible for showing the current text selection in the text area. It also keeps track of the current text selection.

Author:
Nathan Fiedler

Field Summary
protected static java.awt.Color selectionColor
          Color used to indicate selection.
 
Fields inherited from class com.bluemarsh.jswat.view.HighlightDrawLayer
highlightColor, highlightEnd, highlightStart
 
Fields inherited from class com.bluemarsh.jswat.view.BasicDrawLayer
active, extendsEOL
 
Fields inherited from interface com.bluemarsh.jswat.view.DrawLayer
PRIORITY_COLORIZER, PRIORITY_HIGHEST, PRIORITY_LOWEST, PRIORITY_SELECTION, PRIORITY_STEPPING
 
Constructor Summary
SelectionDrawLayer()
          Constructs a SelectionDrawLayer using the default color.
 
Method Summary
 int getSelectionEnd()
          Returns the selected text's end position.
 int getSelectionStart()
          Returns the selected text's start position.
 void setSelection(int start, int end)
          Selects the text found between the specified start and end locations.
 
Methods inherited from class com.bluemarsh.jswat.view.HighlightDrawLayer
setHighlight, updateContext
 
Methods inherited from class com.bluemarsh.jswat.view.BasicDrawLayer
extendsEOL, isActive, setExtendsEOL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

selectionColor

protected static java.awt.Color selectionColor
Color used to indicate selection.
Constructor Detail

SelectionDrawLayer

public SelectionDrawLayer()
Constructs a SelectionDrawLayer using the default color.
Method Detail

getSelectionEnd

public int getSelectionEnd()
Returns the selected text's end position. Return 0 if the document is empty, or the value of dot if there is no selection.
Returns:
the end position >= 0

getSelectionStart

public int getSelectionStart()
Returns the selected text's start position. Return 0 if the document is empty, or the value of dot if there is no selection.
Returns:
the start position >= 0

setSelection

public void setSelection(int start,
                         int end)
Selects the text found between the specified start and end locations. If the start location is after the end location, the values will be swapped before the selection is made.
Parameters:
start - start offset of the selection.
end - end offset of the selection.