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