T
- the type of sequence elements (tokens) used in the sequences of an AlignmentArea
public interface TokenSet<T> extends java.util.Set<T>, java.lang.Cloneable
AlignmentArea
and are provided by an implementation of
AlignmentModel
.
Implementing classes define a set of valid tokens that may be contained in an alignment and define an optional keyboard shortcut a user of LibrAlign can use to insert the according token into an alignment.
Note that implementations may also represent a set of continuous values. In this case the implementation
should return true
for #isContinuous()
, null
for Set.iterator()
,
Integer.MAX_VALUE
for Set.size()
and false
for Set.isEmpty()
. The optional add
and remove operations may throw UnsupportedOperationException
s.
Modifier and Type | Method and Description |
---|---|
TokenSet<T> |
clone()
Returns a deep copy of this instance.
|
java.lang.String |
descriptionByToken(T token)
An description of the specified token (e.g.
|
T |
getGapToken()
Returns the default object that represents a gap in this token set.
|
CharacterSymbolMeaning |
getMeaning(T token)
Returns the meaning of the specified symbol.
|
T |
getMissingInformationToken()
Returns the default object that represents an unknown position in this token set.
|
CharacterSymbolType |
getSymbolType(T token)
Returns the type of the specified token (symbol).
|
CharacterStateSetType |
getType()
Determines the type of tokens that are defined by this instance.
|
boolean |
isGapToken(T token)
Tests if the specified token represents a gap.
|
boolean |
isMissingInformationToken(T token)
Tests if the specified token represents an unknown position (usually '?').
|
boolean |
isSpaceForGap()
Determines whether
tokenByKeyStroke(KeyStroke) shall return the gap token, if the space bar is
pressed, even if that key stroke is not associated with that token. |
int |
maxRepresentationLength()
Calculates the maximal length of a representation returned by
representationByToken(Object)
of all tokens contained in this set. |
java.lang.String |
representationByToken(T token)
Returns the representation string of the specified token that shall be displayed in an
AlignmentArea or written into an alignment file. |
boolean |
representationLengthEqual()
Checks if all representation strings returned by
representationByToken(Object)
have the same length. |
void |
setSpaceForGap(boolean spaceForGap)
Allows to specify whether
tokenByKeyStroke(KeyStroke) shall return the gap token, if the space
bar is pressed, even if that key stroke is not associated with that token. |
T |
tokenByKeyStroke(javax.swing.KeyStroke key)
Returns the token from this set that is associated with the specified key stroke.
|
T |
tokenByRepresentation(java.lang.String representation)
Returns the token associated with the specified string representation used to display the token in
an
AlignmentArea or an alignment file. |
T tokenByKeyStroke(javax.swing.KeyStroke key)
AlignmentArea
.
Note that the key character is only used by AlignmentArea
if it does not collide with a default
keyboard action. (Usually the key character can be any lower or upper case letter or digit.)
key
- the key stroke (key code and shift mask) the user can press to insert the returned token
into an AlignmentArea
null
if none is definedjava.lang.String representationByToken(T token)
AlignmentArea
or written into an alignment file.
Note that some CharSequenceAdapter
s and StringAdapter
s only use the first character
of the returned string to represent a token.
token
- the token associated with the representationT tokenByRepresentation(java.lang.String representation)
AlignmentArea
or an alignment file.representation
- the string representation of the tokennull
if none is definedint maxRepresentationLength()
representationByToken(Object)
of all tokens contained in this set.boolean representationLengthEqual()
representationByToken(Object)
have the same length.true
if all lengths are equal, false
otherwisejava.lang.String descriptionByToken(T token)
token
- the token that shall be describedCharacterStateSetType getType()
boolean isGapToken(T token)
Note that it's legal to have multiple tokens to be considered as gaps, but one of them must be defined as the default gap tokens. When alignments are written to files (e.g. using JPhyloIO), some formats may accept only one of these tokens as a gap and the others may be represented as additional character states.
token
- the token to be testedtrue
if the specified token is recognized as a gap, false
otherwise.T getGapToken()
boolean isSpaceForGap()
tokenByKeyStroke(KeyStroke)
shall return the gap token, if the space bar is
pressed, even if that key stroke is not associated with that token.true
if the gap token shall always be returned, false
otherwise.void setSpaceForGap(boolean spaceForGap)
tokenByKeyStroke(KeyStroke)
shall return the gap token, if the space
bar is pressed, even if that key stroke is not associated with that token.spaceForGap
- Specify true
here, if the gap token shall always be returned, false
otherwise.boolean isMissingInformationToken(T token)
Note that it's legal to have multiple tokens to be considered as unknown symbols, but one of them must be defined as the default. When alignments are written to files, some formats may accept only one
token
- the token to be testedtrue
if the specified token is recognized as an unknown position, false
otherwise.T getMissingInformationToken()
CharacterSymbolMeaning getMeaning(T token)
token
- the token to determine the meaning fromCharacterSymbolType getSymbolType(T token)
token
- the symbol to be tested