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