Clover icon

Coverage Report

  1. Project Clover database Thu Nov 27 2025 16:51:35 GMT
  2. Package jalview.api

File AlignViewportI.java

 

Code metrics

0
0
0
1
615
140
0
-
-
0
-

Classes

Class Line # Actions
AlignViewportI 54 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.api;
22   
23    import java.awt.Color;
24    import java.awt.Font;
25    import java.util.Hashtable;
26    import java.util.Iterator;
27    import java.util.List;
28    import java.util.Map;
29   
30    import jalview.analysis.AlignmentUtils;
31    import jalview.analysis.Conservation;
32    import jalview.analysis.TreeModel;
33    import jalview.datamodel.AlignmentAnnotation;
34    import jalview.datamodel.AlignmentExportData;
35    import jalview.datamodel.AlignmentI;
36    import jalview.datamodel.AlignmentView;
37    import jalview.datamodel.ColumnSelection;
38    import jalview.datamodel.ContactListI;
39    import jalview.datamodel.ContactMatrixI;
40    import jalview.datamodel.ProfilesI;
41    import jalview.datamodel.SearchResultsI;
42    import jalview.datamodel.SequenceCollectionI;
43    import jalview.datamodel.SequenceGroup;
44    import jalview.datamodel.SequenceI;
45    import jalview.renderer.ResidueShaderI;
46    import jalview.schemes.ColourSchemeI;
47    import jalview.util.Constants;
48    import jalview.viewmodel.ViewportRanges;
49   
50    /**
51    * @author jimp
52    *
53    */
 
