Merge branch 'develop' into releases/Release_2_11_3_Branch
[jalview.git] / src / jalview / api / structures / JalviewStructureDisplayI.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.structures;
22
23 import java.io.File;
24
25 import jalview.api.AlignmentViewPanel;
26 import jalview.datamodel.PDBEntry;
27 import jalview.datamodel.SequenceI;
28 import jalview.gui.AlignmentPanel;
29 import jalview.gui.StructureViewer;
30 import jalview.structures.models.AAStructureBindingModel;
31
32 public interface JalviewStructureDisplayI
33 {
34
35   AAStructureBindingModel getBinding();
36
37   /**
38    * @return true if there is an active GUI handling a structure display
39    */
40   boolean isVisible();
41
42   /**
43    * enable or disable the structure display - note this might just hide or show
44    * a GUI element, but not actually reset the display
45    * 
46    * @param b
47    */
48   void setVisible(boolean b);
49
50   /**
51    * free up any external resources that were used by this display and collect
52    * garbage
53    */
54   void dispose();
55
56   /**
57    * Shutdown any Jalview structure viewing processes started by this display
58    * 
59    * @param closeExternalViewer
60    *          if true, force close any linked external viewer process
61    */
62   void closeViewer(boolean closeExternalViewer);
63
64   /**
65    * Check if the external viewer is still running
66    */
67   boolean stillRunning();
68
69   /**
70    * 
71    * @return true if all background sequence/structure binding threads have
72    *         completed for this viewer instance
73    */
74   boolean hasMapping();
75
76   /**
77    * Checks if the PDB file is already loaded in this viewer, if so just adds
78    * mappings as necessary and answers true, else answers false. This supports
79    * the use case of adding additional chains of the same structure to a viewer.
80    * 
81    * @param seq
82    * @param chains
83    * @param apanel
84    * @param pdbId
85    * @return
86    */
87   boolean addAlreadyLoadedFile(SequenceI[] seq, String[] chains,
88           AlignmentViewPanel apanel, String pdbId);
89
90   /**
91    * Adds one or more chains (sequences) of a PDB structure to this structure
92    * viewer
93    * 
94    * @param pdbentry
95    * @param seq
96    * @param chains
97    * @param apanel
98    * @param pdbId
99    * @return
100    */
101   void addToExistingViewer(PDBEntry pdbentry, SequenceI[] seq,
102           String[] chains, AlignmentViewPanel apanel, String pdbId);
103
104   /**
105    * refresh GUI after reconfiguring structure(s) and alignment panels
106    */
107   void updateTitleAndMenus();
108
109   /**
110    * Answers true if the viewer should attempt to align any added structures,
111    * else false
112    * 
113    * @return
114    */
115   boolean isAlignAddedStructures();
116
117   /**
118    * Sets the flag for whether added structures should be aligned
119    * 
120    * @param alignAdded
121    */
122   void setAlignAddedStructures(boolean alignAdded);
123
124   /**
125    * Raise the panel to the top of the stack...
126    */
127   void raiseViewer();
128
129   AlignmentViewPanel getAlignmentPanel();
130
131   /**
132    * Answers true if the given alignment view is used to colour structures by
133    * sequence, false if not
134    * 
135    * @param ap
136    * @return
137    */
138   boolean isUsedForColourBy(AlignmentViewPanel ap);
139
140   /**
141    * If implemented, shows a command line console in the structure viewer
142    * 
143    * @param show
144    *          true to show, false to hide
145    */
146   void showConsole(boolean show);
147
148   /**
149    * Remove references to the given alignment view for this structure viewer
150    * 
151    * @param avp
152    */
153   void removeAlignmentPanel(AlignmentViewPanel avp);
154
155   /**
156    * Updates the progress bar if there is one. Call stopProgressBar with the
157    * returned handle to remove the message.
158    * 
159    * @param msg
160    * @return handle
161    */
162   long startProgressBar(String msg);
163
164   /**
165    * Ends the progress bar with the specified handle, leaving a message (if not
166    * null) on the status bar
167    * 
168    * @param msg
169    * @param handle
170    */
171   void stopProgressBar(String msg, long handle);
172
173   /**
174    * 
175    * @return true if the actions menu is shown for this viewer
176    */
177   boolean hasViewerActionsMenu();
178
179   String getViewId();
180
181   StructureViewer.ViewerType getViewerType();
182
183   boolean isUsedforaligment(AlignmentViewPanel ap);
184
185   boolean isColouredByViewer();
186
187   int getHeight();
188
189   int getWidth();
190
191   int getY();
192
193   File saveSession();
194
195 }