public class AlignmentArea extends TICComponent implements AlignmentModelChangeListener, DataAreaModelListener
AlignmentArea
is one of the major GUI components in LibrAlign. It acts as a view in the model view controller
paradigm and works closely together with an instance of AlignmentModel
which provides the data to be displayed.
It can be used as stand-alone components are can be contained in a MultipleAlignmentsContainer
, which would be
returned by getContainer()
in this case. Instances of this class are TICComponent
s. To use this class
in a GUI application, a toolkit specific version of it can be created using SwingComponentFactory
or
SWTComponentFactory
from TIC. See the
LibrAlign documentation for details.
AlignmentArea
has the following key properties:
getSequenceOrder()
determines the order in which sequences are displayed.getPaintSettings()
determines the way the contents are displayed.getEditSettings()
determines if and how a user can edit the contents of this area.getActionProvider()
provides the business logic for manipulating the contents of the associated
model in response to user inputs depending on the current selection.getSelection()
determines the cells of the alignment that are currently selected and the alignment
cursor position.
The implementation of AlignmentArea
is distributed across getContentArea()
which displays the
sequences and data areas and getLabelArea()
which displays there labels (on the left).
MultipleAlignmentsContainer
,
AlignmentContentArea
,
AlignmentLabelArea
,
AlignmentModel
Modifier and Type | Field and Description |
---|---|
static int |
DIVIDER_WIDTH
Defines the width of the divider of the GUI components for the head, content, and bottom area.
|
static int |
MIN_PART_AREA_HEIGHT |
Constructor and Description |
---|
AlignmentArea()
Creates a new instance of this class that shall not part of a
MultipleAlignmentsContainer . |
AlignmentArea(MultipleAlignmentsContainer container)
Creates a new instance of this class to be inserted into a
MultipleAlignmentsContainer . |
Modifier and Type | Method and Description |
---|---|
<T,U> void |
afterProviderChanged(AlignmentModel<T> previous,
AlignmentModel<U> current)
Called if this listener was moved to another instance of
AlignmentModel . |
<T> void |
afterSequenceChange(SequenceChangeEvent<T> e)
Called after a sequence has been inserted, removed or replaced.
|
<T> void |
afterSequenceRenamed(SequenceRenamedEvent<T> e)
Called after a sequence was renamed.
|
<T> void |
afterTokenChange(TokenChangeEvent<T> e)
Called after a single token or a set of tokens has been inserted, removed or replaced.
|
void |
assignSizeToAll()
Calls the
assignSize() method of the contained AlignmentContentArea , AlignmentLabelArea ,
their subcomponents and on this instance. |
void |
dataAreaInsertedRemoved(DataAreaChangeEvent e) |
void |
dataAreaVisibilityChanged(DataAreaChangeEvent e) |
AlignmentActionProvider<Object> |
getActionProvider()
Tool object that implements business logic methods to manipulate the alignment model.
|
AlignmentModel<?> |
getAlignmentModel()
Returns the alignment model providing the data displayed by this area.
|
MultipleAlignmentsContainer |
getContainer()
Returns the container this object is contained in.
|
AlignmentContentArea |
getContentArea()
Returns the alignment content area used internally by this instance.
|
DataAreaModel |
getDataAreas()
Returns the data area model used by this instance containing all data areas attached
to the displayed alignment.
|
EditSettings |
getEditSettings()
Returns the edit setting object used by this instance.
|
int |
getGlobalMaxNeededWidth()
Returns the maximum needed width to display all alignment columns with the according token painters and the
current zoom factor and the space before and after the alignment possibly occupied by data areas calculated
over all alignments contained in the parent
MultipleAlignmentsContainer . |
int |
getGlobalMaxSequenceLength()
If this area is part of an alignment area that is contained in a
MultipleAlignmentsContainer
than this methods calculates the maximum length of all sequences in all alignment areas contained in
this container. |
AlignmentLabelArea |
getLabelArea()
Returns the alignment label area used internally by this instance.
|
double |
getLocalMaximumNeededAlignmentWidth()
Calculates the needed with to label the associated alignment.
|
double |
getLocalMaxNeededWidth() |
PaintSettings |
getPaintSettings()
Returns the paint settings object associated with this instance.
|
SelectionModel |
getSelection()
Returns the selection model used by this instance.
|
SequenceOrder |
getSequenceOrder()
Returns the sequence order object the determines the order in which the sequences of the associated
alignment model are displayed in this instance.
|
Dimension |
getSize()
Returns the size of the underlying toolkit specific component.
|
protected String |
getSwingComponentClassName() |
protected String |
getSWTComponentClassName() |
ToolkitSpecificAlignmentArea |
getToolkitComponent() |
boolean |
hasAlignmentModel()
Allows to determine whether this instance is currently associated with any alignment model.
|
boolean |
hasContainer()
Determines whether this instance is contained inside a
MultipleAlignmentsContainer . |
boolean |
isAllowVerticalScrolling()
Determines whether this area should be displayed with its whole height insight a
MultipleAlignmentsContainer
if there is enough space available. |
void |
paint(TICPaintEvent event) |
void |
reinsertSubelements()
Reinserts subelements in the contained label and content areas if they already have created a toolkit specific component.
|
void |
scrollCursorToVisible() |
AlignmentModel<?> |
setAlignmentModel(AlignmentModel<?> alignmentModel,
boolean moveListeners)
Changes the alignment model providing the data for this instance.
|
void |
setAllowVerticalScrolling(boolean allowVerticalScrolling)
Allows to specify whether this area should be displayed with its whole height insight a
MultipleAlignmentsContainer
if there is enough space available. |
addKeyListener, addMouseListener, addMouseWheelListener, assignSize, getCurrentToolkit, getKeyListenersSet, getMouseListenersSet, getMouseWheelListenersSet, hasToolkitComponent, removeKeyListener, removeMouseListener, removeWheelMouseListener, repaint, setToolkitComponent
public static final int MIN_PART_AREA_HEIGHT
public static final int DIVIDER_WIDTH
public AlignmentArea()
MultipleAlignmentsContainer
.
If you want to create an alignment area that shall be inserted into a MultipleAlignmentsContainer
use AlignmentArea(MultipleAlignmentsContainer)
instead.
public AlignmentArea(MultipleAlignmentsContainer container)
MultipleAlignmentsContainer
.container
- the container where the returned instance will be contained inpublic boolean hasAlignmentModel()
true
if an associated alignment model is present, false
if no alignment model is specified.public AlignmentModel<?> getAlignmentModel()
public PaintSettings getPaintSettings()
public AlignmentModel<?> setAlignmentModel(AlignmentModel<?> alignmentModel, boolean moveListeners)
alignmentModel
- the new alignment model to use from now onmoveListeners
- Specify true
here, if you want the AlignmentModelChangeListener
s
attached to the current model to be moved to the specified alignmentModel
,
false
if the listeners shall remain attached to the old model. (This instance
is also registered as a listener and is always moved to the new object, no matter which value is
specified here.)null
if there was no model beforepublic SequenceOrder getSequenceOrder()
public DataAreaModel getDataAreas()
public EditSettings getEditSettings()
public SelectionModel getSelection()
public AlignmentActionProvider<Object> getActionProvider()
public MultipleAlignmentsContainer getContainer()
null
if this instance is used as a stand-alone component.public boolean hasContainer()
MultipleAlignmentsContainer
.true
if this area is part of a parent container or false
if it is used as a
stand-alone componentpublic AlignmentContentArea getContentArea()
public AlignmentLabelArea getLabelArea()
public boolean isAllowVerticalScrolling()
MultipleAlignmentsContainer
if there is enough space available.true
if this area does not need to be displayed with its whole width, false
if scrolling should
be avoided if possiblepublic void setAllowVerticalScrolling(boolean allowVerticalScrolling)
MultipleAlignmentsContainer
if there is enough space available.allowVerticalScrolling
- Specify true
here, if this area does not need to be displayed with its
whole width or false
if scrolling should be avoided if possible.public int getGlobalMaxSequenceLength()
MultipleAlignmentsContainer
than this methods calculates the maximum length of all sequences in all alignment areas contained in
this container. Otherwise the return value is identical with getSequenceProvider.getMaxSequenceLength()
.AlignmentModel.getMaxSequenceLength()
public double getLocalMaximumNeededAlignmentWidth()
#getGlobalMaximumNeededWidth()
.public double getLocalMaxNeededWidth()
public int getGlobalMaxNeededWidth()
MultipleAlignmentsContainer
.public void scrollCursorToVisible()
protected String getSwingComponentClassName()
getSwingComponentClassName
in class TICComponent
protected String getSWTComponentClassName()
getSWTComponentClassName
in class TICComponent
public ToolkitSpecificAlignmentArea getToolkitComponent()
getToolkitComponent
in class TICComponent
public void paint(TICPaintEvent event)
paint
in class TICComponent
public Dimension getSize()
getSize
in class TICComponent
tic.TICComponent
public void assignSizeToAll()
assignSize()
method of the contained AlignmentContentArea
, AlignmentLabelArea
,
their subcomponents and on this instance.public void reinsertSubelements()
public <T> void afterSequenceChange(SequenceChangeEvent<T> e)
AlignmentModelChangeListener
afterSequenceChange
in interface AlignmentModelChangeListener
e
- the event object containing information on the changepublic <T> void afterSequenceRenamed(SequenceRenamedEvent<T> e)
AlignmentModelChangeListener
afterSequenceRenamed
in interface AlignmentModelChangeListener
e
- the event object containing information on the changepublic <T> void afterTokenChange(TokenChangeEvent<T> e)
AlignmentModelChangeListener
afterTokenChange
in interface AlignmentModelChangeListener
e
- the event object containing information on the changepublic <T,U> void afterProviderChanged(AlignmentModel<T> previous, AlignmentModel<U> current)
AlignmentModelChangeListener
AlignmentModel
.
This might e.g. happen, if the data provider of an AlignmentArea
was changed.
afterProviderChanged
in interface AlignmentModelChangeListener
previous
- the data provider this listener was attached to before the event happenedcurrent
- the new data provider this listener is attached to nowpublic void dataAreaInsertedRemoved(DataAreaChangeEvent e)
dataAreaInsertedRemoved
in interface DataAreaModelListener
public void dataAreaVisibilityChanged(DataAreaChangeEvent e)
dataAreaVisibilityChanged
in interface DataAreaModelListener