public class OneDimensionalSelection extends java.lang.Object
Warning: This class is meant only for internal use in LibrAlign and its API is not guaranteed to remain stable within on major version number.
Modifier and Type | Field and Description |
---|---|
static int |
NO_SELECTION |
Constructor and Description |
---|
OneDimensionalSelection(SelectionModel owner,
SelectionDimension dimension) |
Modifier and Type | Method and Description |
---|---|
void |
adoptFromOther(OneDimensionalSelection other) |
void |
clear()
Clears this selection.
|
void |
extendSelectionRelatively(int posCount)
Extends the selection to the left (or to the bottom).
|
void |
extendSelectionTo(int pos)
Extends the selection in either direction so that the specified column (or row) and all
previously selected columns (or rows) are included.
|
SelectionDimension |
getDimension()
Determines of this selection represent columns or rows.
|
int |
getFirstPos()
Returns the first column (or row) that is contained in the selection.
|
int |
getLastPos()
Returns the last column (or row) that is contained in the selection.
|
int |
getLength() |
SelectionModel |
getOwner() |
int |
getStartPos()
Returns the position where the current selection process started.
|
boolean |
isEmpty()
Checks if any columns or row (depending on
getDimension() ) is selected. |
boolean |
isSelected(int pos)
Checks if the specified column (or row) is included in this selection.
|
void |
moveSelection(int count)
Moves the selection by the specified number of columns (or rows).
|
void |
selectAll()
Selects all columns or rows (depending on
getDimension() ). |
void |
setFirstPos(int firstPos)
Sets the first column (or row) of the selection.
|
void |
setLastPos(int lastPos)
Sets the last column (or row) of the selection.
|
void |
setNewSelection(int pos)
Deletes the current selection and selects the column (or row) at the specified position.
|
void |
setSelectionEnd(int pos) |
void |
setStartPos(int startPos) |
public static final int NO_SELECTION
public OneDimensionalSelection(SelectionModel owner, SelectionDimension dimension)
public SelectionModel getOwner()
public SelectionDimension getDimension()
SelectionDimension.COLUMN
or SelectionDimension.ROW
public int getFirstPos()
NO_SELECTION
if the selection is emptypublic int getLastPos()
NO_SELECTION
if the selection is emptypublic int getStartPos()
setSelectionEnd(int)
.NO_SELECTION
if no selection process is ongoingpublic void setStartPos(int startPos)
public int getLength()
public void setNewSelection(int pos)
If a value below 0 (except NO_SELECTION
) or greater than the
length (or height) of the alignment is specified, the first or last column (or row) is selected.
pos
- the index of the column (or row) to be selectedjava.lang.IllegalArgumentException
- if NO_SELECTION
is specified (Use clear()
instead.)public void setFirstPos(int firstPos)
If the specified position is greater than getLastPos()
, both values are swapped.
firstPos
- the index of the new selection startpublic void setLastPos(int lastPos)
If the specified position is lower than getFirstPos()
, both values are swapped.
If getFirstPos()
was not set, it is set to the specified value as well.
firstPos
- the index of the new selection startpublic void adoptFromOther(OneDimensionalSelection other)
public boolean isSelected(int pos)
pos
- the index of the column or row to be checkedtrue
if the specified column or row is included, false
otherwisepublic void setSelectionEnd(int pos)
public void moveSelection(int count)
This method may be useful move through the alignment with the keyboard if no cursor independent from the selection is used.
count
- the number of columns (or rows) to move the selection (Can be
positive or negative)public void extendSelectionTo(int pos)
setNewSelection(int)
.pos
- the index of the column or row that shall additionally be included in this selectionpublic void extendSelectionRelatively(int posCount)
posCount
- the number of columns to be added to the selection.public void selectAll()
getDimension()
).public boolean isEmpty()
getDimension()
) is selected.true
if no column or row is selected, false
otherwise.public void clear()