2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import java.awt.Color;
25 import java.util.Hashtable;
26 import java.util.Iterator;
27 import java.util.List;
30 import jalview.analysis.Conservation;
31 import jalview.analysis.TreeModel;
32 import jalview.datamodel.AlignmentAnnotation;
33 import jalview.datamodel.AlignmentExportData;
34 import jalview.datamodel.AlignmentI;
35 import jalview.datamodel.AlignmentView;
36 import jalview.datamodel.ColumnSelection;
37 import jalview.datamodel.ProfilesI;
38 import jalview.datamodel.SearchResultsI;
39 import jalview.datamodel.SequenceCollectionI;
40 import jalview.datamodel.SequenceGroup;
41 import jalview.datamodel.SequenceI;
42 import jalview.renderer.ResidueShaderI;
43 import jalview.schemes.ColourSchemeI;
44 import jalview.viewmodel.ViewportRanges;
50 public interface AlignViewportI extends ViewStyleI
54 * Get the ranges object containing details of the start and end sequences and
59 public ViewportRanges getRanges();
62 * calculate the height for visible annotation, revalidating bounds where
63 * necessary ABSTRACT GUI METHOD
65 * @return total height of annotation
67 public int calcPanelHeight();
70 * Answers true if the viewport has at least one column selected
74 boolean hasSelectedColumns();
77 * Answers true if the viewport has at least one hidden column
81 boolean hasHiddenColumns();
83 boolean isValidCharWidth();
85 boolean isShowConsensusHistogram();
87 boolean isShowSequenceLogo();
89 boolean isNormaliseSequenceLogo();
91 ColourSchemeI getGlobalColourScheme();
94 * Returns an object that describes colouring (including any thresholding or
95 * fading) of the alignment
99 ResidueShaderI getResidueShading();
101 AlignmentI getAlignment();
103 ColumnSelection getColumnSelection();
105 ProfilesI getSequenceConsensusHash();
108 * Get consensus data table for the cDNA complement of this alignment (if any)
112 Hashtable<String, Object>[] getComplementConsensusHash();
114 Hashtable<String, Object>[] getRnaStructureConsensusHash();
116 boolean isIgnoreGapsConsensus();
118 boolean isCalculationInProgress(AlignmentAnnotation alignmentAnnotation);
120 AlignmentAnnotation getAlignmentQualityAnnot();
122 AlignmentAnnotation getAlignmentConservationAnnotation();
125 * get the container for alignment consensus annotation
129 AlignmentAnnotation getAlignmentConsensusAnnotation();
132 * get the container for alignment gap annotation
136 AlignmentAnnotation getAlignmentGapAnnotation();
139 * get the container for cDNA complement consensus annotation
143 AlignmentAnnotation getComplementConsensusAnnotation();
146 * Test to see if viewport is still open and active
148 * @return true indicates that all references to viewport should be dropped
153 * Dispose of all references or resources held by the viewport
158 * get the associated calculation thread manager for the view
162 AlignCalcManagerI getCalcManager();
165 * get the percentage gaps allowed in a conservation calculation
168 public int getConsPercGaps();
171 * set the consensus result object for the viewport
175 void setSequenceConsensusHash(ProfilesI hconsensus);
178 * Set the cDNA complement consensus for the viewport
182 void setComplementConsensusHash(Hashtable<String, Object>[] hconsensus);
186 * @return the alignment annotation row for the structure consensus
189 AlignmentAnnotation getAlignmentStrucConsensusAnnotation();
192 * set the Rna structure consensus result object for the viewport
194 * @param hStrucConsensus
196 void setRnaStructureConsensusHash(
197 Hashtable<String, Object>[] hStrucConsensus);
200 * Sets the colour scheme for the background alignment (as distinct from
201 * sub-groups, which may have their own colour schemes). A null value is used
202 * for no residue colour (white).
206 void setGlobalColourScheme(ColourSchemeI cs);
208 Map<SequenceI, SequenceCollectionI> getHiddenRepSequences();
210 void setHiddenRepSequences(
211 Map<SequenceI, SequenceCollectionI> hiddenRepSequences);
214 * hides or shows dynamic annotation rows based on groups and group and
215 * alignment associated auto-annotation state flags apply the current
216 * group/autoannotation settings to the alignment view. Usually you should
217 * call the AlignmentViewPanel.adjustAnnotationHeight() method afterwards to
218 * ensure the annotation panel bounds are set correctly.
220 * @param applyGlobalSettings
221 * - apply to all autoannotation rows or just the ones associated
222 * with the current visible region
223 * @param preserveNewGroupSettings
224 * - don't apply global settings to groups which don't already have
225 * group associated annotation
227 void updateGroupAnnotationSettings(boolean applyGlobalSettings,
228 boolean preserveNewGroupSettings);
230 void setSequenceColour(SequenceI seq, Color col);
232 Color getSequenceColour(SequenceI seq);
234 void updateSequenceIdColours();
236 SequenceGroup getSelectionGroup();
239 * get the currently selected sequence objects or all the sequences in the
240 * alignment. TODO: change to List<>
242 * @return array of references to sequence objects
244 SequenceI[] getSequenceSelection();
246 void clearSequenceColours();
249 * return a compact representation of the current alignment selection to pass
250 * to an analysis function
252 * @param selectedOnly
253 * boolean true to just return the selected view
254 * @return AlignmentView
256 AlignmentView getAlignmentView(boolean selectedOnly);
259 * return a compact representation of the current alignment selection to pass
260 * to an analysis function
262 * @param selectedOnly
263 * boolean true to just return the selected view
265 * boolean true to annotate the alignment view with groups on the
266 * alignment (and intersecting with selected region if selectedOnly
268 * @return AlignmentView
270 AlignmentView getAlignmentView(boolean selectedOnly, boolean markGroups);
273 * This method returns the visible alignment as text, as seen on the GUI, ie
274 * if columns are hidden they will not be returned in the result. Use this for
275 * calculating trees, PCA, redundancy etc on views which contain hidden
276 * columns. This method doesn't exclude hidden sequences from the output.
278 * @param selectedRegionOnly
279 * - determines if only the selected region or entire alignment is
283 String[] getViewAsString(boolean selectedRegionOnly);
286 * This method returns the visible alignment as text, as seen on the GUI, ie
287 * if columns are hidden they will not be returned in the result. Use this for
288 * calculating trees, PCA, redundancy etc on views which contain hidden
291 * @param selectedRegionOnly
292 * - determines if only the selected region or entire alignment is
294 * @param isExportHiddenSeqs
295 * - determines if hidden sequences would be exported or not.
299 String[] getViewAsString(boolean selectedRegionOnly,
300 boolean isExportHiddenSeqs);
302 void setSelectionGroup(SequenceGroup sg);
304 char getGapCharacter();
306 void setColumnSelection(ColumnSelection cs);
308 void setConservation(Conservation cons);
311 * get a copy of the currently visible alignment annotation
313 * @param selectedOnly
314 * if true - trim to selected regions on the alignment
315 * @return an empty list or new alignment annotation objects shown only
316 * visible columns trimmed to selected region only
318 List<AlignmentAnnotation> getVisibleAlignmentAnnotation(
319 boolean selectedOnly);
321 FeaturesDisplayedI getFeaturesDisplayed();
323 String getSequenceSetId();
325 boolean areFeaturesDisplayed();
327 void setFeaturesDisplayed(FeaturesDisplayedI featuresDisplayedI);
329 void alignmentChanged(AlignmentViewPanel ap);
332 * @return the padGaps
340 void setPadGaps(boolean padGaps);
343 * return visible region boundaries within given column range
346 * first column (inclusive, from 0)
348 * last column (exclusive)
349 * @return int[][] range of {start,end} visible positions
351 List<int[]> getVisibleRegionBoundaries(int min, int max);
354 * This method returns an array of new SequenceI objects derived from the
355 * whole alignment or just the current selection with start and end points
358 * @note if you need references to the actual SequenceI objects in the
359 * alignment or currently selected then use getSequenceSelection()
360 * @return selection as new sequenceI objects
362 SequenceI[] getSelectionAsNewSequence();
364 void invertColumnSelection();
367 * broadcast selection to any interested parties
369 void sendSelection();
372 * calculate the row position for alignmentIndex if all hidden sequences were
375 * @param alignmentIndex
376 * @return adjusted row position
378 int adjustForHiddenSeqs(int alignmentIndex);
380 boolean hasHiddenRows();
384 * @return a copy of this view's current display settings
386 public ViewStyleI getViewStyle();
389 * update the view's display settings with the given style set
391 * @param settingsForView
393 public void setViewStyle(ViewStyleI settingsForView);
396 * Returns a viewport which holds the cDna for this (protein), or vice versa,
397 * or null if none is set.
401 AlignViewportI getCodingComplement();
404 * Sets the viewport which holds the cDna for this (protein), or vice versa.
405 * Implementation should guarantee that the reciprocal relationship is always
406 * set, i.e. each viewport is the complement of the other.
408 void setCodingComplement(AlignViewportI sl);
411 * Answers true if viewport hosts DNA/RNA, else false.
415 boolean isNucleotide();
418 * Returns an id guaranteed to be unique for this viewport.
425 * Return true if view should scroll to show the highlighted region of a
430 boolean isFollowHighlight();
433 * Set whether view should scroll to show the highlighted region of a sequence
435 void setFollowHighlight(boolean b);
438 * configure the feature renderer with predefined feature settings
440 * @param featureSettings
442 public void applyFeaturesStyle(FeatureSettingsModelI featureSettings);
445 * Apply the given feature settings on top of existing feature settings.
447 public void mergeFeaturesStyle(FeatureSettingsModelI featureSettings);
450 * check if current selection group is defined on the view, or is simply a
453 * @return true if group is defined on the alignment
455 boolean isSelectionDefinedGroup();
459 * @return true if there are search results on the view
461 boolean hasSearchResults();
464 * set the search results for the view
467 * - or null to clear current results
469 void setSearchResults(SearchResultsI results);
472 * get search results for this view (if any)
474 * @return search results or null
476 SearchResultsI getSearchResults();
479 * Updates view settings with the given font. You may need to call
480 * AlignmentPanel.fontChanged to update the layout geometry.
483 * when true, charWidth/height is set according to font metrics
485 void setFont(Font newFont, boolean b);
488 * Answers true if split screen protein and cDNA use the same font
493 boolean isProteinFontAsCdna();
496 * Set the flag for whether split screen protein and cDNA use the same font
501 void setProteinFontAsCdna(boolean b);
503 TreeModel getCurrentTree();
505 void setCurrentTree(TreeModel tree);
508 * Answers a data bean containing data for export as configured by the
514 AlignmentExportData getAlignExportData(AlignExportSettingsI options);
518 * - set the flag for updating structures on next repaint
520 void setUpdateStructures(boolean update);
524 * @return true if structure views will be updated on next refresh
526 boolean isUpdateStructures();
529 * check if structure views need to be updated, and clear the flag afterwards.
531 * @return if an update is needed
533 boolean needToUpdateStructureViews();
536 * Adds sequencegroup to the alignment in the view. Also adds a group to the
537 * complement view if one is defined.
539 * @param sequenceGroup
540 * - a group defined on sequences in the alignment held by the view
542 void addSequenceGroup(SequenceGroup sequenceGroup);
545 * Returns an interator over the [start, end] column positions of the visible
546 * regions of the alignment
548 * @param selectedRegionOnly
549 * if true, and the view has a selection region, then only the
550 * intersection of visible columns with the selection region is
554 Iterator<int[]> getViewAsVisibleContigs(boolean selectedRegionOnly);
557 * notify all concerned that the alignment data has changed and derived data
558 * needs to be recalculated
560 public void notifyAlignmentChanged();