JAL-2599 fix for information annotation buttons
[jalview.git] / src / jalview / api / AlignViewportI.java
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 jalview.analysis.Conservation;
24 import jalview.datamodel.AlignmentAnnotation;
25 import jalview.datamodel.AlignmentI;
26 import jalview.datamodel.AlignmentView;
27 import jalview.datamodel.CigarArray;
28 import jalview.datamodel.ColumnSelection;
29 import jalview.datamodel.ProfilesI;
30 import jalview.datamodel.SearchResultsI;
31 import jalview.datamodel.SequenceCollectionI;
32 import jalview.datamodel.SequenceGroup;
33 import jalview.datamodel.SequenceI;
34 import jalview.renderer.ResidueShaderI;
35 import jalview.schemes.ColourSchemeI;
36 import jalview.viewmodel.ViewportRanges;
37
38 import java.awt.Color;
39 import java.awt.Font;
40 import java.util.Hashtable;
41 import java.util.List;
42 import java.util.Map;
43
44 /**
45  * @author jimp
46  * 
47  */
48 public interface AlignViewportI extends ViewStyleI
49 {
50
51   /**
52    * Get the ranges object containing details of the start and end sequences and
53    * residues
54    * 
55    * @return
56    */
57   public ViewportRanges getRanges();
58
59   /**
60    * calculate the height for visible annotation, revalidating bounds where
61    * necessary ABSTRACT GUI METHOD
62    * 
63    * @return total height of annotation
64    */
65   public int calcPanelHeight();
66
67   /**
68    * Answers true if the viewport has at least one column selected
69    * 
70    * @return
71    */
72   boolean hasSelectedColumns();
73
74   /**
75    * Answers true if the viewport has at least one hidden column
76    * 
77    * @return
78    */
79   boolean hasHiddenColumns();
80
81   boolean isValidCharWidth();
82
83   boolean isShowConsensusHistogram();
84
85   boolean isShowSequenceLogo();
86
87   boolean isNormaliseSequenceLogo();
88
89   boolean isShowInformationHistogram();
90
91   boolean isShowHMMSequenceLogo();
92
93   boolean isNormaliseHMMSequenceLogo();
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   ProfilesI getSequenceInformationHash();
112
113   /**
114    * Get consensus data table for the cDNA complement of this alignment (if any)
115    * 
116    * @return
117    */
118   Hashtable[] getComplementConsensusHash();
119
120   Hashtable[] getRnaStructureConsensusHash();
121
122   boolean isIgnoreGapsConsensus();
123
124   boolean isIgnoreBelowBackground();
125
126   boolean isCalculationInProgress(AlignmentAnnotation alignmentAnnotation);
127
128   AlignmentAnnotation getAlignmentQualityAnnot();
129
130   AlignmentAnnotation getAlignmentConservationAnnotation();
131
132   /**
133    * get the container for alignment consensus annotation
134    * 
135    * @return
136    */
137   AlignmentAnnotation getAlignmentConsensusAnnotation();
138
139   /**
140    * get the container for alignment information content annotation
141    * 
142    * @return
143    */
144   AlignmentAnnotation getAlignmentInformationAnnotation();
145
146   /**
147    * get the container for alignment gap annotation
148    * 
149    * @return
150    */
151   AlignmentAnnotation getAlignmentGapAnnotation();
152
153   /**
154    * get the container for cDNA complement consensus annotation
155    * 
156    * @return
157    */
158   AlignmentAnnotation getComplementConsensusAnnotation();
159
160   /**
161    * Test to see if viewport is still open and active
162    * 
163    * @return true indicates that all references to viewport should be dropped
164    */
165   boolean isClosed();
166
167   /**
168    * Dispose of all references or resources held by the viewport
169    */
170   void dispose();
171
172   /**
173    * get the associated calculation thread manager for the view
174    * 
175    * @return
176    */
177   AlignCalcManagerI getCalcManager();
178
179   /**
180    * get the percentage gaps allowed in a conservation calculation
181    * 
182    */
183   public int getConsPercGaps();
184
185   /**
186    * set the consensus result object for the viewport
187    * 
188    * @param hconsensus
189    */
190   void setSequenceConsensusHash(ProfilesI hconsensus);
191
192   /**
193    * set the information result object for the viewport
194    * 
195    * @param hconsensus
196    */
197   void setSequenceInformationHash(ProfilesI hinformation);
198
199   /**
200    * Set the cDNA complement consensus for the viewport
201    * 
202    * @param hconsensus
203    */
204   void setComplementConsensusHash(Hashtable[] hconsensus);
205
206   /**
207    * 
208    * @return the alignment annotation row for the structure consensus
209    *         calculation
210    */
211   AlignmentAnnotation getAlignmentStrucConsensusAnnotation();
212
213   /**
214    * set the Rna structure consensus result object for the viewport
215    * 
216    * @param hStrucConsensus
217    */
218   void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus);
219
220   /**
221    * Sets the colour scheme for the background alignment (as distinct from
222    * sub-groups, which may have their own colour schemes). A null value is used
223    * for no residue colour (white).
224    * 
225    * @param cs
226    */
227   void setGlobalColourScheme(ColourSchemeI cs);
228
229   Map<SequenceI, SequenceCollectionI> getHiddenRepSequences();
230
231   void setHiddenRepSequences(
232           Map<SequenceI, SequenceCollectionI> hiddenRepSequences);
233
234   /**
235    * hides or shows dynamic annotation rows based on groups and group and
236    * alignment associated auto-annotation state flags apply the current
237    * group/autoannotation settings to the alignment view. Usually you should
238    * call the AlignmentViewPanel.adjustAnnotationHeight() method afterwards to
239    * ensure the annotation panel bounds are set correctly.
240    * 
241    * @param applyGlobalSettings
242    *          - apply to all autoannotation rows or just the ones associated
243    *          with the current visible region
244    * @param preserveNewGroupSettings
245    *          - don't apply global settings to groups which don't already have
246    *          group associated annotation
247    */
248   void updateGroupAnnotationSettings(boolean applyGlobalSettings,
249           boolean preserveNewGroupSettings);
250
251   void setSequenceColour(SequenceI seq, Color col);
252
253   Color getSequenceColour(SequenceI seq);
254
255   void updateSequenceIdColours();
256
257   SequenceGroup getSelectionGroup();
258
259   /**
260    * get the currently selected sequence objects or all the sequences in the
261    * alignment. TODO: change to List<>
262    * 
263    * @return array of references to sequence objects
264    */
265   SequenceI[] getSequenceSelection();
266
267   void clearSequenceColours();
268
269   /**
270    * This method returns the visible alignment as text, as seen on the GUI, ie
271    * if columns are hidden they will not be returned in the result. Use this for
272    * calculating trees, PCA, redundancy etc on views which contain hidden
273    * columns.
274    * 
275    * @return String[]
276    */
277   CigarArray getViewAsCigars(boolean selectedRegionOnly);
278
279   /**
280    * return a compact representation of the current alignment selection to pass
281    * to an analysis function
282    * 
283    * @param selectedOnly
284    *          boolean true to just return the selected view
285    * @return AlignmentView
286    */
287   AlignmentView getAlignmentView(boolean selectedOnly);
288
289   /**
290    * return a compact representation of the current alignment selection to pass
291    * to an analysis function
292    * 
293    * @param selectedOnly
294    *          boolean true to just return the selected view
295    * @param markGroups
296    *          boolean true to annotate the alignment view with groups on the
297    *          alignment (and intersecting with selected region if selectedOnly
298    *          is true)
299    * @return AlignmentView
300    */
301   AlignmentView getAlignmentView(boolean selectedOnly, boolean markGroups);
302
303   /**
304    * This method returns the visible alignment as text, as seen on the GUI, ie
305    * if columns are hidden they will not be returned in the result. Use this for
306    * calculating trees, PCA, redundancy etc on views which contain hidden
307    * columns. This method doesn't exclude hidden sequences from the output.
308    *
309    * @param selectedRegionOnly
310    *          - determines if only the selected region or entire alignment is
311    *          exported
312    * @return String[]
313    */
314   String[] getViewAsString(boolean selectedRegionOnly);
315
316   /**
317    * This method returns the visible alignment as text, as seen on the GUI, ie
318    * if columns are hidden they will not be returned in the result. Use this for
319    * calculating trees, PCA, redundancy etc on views which contain hidden
320    * columns.
321    * 
322    * @param selectedRegionOnly
323    *          - determines if only the selected region or entire alignment is
324    *          exported
325    * @param isExportHiddenSeqs
326    *          - determines if hidden sequences would be exported or not.
327    * 
328    * @return String[]
329    */
330   String[] getViewAsString(boolean selectedRegionOnly,
331           boolean isExportHiddenSeqs);
332
333   void setSelectionGroup(SequenceGroup sg);
334
335   char getGapCharacter();
336
337   void setColumnSelection(ColumnSelection cs);
338
339   void setConservation(Conservation cons);
340
341   /**
342    * get a copy of the currently visible alignment annotation
343    * 
344    * @param selectedOnly
345    *          if true - trim to selected regions on the alignment
346    * @return an empty list or new alignment annotation objects shown only
347    *         visible columns trimmed to selected region only
348    */
349   List<AlignmentAnnotation> getVisibleAlignmentAnnotation(
350           boolean selectedOnly);
351
352   FeaturesDisplayedI getFeaturesDisplayed();
353
354   String getSequenceSetId();
355
356   boolean areFeaturesDisplayed();
357
358   void setFeaturesDisplayed(FeaturesDisplayedI featuresDisplayedI);
359
360   void alignmentChanged(AlignmentViewPanel ap);
361
362   /**
363    * @return the padGaps
364    */
365   boolean isPadGaps();
366
367   /**
368    * @param padGaps
369    *          the padGaps to set
370    */
371   void setPadGaps(boolean padGaps);
372
373   /**
374    * return visible region boundaries within given column range
375    * 
376    * @param min
377    *          first column (inclusive, from 0)
378    * @param max
379    *          last column (exclusive)
380    * @return int[][] range of {start,end} visible positions
381    */
382   List<int[]> getVisibleRegionBoundaries(int min, int max);
383
384   /**
385    * This method returns an array of new SequenceI objects derived from the
386    * whole alignment or just the current selection with start and end points
387    * adjusted
388    * 
389    * @note if you need references to the actual SequenceI objects in the
390    *       alignment or currently selected then use getSequenceSelection()
391    * @return selection as new sequenceI objects
392    */
393   SequenceI[] getSelectionAsNewSequence();
394
395   void invertColumnSelection();
396
397   /**
398    * broadcast selection to any interested parties
399    */
400   void sendSelection();
401
402   /**
403    * calculate the row position for alignmentIndex if all hidden sequences were
404    * shown
405    * 
406    * @param alignmentIndex
407    * @return adjusted row position
408    */
409   int adjustForHiddenSeqs(int alignmentIndex);
410
411   boolean hasHiddenRows();
412
413   /**
414    * 
415    * @return a copy of this view's current display settings
416    */
417   public ViewStyleI getViewStyle();
418
419   /**
420    * update the view's display settings with the given style set
421    * 
422    * @param settingsForView
423    */
424   public void setViewStyle(ViewStyleI settingsForView);
425
426   /**
427    * Returns a viewport which holds the cDna for this (protein), or vice versa,
428    * or null if none is set.
429    * 
430    * @return
431    */
432   AlignViewportI getCodingComplement();
433
434   /**
435    * Sets the viewport which holds the cDna for this (protein), or vice versa.
436    * Implementation should guarantee that the reciprocal relationship is always
437    * set, i.e. each viewport is the complement of the other.
438    */
439   void setCodingComplement(AlignViewportI sl);
440
441   /**
442    * Answers true if viewport hosts DNA/RNA, else false.
443    * 
444    * @return
445    */
446   boolean isNucleotide();
447
448   /**
449    * Returns an id guaranteed to be unique for this viewport.
450    * 
451    * @return
452    */
453   String getViewId();
454
455   /**
456    * Return true if view should scroll to show the highlighted region of a
457    * sequence
458    * 
459    * @return
460    */
461   boolean isFollowHighlight();
462
463   /**
464    * Set whether view should scroll to show the highlighted region of a sequence
465    */
466   void setFollowHighlight(boolean b);
467
468   public void applyFeaturesStyle(FeatureSettingsModelI featureSettings);
469
470   /**
471    * check if current selection group is defined on the view, or is simply a
472    * temporary group.
473    * 
474    * @return true if group is defined on the alignment
475    */
476   boolean isSelectionDefinedGroup();
477
478   /**
479    * 
480    * @return true if there are search results on the view
481    */
482   boolean hasSearchResults();
483
484   /**
485    * set the search results for the view
486    * 
487    * @param results
488    *          - or null to clear current results
489    */
490   void setSearchResults(SearchResultsI results);
491
492   /**
493    * get search results for this view (if any)
494    * 
495    * @return search results or null
496    */
497   SearchResultsI getSearchResults();
498
499   /**
500    * Updates view settings with the given font. You may need to call
501    * AlignmentPanel.fontChanged to update the layout geometry.
502    * 
503    * @param setGrid
504    *          when true, charWidth/height is set according to font metrics
505    */
506   void setFont(Font newFont, boolean b);
507
508   /**
509    * Answers true if split screen protein and cDNA use the same font
510    * 
511    * @return
512    */
513   @Override
514   boolean isProteinFontAsCdna();
515
516   /**
517    * Set the flag for whether split screen protein and cDNA use the same font
518    * 
519    * @return
520    */
521   @Override
522   void setProteinFontAsCdna(boolean b);
523
524   ProfilesI setSequenceInformationHash();
525 }