1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import java.awt.BorderLayout; |
24 |
|
import java.awt.Color; |
25 |
|
import java.awt.Dimension; |
26 |
|
import java.awt.Font; |
27 |
|
import java.awt.Graphics; |
28 |
|
import java.awt.Graphics2D; |
29 |
|
import java.awt.RenderingHints; |
30 |
|
import java.io.File; |
31 |
|
import java.util.List; |
32 |
|
import java.util.Locale; |
33 |
|
import java.util.Map; |
34 |
|
import java.util.concurrent.Executors; |
35 |
|
|
36 |
|
import javax.swing.JPanel; |
37 |
|
import javax.swing.JSplitPane; |
38 |
|
import javax.swing.SwingUtilities; |
39 |
|
import javax.swing.event.InternalFrameAdapter; |
40 |
|
import javax.swing.event.InternalFrameEvent; |
41 |
|
|
42 |
|
import jalview.api.AlignmentViewPanel; |
43 |
|
import jalview.bin.Console; |
44 |
|
import jalview.datamodel.PDBEntry; |
45 |
|
import jalview.datamodel.SequenceI; |
46 |
|
import jalview.datamodel.StructureViewerModel; |
47 |
|
import jalview.datamodel.StructureViewerModel.StructureData; |
48 |
|
import jalview.ext.jmol.JmolCommands; |
49 |
|
import jalview.gui.ImageExporter.ImageWriterI; |
50 |
|
import jalview.gui.StructureViewer.ViewerType; |
51 |
|
import jalview.io.exceptions.ImageOutputException; |
52 |
|
import jalview.structure.StructureCommand; |
53 |
|
import jalview.structures.models.AAStructureBindingModel; |
54 |
|
import jalview.util.BrowserLauncher; |
55 |
|
import jalview.util.ImageMaker; |
56 |
|
import jalview.util.ImageMaker.TYPE; |
57 |
|
import jalview.util.MessageManager; |
58 |
|
import jalview.util.Platform; |
59 |
|
import jalview.util.imagemaker.BitmapImageSizing; |
60 |
|
|
|
|
| 65.8% |
Uncovered Elements: 91 (266) |
Complexity: 63 |
Complexity Density: 0.32 |
|
61 |
|
public class AppJmol extends StructureViewerBase |
62 |
|
{ |
63 |
|
|
64 |
|
private static final int JMOL_LOAD_TIMEOUT = 20000; |
65 |
|
|
66 |
|
private static final String SPACE = " "; |
67 |
|
|
68 |
|
private static final String QUOTE = "\""; |
69 |
|
|
70 |
|
AppJmolBinding jmb; |
71 |
|
|
72 |
|
JPanel scriptWindow; |
73 |
|
|
74 |
|
JSplitPane splitPane; |
75 |
|
|
76 |
|
RenderPanel renderPanel; |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
@param |
81 |
|
@param |
82 |
|
@param |
83 |
|
@param |
84 |
|
@param |
85 |
|
|
86 |
|
|
87 |
|
@param |
88 |
|
|
89 |
|
|
90 |
|
@param |
91 |
|
|
92 |
|
|
93 |
|
@param |
94 |
|
@param |
95 |
|
@param |
96 |
|
|
|
|
| 74.4% |
Uncovered Elements: 10 (39) |
Complexity: 5 |
Complexity Density: 0.15 |
|
97 |
7 |
public AppJmol(StructureViewerModel viewerModel, AlignmentPanel ap,... |
98 |
|
String sessionFile, String viewid) |
99 |
|
{ |
100 |
7 |
Map<File, StructureData> pdbData = viewerModel.getFileData(); |
101 |
7 |
PDBEntry[] pdbentrys = new PDBEntry[pdbData.size()]; |
102 |
7 |
SequenceI[][] seqs = new SequenceI[pdbData.size()][]; |
103 |
7 |
int i = 0; |
104 |
7 |
for (StructureData data : pdbData.values()) |
105 |
|
{ |
106 |
7 |
PDBEntry pdbentry = new PDBEntry(data.getPdbId(), null, |
107 |
|
PDBEntry.Type.PDB, data.getFilePath()); |
108 |
7 |
pdbentrys[i] = pdbentry; |
109 |
7 |
List<SequenceI> sequencesForPdb = data.getSeqList(); |
110 |
7 |
seqs[i] = sequencesForPdb |
111 |
|
.toArray(new SequenceI[sequencesForPdb.size()]); |
112 |
7 |
i++; |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
7 |
jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(), |
118 |
|
pdbentrys, seqs, null); |
119 |
|
|
120 |
7 |
jmb.setLoadingFromArchive(true); |
121 |
7 |
addAlignmentPanel(ap); |
122 |
7 |
if (viewerModel.isAlignWithPanel()) |
123 |
|
{ |
124 |
0 |
useAlignmentPanelForSuperposition(ap); |
125 |
|
} |
126 |
7 |
initMenus(); |
127 |
7 |
boolean useToColour = viewerModel.isColourWithAlignPanel(); |
128 |
7 |
boolean leaveColouringToJmol = viewerModel.isColourByViewer(); |
129 |
7 |
if (leaveColouringToJmol || !useToColour) |
130 |
|
{ |
131 |
7 |
jmb.setColourBySequence(false); |
132 |
7 |
seqColour.setSelected(false); |
133 |
7 |
viewerColour.setSelected(true); |
134 |
|
} |
135 |
0 |
else if (useToColour) |
136 |
|
{ |
137 |
0 |
useAlignmentPanelForColourbyseq(ap); |
138 |
0 |
jmb.setColourBySequence(true); |
139 |
0 |
seqColour.setSelected(true); |
140 |
0 |
viewerColour.setSelected(false); |
141 |
|
} |
142 |
|
|
143 |
7 |
this.setBounds(viewerModel.getX(), viewerModel.getY(), |
144 |
|
viewerModel.getWidth(), viewerModel.getHeight()); |
145 |
7 |
setViewId(viewid); |
146 |
|
|
147 |
7 |
this.addInternalFrameListener(new InternalFrameAdapter() |
148 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
149 |
7 |
@Override... |
150 |
|
public void internalFrameClosing( |
151 |
|
InternalFrameEvent internalFrameEvent) |
152 |
|
{ |
153 |
7 |
closeViewer(false); |
154 |
|
} |
155 |
|
}); |
156 |
7 |
StringBuilder cmd = new StringBuilder(); |
157 |
7 |
cmd.append(jmb.getCommandGenerator().loadFile(sessionFile)); |
158 |
7 |
initJmol(cmd.toString()); |
159 |
|
} |
160 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
161 |
45 |
@Override... |
162 |
|
protected void initMenus() |
163 |
|
{ |
164 |
45 |
super.initMenus(); |
165 |
|
|
166 |
45 |
viewerColour |
167 |
|
.setText(MessageManager.getString("label.colour_with_jmol")); |
168 |
45 |
viewerColour.setToolTipText(MessageManager |
169 |
|
.getString("label.let_jmol_manage_structure_colours")); |
170 |
|
} |
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
@param |
176 |
|
@param |
177 |
|
@param |
178 |
|
@param |
179 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
180 |
38 |
public AppJmol(PDBEntry pdbentry, SequenceI[] seq, String[] chains,... |
181 |
|
final AlignmentPanel ap) |
182 |
|
{ |
183 |
38 |
setProgressIndicator(ap.alignFrame); |
184 |
|
|
185 |
38 |
openNewJmol(ap, alignAddedStructures, new PDBEntry[] { pdbentry }, |
186 |
|
new SequenceI[][] |
187 |
|
{ seq }); |
188 |
|
} |
189 |
|
|
|
|
| 87.5% |
Uncovered Elements: 2 (16) |
Complexity: 2 |
Complexity Density: 0.14 |
|
190 |
38 |
private void openNewJmol(AlignmentPanel ap, boolean alignAdded,... |
191 |
|
PDBEntry[] pdbentrys, SequenceI[][] seqs) |
192 |
|
{ |
193 |
38 |
setProgressIndicator(ap.alignFrame); |
194 |
38 |
jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(), |
195 |
|
pdbentrys, seqs, null); |
196 |
38 |
addAlignmentPanel(ap); |
197 |
38 |
useAlignmentPanelForColourbyseq(ap); |
198 |
|
|
199 |
38 |
alignAddedStructures = alignAdded; |
200 |
38 |
if (pdbentrys.length > 1) |
201 |
|
{ |
202 |
0 |
useAlignmentPanelForSuperposition(ap); |
203 |
|
} |
204 |
|
|
205 |
38 |
jmb.setColourBySequence(true); |
206 |
38 |
setSize(400, 400); |
207 |
38 |
initMenus(); |
208 |
38 |
addingStructures = false; |
209 |
38 |
worker = new Thread(this); |
210 |
38 |
worker.start(); |
211 |
|
|
212 |
38 |
this.addInternalFrameListener(new InternalFrameAdapter() |
213 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
214 |
14 |
@Override... |
215 |
|
public void internalFrameClosing( |
216 |
|
InternalFrameEvent internalFrameEvent) |
217 |
|
{ |
218 |
14 |
closeViewer(false); |
219 |
|
} |
220 |
|
}); |
221 |
|
|
222 |
|
} |
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
@param |
229 |
|
@param |
230 |
|
|
231 |
|
@param |
232 |
|
@param |
233 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
234 |
0 |
public AppJmol(AlignmentPanel ap, boolean alignAdded, PDBEntry[] pe,... |
235 |
|
SequenceI[][] seqs) |
236 |
|
{ |
237 |
0 |
openNewJmol(ap, alignAdded, pe, seqs); |
238 |
|
} |
239 |
|
|
|
|
| 85.7% |
Uncovered Elements: 3 (21) |
Complexity: 3 |
Complexity Density: 0.18 |
|
240 |
45 |
void initJmol(String command)... |
241 |
|
{ |
242 |
45 |
jmb.setFinishedInit(false); |
243 |
45 |
renderPanel = new RenderPanel(); |
244 |
|
|
245 |
|
|
246 |
45 |
this.getContentPane().add(renderPanel, java.awt.BorderLayout.CENTER); |
247 |
45 |
jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(), |
248 |
|
getBounds().width, getBounds().height); |
249 |
45 |
if (scriptWindow == null) |
250 |
|
{ |
251 |
45 |
BorderLayout bl = new BorderLayout(); |
252 |
45 |
bl.setHgap(0); |
253 |
45 |
bl.setVgap(0); |
254 |
45 |
scriptWindow = new JPanel(bl); |
255 |
45 |
scriptWindow.setVisible(false); |
256 |
|
} |
257 |
|
|
258 |
45 |
jmb.allocateViewer(renderPanel, true, "", null, null, "", scriptWindow, |
259 |
|
null); |
260 |
|
|
261 |
45 |
if (command == null) |
262 |
|
{ |
263 |
0 |
command = ""; |
264 |
|
} |
265 |
45 |
jmb.executeCommand(new StructureCommand(command), false); |
266 |
45 |
jmb.executeCommand(new StructureCommand("set hoverDelay=0.1"), false); |
267 |
45 |
jmb.executeCommand(new StructureCommand("set antialiasdisplay on"), |
268 |
|
false); |
269 |
45 |
jmb.setFinishedInit(true); |
270 |
|
} |
271 |
|
|
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
272 |
39 |
@Override... |
273 |
|
public void run() |
274 |
|
{ |
275 |
39 |
_started = true; |
276 |
39 |
try |
277 |
|
{ |
278 |
39 |
List<String> files = jmb.fetchPdbFiles(this); |
279 |
39 |
if (files.size() > 0) |
280 |
|
{ |
281 |
39 |
showFilesInViewer(files); |
282 |
|
} |
283 |
|
} finally |
284 |
|
{ |
285 |
39 |
_started = false; |
286 |
39 |
worker = null; |
287 |
|
} |
288 |
|
} |
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
|
293 |
|
|
294 |
|
@param |
295 |
|
|
296 |
|
|
|
|
| 72.2% |
Uncovered Elements: 15 (54) |
Complexity: 13 |
Complexity Density: 0.3 |
|
297 |
39 |
void showFilesInViewer(List<String> files)... |
298 |
|
{ |
299 |
39 |
long lastnotify = jmb.getLoadNotifiesHandled(); |
300 |
39 |
StringBuilder fileList = new StringBuilder(); |
301 |
39 |
for (String s : files) |
302 |
|
{ |
303 |
39 |
fileList.append(SPACE).append(QUOTE) |
304 |
|
.append(JmolCommands.escapeQuotedFilename(s)).append(QUOTE); |
305 |
|
} |
306 |
39 |
String filesString = fileList.toString(); |
307 |
|
|
308 |
39 |
if (!addingStructures) |
309 |
|
{ |
310 |
38 |
try |
311 |
|
{ |
312 |
38 |
initJmol("load FILES " + filesString); |
313 |
|
} catch (OutOfMemoryError oomerror) |
314 |
|
{ |
315 |
0 |
new OOMWarning("When trying to open the Jmol viewer!", oomerror); |
316 |
0 |
Console.debug("File locations are " + filesString); |
317 |
|
} catch (Exception ex) |
318 |
|
{ |
319 |
0 |
Console.error("Couldn't open Jmol viewer!", ex); |
320 |
0 |
ex.printStackTrace(); |
321 |
0 |
return; |
322 |
|
} |
323 |
|
} |
324 |
|
else |
325 |
|
{ |
326 |
1 |
StringBuilder cmd = new StringBuilder(); |
327 |
1 |
cmd.append("loadingJalviewdata=true\nload APPEND "); |
328 |
1 |
cmd.append(filesString); |
329 |
1 |
cmd.append("\nloadingJalviewdata=null"); |
330 |
1 |
final StructureCommand command = new StructureCommand(cmd.toString()); |
331 |
1 |
lastnotify = jmb.getLoadNotifiesHandled(); |
332 |
|
|
333 |
1 |
try |
334 |
|
{ |
335 |
1 |
jmb.executeCommand(command, false); |
336 |
|
} catch (OutOfMemoryError oomerror) |
337 |
|
{ |
338 |
0 |
new OOMWarning("When trying to add structures to the Jmol viewer!", |
339 |
|
oomerror); |
340 |
0 |
Console.debug("File locations are " + filesString); |
341 |
0 |
return; |
342 |
|
} catch (Exception ex) |
343 |
|
{ |
344 |
0 |
Console.error("Couldn't add files to Jmol viewer!", ex); |
345 |
0 |
ex.printStackTrace(); |
346 |
0 |
return; |
347 |
|
} |
348 |
|
} |
349 |
|
|
350 |
|
|
351 |
39 |
int waitMax = JMOL_LOAD_TIMEOUT; |
352 |
39 |
int waitFor = 35; |
353 |
39 |
int waitTotal = 0; |
354 |
137 |
while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled() |
355 |
|
: !(jmb.isFinishedInit() && jmb.getStructureFiles() != null |
356 |
|
&& jmb.getStructureFiles().length == files.size())) |
357 |
|
{ |
358 |
98 |
try |
359 |
|
{ |
360 |
98 |
Console.debug("Waiting around for jmb notify."); |
361 |
98 |
waitTotal += waitFor; |
362 |
|
|
363 |
|
|
364 |
98 |
Thread.sleep(waitFor); |
365 |
|
} catch (Exception e) |
366 |
|
{ |
367 |
|
} |
368 |
98 |
if (waitTotal > waitMax) |
369 |
|
{ |
370 |
0 |
jalview.bin.Console.errPrintln( |
371 |
|
"Timed out waiting for Jmol to load files after " |
372 |
|
+ waitTotal + "ms"); |
373 |
|
|
374 |
|
|
375 |
|
|
376 |
0 |
jmb.getStructureFiles(); |
377 |
0 |
break; |
378 |
|
} |
379 |
|
} |
380 |
|
|
381 |
|
|
382 |
39 |
for (AlignmentViewPanel ap : _colourwith) |
383 |
|
{ |
384 |
39 |
jmb.updateColours(ap); |
385 |
|
} |
386 |
|
|
387 |
36 |
if (alignAddedStructures) |
388 |
|
{ |
389 |
1 |
alignAddedStructures(); |
390 |
|
} |
391 |
36 |
addingStructures = false; |
392 |
|
} |
393 |
|
|
394 |
|
|
395 |
|
|
396 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
397 |
1 |
void alignAddedStructures()... |
398 |
|
{ |
399 |
1 |
javax.swing.SwingUtilities.invokeLater(new Runnable() |
400 |
|
{ |
|
|
| 37.5% |
Uncovered Elements: 5 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
401 |
1 |
@Override... |
402 |
|
public void run() |
403 |
|
{ |
404 |
1 |
if (jmb.jmolViewer.isScriptExecuting()) |
405 |
|
{ |
406 |
0 |
SwingUtilities.invokeLater(this); |
407 |
0 |
try |
408 |
|
{ |
409 |
0 |
Thread.sleep(5); |
410 |
|
} catch (InterruptedException q) |
411 |
|
{ |
412 |
|
} |
413 |
0 |
return; |
414 |
|
} |
415 |
|
else |
416 |
|
{ |
417 |
1 |
alignStructsWithAllAlignPanels(); |
418 |
|
} |
419 |
|
} |
420 |
|
}); |
421 |
|
|
422 |
|
} |
423 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
424 |
0 |
public boolean isRepainting()... |
425 |
|
{ |
426 |
0 |
if (renderPanel != null && renderPanel.isVisible()) |
427 |
|
{ |
428 |
0 |
return renderPanel.repainting; |
429 |
|
} |
430 |
0 |
return false; |
431 |
|
} |
432 |
|
|
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
@param |
439 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 4 |
Complexity Density: 0.67 |
|
440 |
0 |
@Override... |
441 |
|
public void makePDBImage(ImageMaker.TYPE type) |
442 |
|
{ |
443 |
0 |
while (!isRepainting()) |
444 |
|
{ |
445 |
0 |
try |
446 |
|
{ |
447 |
0 |
Thread.sleep(2); |
448 |
|
} catch (Exception q) |
449 |
|
{ |
450 |
|
} |
451 |
|
} |
452 |
0 |
try |
453 |
|
{ |
454 |
0 |
makePDBImage(null, type, null, |
455 |
|
BitmapImageSizing.defaultBitmapImageSizing()); |
456 |
|
} catch (ImageOutputException ioex) |
457 |
|
{ |
458 |
0 |
Console.error("Unexpected error whilst writing " + type.toString(), |
459 |
|
ioex); |
460 |
|
} |
461 |
|
} |
462 |
|
|
|
|
| 70.6% |
Uncovered Elements: 10 (34) |
Complexity: 7 |
Complexity Density: 0.27 |
|
463 |
10 |
public void makePDBImage(File file, ImageMaker.TYPE type, String renderer,... |
464 |
|
BitmapImageSizing userBis) throws ImageOutputException |
465 |
|
{ |
466 |
10 |
int width = getWidth(); |
467 |
10 |
int height = getHeight(); |
468 |
|
|
469 |
10 |
BitmapImageSizing bis = ImageMaker.getScaleWidthHeight(width, height, |
470 |
|
userBis); |
471 |
10 |
float usescale = bis.scale(); |
472 |
10 |
int usewidth = bis.width(); |
473 |
10 |
int useheight = bis.height(); |
474 |
|
|
475 |
10 |
ImageWriterI writer = new ImageWriterI() |
476 |
|
{ |
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
477 |
10 |
@Override... |
478 |
|
public void exportImage(Graphics g) throws Exception |
479 |
|
{ |
480 |
10 |
Graphics2D ig2 = (Graphics2D) g; |
481 |
10 |
ig2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, |
482 |
|
RenderingHints.VALUE_ANTIALIAS_ON); |
483 |
10 |
if (type == TYPE.PNG && usescale > 0.0f) |
484 |
|
{ |
485 |
|
|
486 |
|
|
487 |
4 |
if (usescale > 0.0f) |
488 |
|
{ |
489 |
4 |
ig2.scale(1 / usescale, 1 / usescale); |
490 |
|
} |
491 |
|
} |
492 |
|
|
493 |
10 |
jmb.jmolViewer.requestRepaintAndWait("image export"); |
494 |
10 |
jmb.jmolViewer.renderScreenImage(ig2, usewidth, useheight); |
495 |
|
} |
496 |
|
}; |
497 |
10 |
String view = MessageManager.getString("action.view") |
498 |
|
.toLowerCase(Locale.ROOT); |
499 |
10 |
final ImageExporter exporter = new ImageExporter(writer, |
500 |
|
getProgressIndicator(), type, getTitle()); |
501 |
|
|
502 |
10 |
final Throwable[] exceptions = new Throwable[1]; |
503 |
10 |
exceptions[0] = null; |
504 |
10 |
final AppJmol us = this; |
505 |
10 |
try |
506 |
|
{ |
507 |
10 |
Thread runner = Executors.defaultThreadFactory() |
508 |
|
.newThread(new Runnable() |
509 |
|
{ |
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
510 |
10 |
@Override... |
511 |
|
public void run() |
512 |
|
{ |
513 |
10 |
try |
514 |
|
{ |
515 |
10 |
exporter.doExport(file, us, width, height, view, |
516 |
|
renderer, userBis); |
517 |
|
} catch (Throwable t) |
518 |
|
{ |
519 |
0 |
exceptions[0] = t; |
520 |
|
} |
521 |
|
} |
522 |
|
}); |
523 |
10 |
runner.start(); |
524 |
10 |
long time = 0; |
525 |
10 |
do |
526 |
|
{ |
527 |
417 |
Thread.sleep(25); |
528 |
417 |
} while (runner.isAlive() && time++ < 4000); |
529 |
10 |
if (time >= 4000) |
530 |
|
{ |
531 |
0 |
runner.interrupt(); |
532 |
0 |
throw new ImageOutputException( |
533 |
|
"Jmol took too long to export. Waited for 100 seconds."); |
534 |
|
} |
535 |
|
} catch (Throwable e) |
536 |
|
{ |
537 |
0 |
throw new ImageOutputException( |
538 |
|
"Unexpected error when generating image", e); |
539 |
|
} |
540 |
10 |
if (exceptions[0] != null) |
541 |
|
{ |
542 |
0 |
if (exceptions[0] instanceof ImageOutputException) |
543 |
|
{ |
544 |
0 |
throw ((ImageOutputException) exceptions[0]); |
545 |
|
} |
546 |
|
else |
547 |
|
{ |
548 |
0 |
throw new ImageOutputException( |
549 |
|
"Unexpected error when generating image", exceptions[0]); |
550 |
|
} |
551 |
|
} |
552 |
|
} |
553 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
554 |
0 |
@Override... |
555 |
|
public void showHelp_actionPerformed() |
556 |
|
{ |
557 |
0 |
try |
558 |
|
{ |
559 |
0 |
BrowserLauncher |
560 |
|
.openURL("http://wiki.jmol.org"); |
561 |
|
} catch (Exception ex) |
562 |
|
{ |
563 |
0 |
jalview.bin.Console |
564 |
|
.errPrintln("Show Jmol help failed with: " + ex.getMessage()); |
565 |
|
} |
566 |
|
} |
567 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 4 |
Complexity Density: 0.27 |
|
568 |
0 |
@Override... |
569 |
|
public void showConsole(boolean showConsole) |
570 |
|
{ |
571 |
0 |
if (showConsole) |
572 |
|
{ |
573 |
0 |
if (splitPane == null) |
574 |
|
{ |
575 |
0 |
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); |
576 |
0 |
splitPane.setTopComponent(renderPanel); |
577 |
0 |
splitPane.setBottomComponent(scriptWindow); |
578 |
0 |
this.getContentPane().add(splitPane, BorderLayout.CENTER); |
579 |
0 |
splitPane.setDividerLocation(getHeight() - 200); |
580 |
0 |
scriptWindow.setVisible(true); |
581 |
0 |
scriptWindow.validate(); |
582 |
0 |
splitPane.validate(); |
583 |
|
} |
584 |
|
|
585 |
|
} |
586 |
|
else |
587 |
|
{ |
588 |
0 |
if (splitPane != null) |
589 |
|
{ |
590 |
0 |
splitPane.setVisible(false); |
591 |
|
} |
592 |
|
|
593 |
0 |
splitPane = null; |
594 |
|
|
595 |
0 |
this.getContentPane().add(renderPanel, BorderLayout.CENTER); |
596 |
|
} |
597 |
|
|
598 |
0 |
validate(); |
599 |
|
} |
600 |
|
|
|
|
| 43.2% |
Uncovered Elements: 21 (37) |
Complexity: 10 |
Complexity Density: 0.38 |
|
601 |
|
class RenderPanel extends JPanel |
602 |
|
{ |
603 |
|
final Dimension currentSize = new Dimension(); |
604 |
|
|
|
|
| 41.7% |
Uncovered Elements: 21 (36) |
Complexity: 10 |
Complexity Density: 0.38 |
|
605 |
319 |
@Override... |
606 |
|
public void paintComponent(Graphics g) |
607 |
|
{ |
608 |
319 |
getSize(currentSize); |
609 |
|
|
610 |
319 |
if (jmb != null && jmb.hasFileLoadingError()) |
611 |
|
{ |
612 |
0 |
g.setColor(Color.black); |
613 |
0 |
g.fillRect(0, 0, currentSize.width, currentSize.height); |
614 |
0 |
g.setColor(Color.white); |
615 |
0 |
g.setFont(new Font("Verdana", Font.BOLD, 14)); |
616 |
0 |
g.drawString(MessageManager.getString("label.error_loading_file") |
617 |
|
+ "...", 20, currentSize.height / 2); |
618 |
0 |
StringBuffer sb = new StringBuffer(); |
619 |
0 |
int lines = 0; |
620 |
0 |
for (int e = 0; e < jmb.getPdbCount(); e++) |
621 |
|
{ |
622 |
0 |
sb.append(jmb.getPdbEntry(e).getId()); |
623 |
0 |
if (e < jmb.getPdbCount() - 1) |
624 |
|
{ |
625 |
0 |
sb.append(","); |
626 |
|
} |
627 |
|
|
628 |
0 |
if (e == jmb.getPdbCount() - 1 || sb.length() > 20) |
629 |
|
{ |
630 |
0 |
lines++; |
631 |
0 |
g.drawString(sb.toString(), 20, currentSize.height / 2 |
632 |
|
- lines * g.getFontMetrics().getHeight()); |
633 |
|
} |
634 |
|
} |
635 |
|
} |
636 |
319 |
else if (jmb == null || jmb.jmolViewer == null |
637 |
|
|| !jmb.isFinishedInit()) |
638 |
|
{ |
639 |
26 |
g.setColor(Color.black); |
640 |
26 |
g.fillRect(0, 0, currentSize.width, currentSize.height); |
641 |
26 |
g.setColor(Color.white); |
642 |
26 |
g.setFont(new Font("Verdana", Font.BOLD, 14)); |
643 |
26 |
g.drawString(MessageManager.getString("label.retrieving_pdb_data"), |
644 |
|
20, currentSize.height / 2); |
645 |
|
} |
646 |
|
else |
647 |
|
{ |
648 |
293 |
repainting = true; |
649 |
293 |
synchronized (jmb) |
650 |
|
{ |
651 |
293 |
jmb.jmolViewer.renderScreenImage(g, currentSize.width, |
652 |
|
currentSize.height); |
653 |
|
|
654 |
|
} |
655 |
293 |
repainting = false; |
656 |
|
} |
657 |
|
} |
658 |
|
|
659 |
|
volatile boolean repainting = false; |
660 |
|
} |
661 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
662 |
1513 |
@Override... |
663 |
|
public AAStructureBindingModel getBinding() |
664 |
|
{ |
665 |
1513 |
return this.jmb; |
666 |
|
} |
667 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
668 |
68 |
@Override... |
669 |
|
public ViewerType getViewerType() |
670 |
|
{ |
671 |
68 |
return ViewerType.JMOL; |
672 |
|
} |
673 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
674 |
139 |
@Override... |
675 |
|
protected String getViewerName() |
676 |
|
{ |
677 |
139 |
return "Jmol"; |
678 |
|
} |
679 |
|
} |