public class AlignmentArea extends info.bioinfweb.tic.scrolling.ScrollingTICComponent implements AlignmentModelChangeListener, DataAreasModelListener
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).
TICComponent
s
and therefore allow to create Swing and SWT instances from them using the factory classes from
TIC. (See the documentation for further details.)
SWT components used to display an alignment are available in two versions. One creates a subcomponent for
each sequence and data area in the alignment. This allows e.g. to provide custom toolkit-specific components for
custom data area implementations (instead of just implementing the
AlignmentSubArea.paintPart(info.bioinfweb.libralign.alignmentarea.content.AlignmentPaintEvent)
method), which may
be necessary in rare cases, e.g. to nest other GUI components in a data area. Using subcomponents in SWT
has the disadvantage that they have a size limit of 2^15-1 px in SWT on many operating systems (currently
Windows or Linux). This width limit can easily be reached when displaying nucleotide or protein
sequences and is due to limitations in the GUI libraries of these operating systems and cannot be fixed within
LibrAlign or SWT.
As a workaround for that problem alternative SWT component implementations that do not create subcomponents
for sequences and data areas are available, which paint the whole alignment directly on a shared component and
allow to scroll alignments with a maximum width and height of Integer.MAX_VALUE
px. (Which is much larger
than the maximum in the first alternative.) These components are not able to make use of custom SWT
components associated with custom or third party data areas. Only data areas that paint directly by implementing
AlignmentSubArea.paintPart(info.bioinfweb.libralign.alignmentarea.content.AlignmentPaintEvent)
can be used in this
case.
The strategy to be used can be set with an additional boolean
parameter passed to the TIC factory
class when creating the SWT toolkit component of an instance of this class. (See
here on how to create toolkit components with such a
factory.) If the parameter is omitted, no subcomponents will be created.
SWTComponentFactory.getInstance().getSWTComponent(someAlignmentArea, shell, SWT.NONE, true); // Creates an SWT component with subcomponents. SWTComponentFactory.getInstance().getSWTComponent(someAlignmentArea, shell, SWT.NONE, false); // Creates an SWT component without subcomponents. SWTComponentFactory.getInstance().getSWTComponent(someAlignmentArea, shell, SWT.NONE); // Creates an SWT component without subcomponents.Since no such limitation exists in Swing, subcomponents will always be created there. This problem is only relevant for SWT under Windows or Linux. (You can determine whether an existing component has subcomponents or using
ToolkitSpecificAlignmentContentArea.hasSubcomponents()
.)MultipleAlignmentsContainer
,
AlignmentContentArea
,
AlignmentLabelArea
,
AlignmentModel
,
LibrAlign documentation on working with toolkitsModifier 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 |
DISPATCHER_MAP, repaintRequested
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 |
afterModelChanged(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<java.lang.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.
|
DataAreasModel |
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.
|
double |
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() |
java.util.List<ColorOverlay> |
getOverlays()
Returns an editable list of color overlays to be used when painting the contents of this area.
|
double |
getPaintHeight()
Calculates the height of all sequences and all visible data areas together.
|
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.
|
java.awt.Dimension |
getSize()
Returns the size of the underlying toolkit specific component.
|
protected java.lang.String |
getSwingComponentClassName(java.lang.Object... parameters)
Returns the name of a toolkit specific Swing component displaying the contents of this instance.
|
protected java.lang.String |
getSWTComponentClassName(java.lang.Object... parameters)
Returns the name of a toolkit specific SWT component displaying the contents of this instance.
|
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 |
revalidate()
Recalculates the size of this and all subcomponents.
|
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. |
void |
updateSubelements()
Reinserts subelements in the contained label and content areas if they already have created a toolkit specific component.
|
fireControlScrolled, getScrollListeners, getScrollOffsetX, getScrollOffsetY, getVisibleRectangle, scrollRectangleToVisible, setScrollOffset, setScrollOffsetX, setScrollOffsetY
addKeyListener, addMouseListener, addMouseWheelListener, assignSize, dispatchEvent, getCurrentToolkit, getKeyListenersSet, getMouseListenersSet, getMouseWheelListenersSet, getSwingComponentConstructorParameters, getSWTComponentConstructorParameters, hasDefinedSize, hasToolkitComponent, isUpdateOngoing, removeKeyListener, removeMouseListener, removeWheelMouseListener, repaint, setToolkitComponent, setUpdateOngoing
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 DataAreasModel getDataAreas()
public EditSettings getEditSettings()
public SelectionModel getSelection()
public java.util.List<ColorOverlay> getOverlays()
public AlignmentActionProvider<java.lang.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()
getGlobalMaxNeededWidth()
.public double getLocalMaxNeededWidth()
public double getGlobalMaxNeededWidth()
MultipleAlignmentsContainer
.public double getPaintHeight()
public void scrollCursorToVisible()
protected java.lang.String getSwingComponentClassName(java.lang.Object... parameters)
getSwingComponentClassName
in class info.bioinfweb.tic.scrolling.ScrollingTICComponent
parameters
- This implementation does not recognize any additional parameters.protected java.lang.String getSWTComponentClassName(java.lang.Object... parameters)
getSWTComponentClassName
in class info.bioinfweb.tic.scrolling.ScrollingTICComponent
parameters
- This implementation expects no or a single Boolean
parameter which determines
whether the name of an SWT component using subcomponents for each sequence and data area
or a shared component for direct painting shall be returned. If no parameter is passed,
false
is assumed.public ToolkitSpecificAlignmentArea getToolkitComponent()
getToolkitComponent
in class info.bioinfweb.tic.scrolling.ScrollingTICComponent
public void paint(TICPaintEvent event)
paint
in class TICComponent
public java.awt.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 revalidate()
MultipleAlignmentsContainer
this container and all its subcomponents will do the
same.
This method can be used e.g. by data areas to make sure that their owning alignment area adjusts to their content changes that possibly result in size changes.
public void updateSubelements()
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 afterModelChanged(AlignmentModel<T> previous, AlignmentModel<U> current)
AlignmentModelChangeListener
AlignmentModel
.
This happens if the alignment model of an AlignmentArea
was changed.
afterModelChanged
in interface AlignmentModelChangeListener
previous
- the alignment model this listener was attached to before the event happenedcurrent
- the new alignment model this listener is attached to nowpublic void dataAreaInsertedRemoved(DataAreaChangeEvent e)
dataAreaInsertedRemoved
in interface DataAreasModelListener
public void dataAreaVisibilityChanged(DataAreaChangeEvent e)
dataAreaVisibilityChanged
in interface DataAreasModelListener