JAL-2094 first pass with jalview.api.ColorI interface
[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.SequenceCollectionI;
30 import jalview.datamodel.SequenceGroup;
31 import jalview.datamodel.SequenceI;
32 import jalview.schemes.ColourSchemeI;
33
34 import java.util.Hashtable;
35 import java.util.List;
36 import java.util.Map;
37
38 /**
39  * @author jimp
40  * 
41  */
42 public interface AlignViewportI extends ViewStyleI
43 {
44
45   int getEndRes();
46
47   /**
48    * calculate the height for visible annotation, revalidating bounds where
49    * necessary ABSTRACT GUI METHOD
50    * 
51    * @return total height of annotation
52    */
53   public int calcPanelHeight();
54
55   boolean hasHiddenColumns();
56
57   boolean isValidCharWidth();
58
59   boolean isShowConsensusHistogram();
60
61   boolean isShowSequenceLogo();
62
63   boolean isNormaliseSequenceLogo();
64
65   ColourSchemeI getGlobalColourScheme();
66
67   AlignmentI getAlignment();
68
69   ColumnSelection getColumnSelection();
70
71   Hashtable[] getSequenceConsensusHash();
72
73   /**
74    * Get consensus data table for the cDNA complement of this alignment (if any)
75    * 
76    * @return
77    */
78   Hashtable[] getComplementConsensusHash();
79
80   Hashtable[] getRnaStructureConsensusHash();
81
82   boolean isIgnoreGapsConsensus();
83
84   boolean isCalculationInProgress(AlignmentAnnotation alignmentAnnotation);
85
86   AlignmentAnnotation getAlignmentQualityAnnot();
87
88   AlignmentAnnotation getAlignmentConservationAnnotation();
89
90   /**
91    * get the container for alignment consensus annotation
92    * 
93    * @return
94    */
95   AlignmentAnnotation getAlignmentConsensusAnnotation();
96
97   /**
98    * get the container for cDNA complement consensus annotation
99    * 
100    * @return
101    */
102   AlignmentAnnotation getComplementConsensusAnnotation();
103
104   /**
105    * Test to see if viewport is still open and active
106    * 
107    * @return true indicates that all references to viewport should be dropped
108    */
109   boolean isClosed();
110
111   /**
112    * get the associated calculation thread manager for the view
113    * 
114    * @return
115    */
116   AlignCalcManagerI getCalcManager();
117
118   /**
119    * get the percentage gaps allowed in a conservation calculation
120    * 
121    */
122   public int getConsPercGaps();
123
124   /**
125    * set the consensus result object for the viewport
126    * 
127    * @param hconsensus
128    */
129   void setSequenceConsensusHash(Hashtable[] hconsensus);
130
131   /**
132    * Set the cDNA complement consensus for the viewport
133    * 
134    * @param hconsensus
135    */
136   void setComplementConsensusHash(Hashtable[] hconsensus);
137
138   /**
139    * 
140    * @return the alignment annotatino row for the structure consensus
141    *         calculation
142    */
143   AlignmentAnnotation getAlignmentStrucConsensusAnnotation();
144
145   /**
146    * set the Rna structure consensus result object for the viewport
147    * 
148    * @param hStrucConsensus
149    */
150   void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus);
151
152   /**
153    * set global colourscheme
154    * 
155    * @param rhc
156    */
157   void setGlobalColourScheme(ColourSchemeI rhc);
158
159   Map<SequenceI, SequenceCollectionI> getHiddenRepSequences();
160
161   void setHiddenRepSequences(
162           Map<SequenceI, SequenceCollectionI> hiddenRepSequences);
163
164   /**
165    * hides or shows dynamic annotation rows based on groups and group and
166    * alignment associated auto-annotation state flags apply the current
167    * group/autoannotation settings to the alignment view. Usually you should
168    * call the AlignmentViewPanel.adjustAnnotationHeight() method afterwards to
169    * ensure the annotation panel bounds are set correctly.
170    * 
171    * @param applyGlobalSettings
172    *          - apply to all autoannotation rows or just the ones associated
173    *          with the current visible region
174    * @param preserveNewGroupSettings
175    *          - don't apply global settings to groups which don't already have
176    *          group associated annotation
177    */
178   void updateGroupAnnotationSettings(boolean applyGlobalSettings,
179           boolean preserveNewGroupSettings);
180
181   void setSequenceColour(SequenceI seq, ColorI col);
182
183   ColorI getSequenceColour(SequenceI seq);
184
185   void updateSequenceIdColours();
186
187   SequenceGroup getSelectionGroup();
188
189   /**
190    * get the currently selected sequence objects or all the sequences in the
191    * alignment. TODO: change to List<>
192    * 
193    * @return array of references to sequence objects
194    */
195   SequenceI[] getSequenceSelection();
196
197   void clearSequenceColours();
198
199   /**
200    * This method returns the visible alignment as text, as seen on the GUI, ie
201    * if columns are hidden they will not be returned in the result. Use this for
202    * calculating trees, PCA, redundancy etc on views which contain hidden
203    * columns.
204    * 
205    * @return String[]
206    */
207   CigarArray getViewAsCigars(boolean selectedRegionOnly);
208
209   /**
210    * return a compact representation of the current alignment selection to pass
211    * to an analysis function
212    * 
213    * @param selectedOnly
214    *          boolean true to just return the selected view
215    * @return AlignmentView
216    */
217   AlignmentView getAlignmentView(boolean selectedOnly);
218
219   /**
220    * return a compact representation of the current alignment selection to pass
221    * to an analysis function
222    * 
223    * @param selectedOnly
224    *          boolean true to just return the selected view
225    * @param markGroups
226    *          boolean true to annotate the alignment view with groups on the
227    *          alignment (and intersecting with selected region if selectedOnly
228    *          is true)
229    * @return AlignmentView
230    */
231   AlignmentView getAlignmentView(boolean selectedOnly, boolean markGroups);
232
233   /**
234    * This method returns the visible alignment as text, as seen on the GUI, ie
235    * if columns are hidden they will not be returned in the result. Use this for
236    * calculating trees, PCA, redundancy etc on views which contain hidden
237    * columns.
238    * 
239    * @return String[]
240    */
241   String[] getViewAsString(boolean selectedRegionOnly);
242
243   void setSelectionGroup(SequenceGroup sg);
244
245   char getGapCharacter();
246
247   void setColumnSelection(ColumnSelection cs);
248
249   void setConservation(Conservation cons);
250
251   /**
252    * get a copy of the currently visible alignment annotation
253    * 
254    * @param selectedOnly
255    *          if true - trim to selected regions on the alignment
256    * @return an empty list or new alignment annotation objects shown only
257    *         visible columns trimmed to selected region only
258    */
259   List<AlignmentAnnotation> getVisibleAlignmentAnnotation(
260           boolean selectedOnly);
261
262   FeaturesDisplayedI getFeaturesDisplayed();
263
264   String getSequenceSetId();
265
266   boolean areFeaturesDisplayed();
267
268   void setFeaturesDisplayed(FeaturesDisplayedI featuresDisplayedI);
269
270   void alignmentChanged(AlignmentViewPanel ap);
271
272   /**
273    * @return the padGaps
274    */
275   boolean isPadGaps();
276
277   /**
278    * @param padGaps
279    *          the padGaps to set
280    */
281   void setPadGaps(boolean padGaps);
282
283   /**
284    * return visible region boundaries within given column range
285    * 
286    * @param min
287    *          first column (inclusive, from 0)
288    * @param max
289    *          last column (exclusive)
290    * @return int[][] range of {start,end} visible positions
291    */
292   List<int[]> getVisibleRegionBoundaries(int min, int max);
293
294   /**
295    * This method returns an array of new SequenceI objects derived from the
296    * whole alignment or just the current selection with start and end points
297    * adjusted
298    * 
299    * @note if you need references to the actual SequenceI objects in the
300    *       alignment or currently selected then use getSequenceSelection()
301    * @return selection as new sequenceI objects
302    */
303   SequenceI[] getSelectionAsNewSequence();
304
305   void invertColumnSelection();
306
307   /**
308    * broadcast selection to any interested parties
309    */
310   void sendSelection();
311
312   /**
313    * calculate the row position for alignmentIndex if all hidden sequences were
314    * shown
315    * 
316    * @param alignmentIndex
317    * @return adjusted row position
318    */
319   int adjustForHiddenSeqs(int alignmentIndex);
320
321   boolean hasHiddenRows();
322
323   /**
324    * 
325    * @return a copy of this view's current display settings
326    */
327   public ViewStyleI getViewStyle();
328
329   /**
330    * update the view's display settings with the given style set
331    * 
332    * @param settingsForView
333    */
334   public void setViewStyle(ViewStyleI settingsForView);
335
336   /**
337    * Returns a viewport which holds the cDna for this (protein), or vice versa,
338    * or null if none is set.
339    * 
340    * @return
341    */
342   AlignViewportI getCodingComplement();
343
344   /**
345    * Sets the viewport which holds the cDna for this (protein), or vice versa.
346    * Implementation should guarantee that the reciprocal relationship is always
347    * set, i.e. each viewport is the complement of the other.
348    */
349   void setCodingComplement(AlignViewportI sl);
350
351   /**
352    * Answers true if viewport hosts DNA/RNA, else false.
353    * 
354    * @return
355    */
356   boolean isNucleotide();
357
358   /**
359    * Returns an id guaranteed to be unique for this viewport.
360    * 
361    * @return
362    */
363   String getViewId();
364
365   /**
366    * Return true if view should scroll to show the highlighted region of a
367    * sequence
368    * 
369    * @return
370    */
371   boolean isFollowHighlight();
372
373   /**
374    * Set whether view should scroll to show the highlighted region of a sequence
375    */
376   void setFollowHighlight(boolean b);
377
378   public void applyFeaturesStyle(FeatureSettingsModelI featureSettings);
379 }