2067e9ce0bd7aa0bdaacc594d47a332c387c178f
[jalview.git] / src / jalview / api / AlignViewportI.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1)
3  * Copyright (C) 2014 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.awt.Color;
35 import java.util.Hashtable;
36 import java.util.List;
37 import java.util.Map;
38
39 /**
40  * @author jimp
41  * 
42  */
43 public interface AlignViewportI
44 {
45
46   int getCharWidth();
47
48   int getEndRes();
49
50   int getCharHeight();
51
52   /**
53    * calculate the height for visible annotation, revalidating bounds where
54    * necessary ABSTRACT GUI METHOD
55    * 
56    * @return total height of annotation
57    */
58   public int calcPanelHeight();
59
60   boolean hasHiddenColumns();
61
62   boolean isValidCharWidth();
63
64   boolean isShowConsensusHistogram();
65
66   boolean isShowSequenceLogo();
67
68   boolean isNormaliseSequenceLogo();
69
70   ColourSchemeI getGlobalColourScheme();
71
72   AlignmentI getAlignment();
73
74   ColumnSelection getColumnSelection();
75
76   Hashtable[] getSequenceConsensusHash();
77
78   Hashtable[] getRnaStructureConsensusHash();
79
80   boolean getIgnoreGapsConsensus();
81
82   boolean getCentreColumnLabels();
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    * Test to see if viewport is still open and active
99    * 
100    * @return true indicates that all references to viewport should be dropped
101    */
102   boolean isClosed();
103
104   /**
105    * get the associated calculation thread manager for the view
106    * 
107    * @return
108    */
109   AlignCalcManagerI getCalcManager();
110
111   /**
112    * get the percentage gaps allowed in a conservation calculation
113    * 
114    */
115   public int getConsPercGaps();
116
117   /**
118    * set the consensus result object for the viewport
119    * 
120    * @param hconsensus
121    */
122   void setSequenceConsensusHash(Hashtable[] hconsensus);
123
124   /**
125    * 
126    * @return the alignment annotatino row for the structure consensus
127    *         calculation
128    */
129   AlignmentAnnotation getAlignmentStrucConsensusAnnotation();
130
131   /**
132    * set the Rna structure consensus result object for the viewport
133    * 
134    * @param hStrucConsensus
135    */
136   void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus);
137
138   /**
139    * set global colourscheme
140    * 
141    * @param rhc
142    */
143   void setGlobalColourScheme(ColourSchemeI rhc);
144
145   Map<SequenceI, SequenceCollectionI> getHiddenRepSequences();
146
147   void setHiddenRepSequences(
148           Map<SequenceI, SequenceCollectionI> hiddenRepSequences);
149
150   /**
151    * hides or shows dynamic annotation rows based on groups and group and
152    * alignment associated auto-annotation state flags apply the current
153    * group/autoannotation settings to the alignment view. Usually you should
154    * call the AlignmentViewPanel.adjustAnnotationHeight() method afterwards to
155    * ensure the annotation panel bounds are set correctly.
156    * 
157    * @param applyGlobalSettings
158    *          - apply to all autoannotation rows or just the ones associated
159    *          with the current visible region
160    * @param preserveNewGroupSettings
161    *          - don't apply global settings to groups which don't already have
162    *          group associated annotation
163    */
164   void updateGroupAnnotationSettings(boolean applyGlobalSettings,
165           boolean preserveNewGroupSettings);
166   
167   /**
168    * @return true if a reference sequence is set and should be displayed
169    */
170   public boolean isDisplayReferenceSeq();
171
172   /**
173    * @return set the flag for displaying reference sequences when they are
174    *         available
175    */
176   public void setDisplayReferenceSeq(boolean displayReferenceSeq);
177
178   /**
179    * @return true if colourschemes should render according to reference sequence
180    *         rather than consensus if available
181    */
182   public boolean isColourByReferenceSeq();
183
184   /**
185    * @return true set flag for deciding if colourschemes should render according
186    *         to reference sequence rather than consensus if available
187    */
188   public void setColourByReferenceSeq(boolean colourByReferenceSeq);
189
190   void setSequenceColour(SequenceI seq, Color col);
191
192   Color getSequenceColour(SequenceI seq);
193
194   void updateSequenceIdColours();
195
196   SequenceGroup getSelectionGroup();
197
198   /**
199    * get the currently selected sequence objects or all the sequences in the
200    * alignment. TODO: change to List<>
201    * 
202    * @return array of references to sequence objects
203    */
204   SequenceI[] getSequenceSelection();
205
206   void clearSequenceColours();
207
208   /**
209    * This method returns the visible alignment as text, as seen on the GUI, ie
210    * if columns are hidden they will not be returned in the result. Use this for
211    * calculating trees, PCA, redundancy etc on views which contain hidden
212    * columns.
213    * 
214    * @return String[]
215    */
216   CigarArray getViewAsCigars(boolean selectedRegionOnly);
217
218   /**
219    * return a compact representation of the current alignment selection to pass
220    * to an analysis function
221    * 
222    * @param selectedOnly
223    *          boolean true to just return the selected view
224    * @return AlignmentView
225    */
226   AlignmentView getAlignmentView(boolean selectedOnly);
227
228   /**
229    * return a compact representation of the current alignment selection to pass
230    * to an analysis function
231    * 
232    * @param selectedOnly
233    *          boolean true to just return the selected view
234    * @param markGroups
235    *          boolean true to annotate the alignment view with groups on the
236    *          alignment (and intersecting with selected region if selectedOnly
237    *          is true)
238    * @return AlignmentView
239    */
240   AlignmentView getAlignmentView(boolean selectedOnly, boolean markGroups);
241
242   /**
243    * This method returns the visible alignment as text, as seen on the GUI, ie
244    * if columns are hidden they will not be returned in the result. Use this for
245    * calculating trees, PCA, redundancy etc on views which contain hidden
246    * columns.
247    * 
248    * @return String[]
249    */
250   String[] getViewAsString(boolean selectedRegionOnly);
251
252   void setSelectionGroup(SequenceGroup sg);
253
254   char getGapCharacter();
255
256   void setColumnSelection(ColumnSelection cs);
257
258   void setConservation(Conservation cons);
259
260   /**
261    * get a copy of the currently visible alignment annotation
262    * @param selectedOnly if true - trim to selected regions on the alignment
263    * @return an empty list or new alignment annotation objects shown only visible columns trimmed to selected region only
264    */
265   List<AlignmentAnnotation> getVisibleAlignmentAnnotation(
266           boolean selectedOnly);
267
268   FeaturesDisplayedI getFeaturesDisplayed();
269
270   String getSequenceSetId();
271
272   boolean isShowSequenceFeatures();
273
274   void setShowSequenceFeatures(boolean b);
275
276   /**
277    * 
278    * @param flag
279    *          indicating if annotation panel shown below alignment
280    * 
281    */
282   void setShowAnnotation(boolean b);
283
284   /**
285    * flag indicating if annotation panel shown below alignment
286    * 
287    * @return
288    */
289   boolean isShowAnnotation();
290
291   boolean isRightAlignIds();
292
293   void setRightAlignIds(boolean rightAlignIds);
294
295   boolean areFeaturesDisplayed();
296
297   void setShowSequenceFeaturesHeight(boolean selected);
298
299   boolean isShowSequenceFeaturesHeight();
300
301   void setFeaturesDisplayed(FeaturesDisplayedI featuresDisplayedI);
302
303   void alignmentChanged(AlignmentViewPanel ap);
304
305   /**
306    * @return the padGaps
307    */
308   boolean isPadGaps();
309
310   /**
311    * @param padGaps
312    *          the padGaps to set
313    */
314   void setPadGaps(boolean padGaps);
315
316   /**
317    * return visible region boundaries within given column range
318    * 
319    * @param min
320    *          first column (inclusive, from 0)
321    * @param max
322    *          last column (exclusive)
323    * @return int[][] range of {start,end} visible positions TODO: change to list
324    *         of int ranges
325    */
326   int[][] getVisibleRegionBoundaries(int min, int max);
327
328   /**
329    * This method returns an array of new SequenceI objects derived from the
330    * whole alignment or just the current selection with start and end points
331    * adjusted
332    * 
333    * @note if you need references to the actual SequenceI objects in the
334    *       alignment or currently selected then use getSequenceSelection()
335    * @return selection as new sequenceI objects
336    */
337   SequenceI[] getSelectionAsNewSequence();
338
339   void invertColumnSelection();
340
341   /**
342    * broadcast selection to any interested parties
343    */
344   void sendSelection();
345
346   /**
347    * calculate the row position for alignmentIndex if all hidden sequences were
348    * shown
349    * 
350    * @param alignmentIndex
351    * @return adjusted row position
352    */
353   int adjustForHiddenSeqs(int alignmentIndex);
354
355   boolean hasHiddenRows();
356
357 }