public class AlignmentActionProvider<T> extends java.lang.Object
AlignmentContentArea
to manipulate the associated models AlignmentModel
and SelectionModel
.Constructor and Description |
---|
AlignmentActionProvider(AlignmentArea alignmentArea)
Creates a new instance of this class that is associated with the specified view and model.
|
Modifier and Type | Method and Description |
---|---|
boolean |
deleteBackwards()
Removes the currently selected tokens from the underlying
AlignmentModel . |
boolean |
deleteForward()
Removes the currently selected tokens from the underlying
AlignmentModel . |
void |
deleteSelection()
Deletes the currently selected tokens.
|
int |
elongateSequence(java.lang.String sequenceID,
int newLength)
Inserts trailing gaps into a sequence until it has the specified length.
|
AlignmentArea |
getAlignmentArea()
Returns the view this instance is associated with.
|
AlignmentModel<T> |
getModel() |
boolean |
insertToken(T token)
Inserts the specified token at the current cursor position specified by
selection . |
boolean |
overwriteWithToken(T token)
Overwrites the currently selected token(s) in each selected sequence with the specified token.
|
public AlignmentActionProvider(AlignmentArea alignmentArea)
Note that the token type of the AlignmentModel
associated with view
and the token type
T
if this instance must match.
view
- the alignment content area from which the user operations will be triggered (The sequence data
provider, the selection model and the sequence order this view provides will be used for all operations.)public AlignmentArea getAlignmentArea()
public AlignmentModel<T> getModel()
public void deleteSelection()
This method is called internally by deleteBackwards()
and deleteForward()
if the selection
is not empty.
public boolean deleteForward()
AlignmentModel
. If no tokens
are selected the token right of the cursor is removed from each sequence the cursor spans to.
Most users would probably expect this operation to be executed when the delete button is pressed.
Note that calling this method will have no effect if the underlying AlignmentModel
is
not writable.
true
if the underlying data source was changed as a result of this operation,
false
otherwisepublic boolean deleteBackwards()
AlignmentModel
. If no tokens
are selected the token left of the cursor is removed from each sequence the cursor spans to.
Most users would probably expect this operation to be executed when the backspace button is pressed.
Note that calling this method will have no effect if the underlying AlignmentModel
is
not writable.
true
if the underlying data source was changed as a result of this operation,
false
otherwisepublic int elongateSequence(java.lang.String sequenceID, int newLength)
sequenceID
- the ID of the sequence to be elongatednewLength
- the new length the sequence shall havepublic boolean insertToken(T token)
selection
. If the cursor
spans over multiple rows the token is inserted into each row. If other tokens are currently selected the
specified token will be inserted as often as the length of the selection.
Note that no deep copy of the specified token will be used, if it is inserted into several rows. Generally
implementations of AlignmentModel
do not necessarily store one object per position in a sequence,
but equal objects can also be mapped to the token set to save memory.
Note that calling this method will have no effect if the underlying AlignmentModel
is
not writable.
token
- the token to be insertedtrue
if the underlying data source was changed as a result of this operation,
false
otherwisepublic boolean overwriteWithToken(T token)
If more than one token in each sequence is selected, the first one will be replaced by
AlignmentModel#setTokenAt(int, int, Object)
and the other will be deleted using
AlignmentModel#removeTokensAt(int, int, int)
.
Note that calling this method will have no effect if the underlying AlignmentModel
is
not writable.
token
- the new token to replace the other(s)true
if the underlying data source was changed as a result of this operation,
false
otherwise