54    public interface AlignViewportI extends ViewStyleI
55    {
56   
57    /**
58    * Get the ranges object containing details of the start and end sequences and
59    * residues
60    *
61    * @return
62    */
63    public ViewportRanges getRanges();
64   
65    /**
66    * calculate the height for visible annotation, revalidating bounds where
67    * necessary ABSTRACT GUI METHOD
68    *
69    * @return total height of annotation
70    */
71    public int calcPanelHeight();
72   
73    /**
74    * Answers true if the viewport has at least one column selected
75    *
76    * @return
77    */
78    boolean hasSelectedColumns();
79   
80    /**
81    * Answers true if the viewport has at least one hidden column
82    *
83    * @return
84    */
85    boolean hasHiddenColumns();
86   
87    boolean isValidCharWidth();
88   
89    boolean isShowConsensusHistogram();
90   
91    boolean isShowSequenceLogo();
92   
93    boolean isNormaliseSequenceLogo();
94   
95    ColourSchemeI getGlobalColourScheme();
96   
97    /**
98    * Returns an object that describes colouring (including any thresholding or
99    * fading) of the alignment
100    *
101    * @return
102    */
103    ResidueShaderI getResidueShading();
104   
105    AlignmentI getAlignment();
106   
107    ColumnSelection getColumnSelection();
108   
109    ProfilesI getSequenceConsensusHash();
110   
111    /**
112    * Get consensus data table for the cDNA complement of this alignment (if any)
113    *
114    * @return
115    */
116    Hashtable<String, Object>[] getComplementConsensusHash();
117   
118    Hashtable<String, Object>[] getRnaStructureConsensusHash();
119   
120    boolean isIgnoreGapsConsensus();
121   
122    boolean isCalculationInProgress(AlignmentAnnotation alignmentAnnotation);
123   
124    AlignmentAnnotation getAlignmentQualityAnnot();
125   
126    AlignmentAnnotation getAlignmentConservationAnnotation();
127   
128    /**
129    * get the container for alignment consensus annotation
130    *
131    * @return
132    */
133    AlignmentAnnotation getAlignmentConsensusAnnotation();
134   
135    List<AlignmentAnnotation> getAlignmentSecondaryStructureConsensusAnnotation();
136   
137    /**
138    * get the container for alignment gap annotation
139    *
140    * @return
141    */
142    AlignmentAnnotation getAlignmentGapAnnotation();
143   
144    /**
145    * get the container for cDNA complement consensus annotation
146    *
147    * @return
148    */
149    AlignmentAnnotation getComplementConsensusAnnotation();
150   
151    /**
152    * Test to see if viewport is still open and active
153    *
154    * @return true indicates that all references to viewport should be dropped
155    */
156    boolean isClosed();
157   
158    /**
159    * Dispose of all references or resources held by the viewport
160    */
161    void dispose();
162   
163    /**
164    * get the associated calculation thread manager for the view
165    *
166    * @return
167    */
168    AlignCalcManagerI getCalcManager();
169   
170    /**
171    * get the percentage gaps allowed in a conservation calculation
172    *
173    */
174    public int getConsPercGaps();
175   
176    /**
177    * set the consensus result object for the viewport
178    *
179    * @param hconsensus
180    */
181    void setSequenceConsensusHash(ProfilesI hconsensus);
182   
183    void setSequenceSSConsensusHash(
184    Map<String, ProfilesI> hSSConsesnusProfileMap);
185   
186    /**
187    * Set the cDNA complement consensus for the viewport
188    *
189    * @param hconsensus
190    */
191    void setComplementConsensusHash(Hashtable<String, Object>[] hconsensus);
192   
193    /**
194    *
195    * @return the alignment annotation row for the structure consensus
196    * calculation
197    */
198    AlignmentAnnotation getAlignmentStrucConsensusAnnotation();
199   
200    /**
201    * set the Rna structure consensus result object for the viewport
202    *
203    * @param hStrucConsensus
204    */
205    void setRnaStructureConsensusHash(
206    Hashtable<String, Object>[] hStrucConsensus);
207   
208    /**
209    * Sets the colour scheme for the background alignment (as distinct from
210    * sub-groups, which may have their own colour schemes). A null value is used
211    * for no residue colour (white).
212    *
213    * @param cs
214    */
215    void setGlobalColourScheme(ColourSchemeI cs);
216   
217    Map<SequenceI, SequenceCollectionI> getHiddenRepSequences();
218   
219    void setHiddenRepSequences(
220    Map<SequenceI, SequenceCollectionI> hiddenRepSequences);
221   
222    /**
223    * hides or shows dynamic annotation rows based on groups and group and
224    * alignment associated auto-annotation state flags apply the current
225    * group/autoannotation settings to the alignment view. Usually you should
226    * call the AlignmentViewPanel.adjustAnnotationHeight() method afterwards to
227    * ensure the annotation panel bounds are set correctly.
228    *
229    * @param applyGlobalSettings
230    * - apply to all autoannotation rows or just the ones associated
231    * with the current visible region
232    * @param preserveNewGroupSettings
233    * - don't apply global settings to groups which don't already have
234    * group associated annotation
235    */
236    void updateGroupAnnotationSettings(boolean applyGlobalSettings,
237    boolean preserveNewGroupSettings);
238   
239    void setSequenceColour(SequenceI seq, Color col);
240   
241    Color getSequenceColour(SequenceI seq);
242   
243    void updateSequenceIdColours();
244   
245    SequenceGroup getSelectionGroup();
246   
247    /**
248    * get the currently selected sequence objects or all the sequences in the
249    * alignment. TODO: change to List<>
250    *
251    * @return array of references to sequence objects
252    */
253    SequenceI[] getSequenceSelection();
254   
255    void clearSequenceColours();
256   
257    /**
258    * return a compact representation of the current alignment selection to pass
259    * to an analysis function
260    *
261    * @param selectedOnly
262    * boolean true to just return the selected view
263    * @return AlignmentView
264    */
265    AlignmentView getAlignmentView(boolean selectedOnly);
266   
267    /**
268    * return a compact representation of the current alignment selection to pass
269    * to an analysis function
270    *
271    * @param selectedOnly
272    * boolean true to just return the selected view
273    * @param markGroups
274    * boolean true to annotate the alignment view with groups on the
275    * alignment (and intersecting with selected region if selectedOnly
276    * is true)
277    * @return AlignmentView
278    */
279    AlignmentView getAlignmentView(boolean selectedOnly, boolean markGroups);
280   
281    /**
282    * This method returns the visible alignment as text, as seen on the GUI, ie
283    * if columns are hidden they will not be returned in the result. Use this for
284    * calculating trees, PCA, redundancy etc on views which contain hidden
285    * columns. This method doesn't exclude hidden sequences from the output.
286    *
287    * @param selectedRegionOnly
288    * - determines if only the selected region or entire alignment is
289    * exported
290    * @return String[]
291    */
292    String[] getViewAsString(boolean selectedRegionOnly);
293   
294    /**
295    * This method returns the visible alignment as text, as seen on the GUI, ie
296    * if columns are hidden they will not be returned in the result. Use this for
297    * calculating trees, PCA, redundancy etc on views which contain hidden
298    * columns.
299    *
300    * @param selectedRegionOnly
301    * - determines if only the selected region or entire alignment is
302    * exported
303    * @param isExportHiddenSeqs
304    * - determines if hidden sequences would be exported or not.
305    *
306    * @return String[]
307    */
308    String[] getViewAsString(boolean selectedRegionOnly,
309    boolean isExportHiddenSeqs);
310   
311    void setSelectionGroup(SequenceGroup sg);
312   
313    char getGapCharacter();
314   
315    void setColumnSelection(ColumnSelection cs);
316   
317    void setConservation(Conservation cons);
318   
319    /**
320    * get a copy of the currently visible alignment annotation
321    *
322    * @param selectedOnly
323    * if true - trim to selected regions on the alignment
324    * @return an empty list or new alignment annotation objects shown only
325    * visible columns trimmed to selected region only
326    */
327    List<AlignmentAnnotation> getVisibleAlignmentAnnotation(
328    boolean selectedOnly);
329   
330    FeaturesDisplayedI getFeaturesDisplayed();
331   
332    String getSequenceSetId();
333   
334    boolean areFeaturesDisplayed();
335   
336    void setFeaturesDisplayed(FeaturesDisplayedI featuresDisplayedI);
337   
338    void alignmentChanged(AlignmentViewPanel ap);
339   
340    /**
341    * @return the padGaps
342    */
343    boolean isPadGaps();
344   
345    /**
346    * @param padGaps
347    * the padGaps to set
348    */
349    void setPadGaps(boolean padGaps);
350   
351    /**
352    * return visible region boundaries within given column range
353    *
354    * @param min
355    * first column (inclusive, from 0)
356    * @param max
357    * last column (exclusive)
358    * @return int[][] range of {start,end} visible positions
359    */
360    List<int[]> getVisibleRegionBoundaries(int min, int max);
361   
362    /**
363    * This method returns an array of new SequenceI objects derived from the
364    * whole alignment or just the current selection with start and end points
365    * adjusted
366    *
367    * @note if you need references to the actual SequenceI objects in the
368    * alignment or currently selected then use getSequenceSelection()
369    * @return selection as new sequenceI objects
370    */
371    SequenceI[] getSelectionAsNewSequence();
372   
373    void invertColumnSelection();
374   
375    /**
376    * broadcast selection to any interested parties
377    */
378    void sendSelection();
379   
380    /**
381    * calculate the row position for alignmentIndex if all hidden sequences were
382    * shown
383    *
384    * @param alignmentIndex
385    * @return adjusted row position
386    */
387    int adjustForHiddenSeqs(int alignmentIndex);
388   
389    boolean hasHiddenRows();
390   
391    /**
392    *
393    * @return a copy of this view's current display settings
394    */
395    public ViewStyleI getViewStyle();
396   
397    /**
398    * update the view's display settings with the given style set
399    *
400    * @param settingsForView
401    */
402    public void setViewStyle(ViewStyleI settingsForView);
403   
404    /**
405    * Returns a viewport which holds the cDna for this (protein), or vice versa,
406    * or null if none is set.
407    *
408    * @return
409    */
410    AlignViewportI getCodingComplement();
411   
412    /**
413    * Sets the viewport which holds the cDna for this (protein), or vice versa.
414    * Implementation should guarantee that the reciprocal relationship is always
415    * set, i.e. each viewport is the complement of the other.
416    */
417    void setCodingComplement(AlignViewportI sl);
418   
419    /**
420    * Answers true if viewport hosts DNA/RNA, else false.
421    *
422    * @return
423    */
424    boolean isNucleotide();
425   
426    /**
427    * Returns an id guaranteed to be unique for this viewport.
428    *
429    * @return
430    */
431    String getViewId();
432   
433    /**
434    * Return true if view should scroll to show the highlighted region of a
435    * sequence
436    *
437    * @return
438    */
439    boolean isFollowHighlight();
440   
441    /**
442    * Set whether view should scroll to show the highlighted region of a sequence
443    */
444    void setFollowHighlight(boolean b);
445   
446    /**
447    * configure the feature renderer with predefined feature settings
448    *
449    * @param featureSettings
450    */
451    public void applyFeaturesStyle(FeatureSettingsModelI featureSettings);
452   
453    /**
454    * Apply the given feature settings on top of existing feature settings.
455    */
456    public void mergeFeaturesStyle(FeatureSettingsModelI featureSettings);
457   
458    /**
459    * check if current selection group is defined on the view, or is simply a
460    * temporary group.
461    *
462    * @return true if group is defined on the alignment
463    */
464    boolean isSelectionDefinedGroup();
465   
466    /**
467    *
468    * @return true if there are search results on the view
469    */
470    boolean hasSearchResults();
471   
472    /**
473    * set the search results for the view
474    *
475    * @param results
476    * - or null to clear current results
477    */
478    void setSearchResults(SearchResultsI results);
479   
480    /**
481    * get search results for this view (if any)
482    *
483    * @return search results or null
484    */
485    SearchResultsI getSearchResults();
486   
487    /**
488    * Retrieve a ContactListI corresponding to column in an annotation row in an
489    * alignment.
490    *
491    * @param _aa
492    * - annotation with associated matrix data
493    * @param column
494    * - column in alignment where _aa is associated
495    */
496    ContactListI getContactList(AlignmentAnnotation _aa, int column);
497   
498    /**
499    * Updates view settings with the given font. You may need to call
500    * AlignmentPanel.fontChanged to update the layout geometry.
501    *
502    * @param setGrid
503    * when true, charWidth/height is set according to font metrics
504    */
505    void setFont(Font newFont, boolean b);
506   
507    /**
508    * Answers true if split screen protein and cDNA use the same font
509    *
510    * @return
511    */
512    @Override
513    boolean isProteinFontAsCdna();
514   
515    /**
516    * Set the flag for whether split screen protein and cDNA use the same font
517    *
518    * @return
519    */
520    @Override
521    void setProteinFontAsCdna(boolean b);
522   
523    TreeModel getCurrentTree();
524   
525    void setCurrentTree(TreeModel tree);
526   
527    /**
528    * Answers a data bean containing data for export as configured by the
529    * supplied options
530    *
531    * @param options
532    * @return
533    */
534    AlignmentExportData getAlignExportData(AlignExportSettingsI options);
535   
536    /**
537    * @param update
538    * - set the flag for updating structures on next repaint
539    */
540    void setUpdateStructures(boolean update);
541   
542    /**
543    *
544    * @return true if structure views will be updated on next refresh
545    */
546    boolean isUpdateStructures();
547   
548    /**
549    * check if structure views need to be updated, and clear the flag afterwards.
550    *
551    * @return if an update is needed
552    */
553    boolean needToUpdateStructureViews();
554   
555    /**
556    * Adds sequencegroup to the alignment in the view. Also adds a group to the
557    * complement view if one is defined.
558    *
559    * @param sequenceGroup
560    * - a group defined on sequences in the alignment held by the view
561    */
562    void addSequenceGroup(SequenceGroup sequenceGroup);
563   
564    /**
565    * Returns an interator over the [start, end] column positions of the visible
566    * regions of the alignment
567    *
568    * @param selectedRegionOnly
569    * if true, and the view has a selection region, then only the
570    * intersection of visible columns with the selection region is
571    * returned
572    * @return
573    */
574    Iterator<int[]> getViewAsVisibleContigs(boolean selectedRegionOnly);
575   
576    /**
577    * notify all concerned that the alignment data has changed and derived data
578    * needs to be recalculated
579    */
580    public void notifyAlignmentChanged();
581   
582    /**
583    * retrieve a matrix associated with the view's alignment's annotation
584    *
585    * @param alignmentAnnotation
586    * @return contact matrix or NULL
587    */
588    ContactMatrixI getContactMatrix(AlignmentAnnotation alignmentAnnotation);
589   
590    Map<String, ProfilesI> getSequenceSSConsensusHash();
591   
592    List<String> getSecondaryStructureSources();
593   
594    void setSecondaryStructureSources(List<String> secondaryStructureSources);
595   
596    Color getAnnotationColour(AlignmentAnnotation annot);
597   
598    void setAnnotationColour(AlignmentAnnotation annot, Color col);
599   
600    void updateAnnotationColours();
601   
602    void clearAnnotationColours();
603   
604    Map<AlignmentAnnotation, Color> getAnnotationColours();
605   
606    void setAnnotationColours(
607    Map<AlignmentAnnotation, Color> annotationColours);
608   
609    /**
610    * Get the Consensus annotation for the alignment
611    *
612    * @return
613    */
614    public void setSecondaryStructureSources();
615    }