1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.io; |
22 |
|
|
23 |
|
import jalview.api.ComplexAlignFile; |
24 |
|
import jalview.api.FeatureSettingsModelI; |
25 |
|
import jalview.api.FeaturesDisplayedI; |
26 |
|
import jalview.api.FeaturesSourceI; |
27 |
|
import jalview.bin.Cache; |
28 |
|
import jalview.bin.Jalview; |
29 |
|
import jalview.datamodel.AlignmentI; |
30 |
|
import jalview.datamodel.HiddenColumns; |
31 |
|
import jalview.datamodel.PDBEntry; |
32 |
|
import jalview.datamodel.SequenceI; |
33 |
|
import jalview.gui.AlignFrame; |
34 |
|
import jalview.gui.AlignViewport; |
35 |
|
import jalview.gui.Desktop; |
36 |
|
import jalview.gui.Jalview2XML; |
37 |
|
import jalview.gui.JvOptionPane; |
38 |
|
import jalview.json.binding.biojson.v1.ColourSchemeMapper; |
39 |
|
import jalview.schemes.ColourSchemeI; |
40 |
|
import jalview.structure.StructureSelectionManager; |
41 |
|
import jalview.util.MessageManager; |
42 |
|
import jalview.ws.utils.UrlDownloadClient; |
43 |
|
|
44 |
|
import java.io.BufferedReader; |
45 |
|
import java.io.ByteArrayInputStream; |
46 |
|
import java.io.File; |
47 |
|
import java.io.FileNotFoundException; |
48 |
|
import java.io.FileReader; |
49 |
|
import java.io.IOException; |
50 |
|
import java.io.InputStream; |
51 |
|
import java.io.InputStreamReader; |
52 |
|
import java.util.StringTokenizer; |
53 |
|
import java.util.Vector; |
54 |
|
|
55 |
|
import javax.swing.SwingUtilities; |
56 |
|
|
|
|
| 58.5% |
Uncovered Elements: 114 (275) |
Complexity: 71 |
Complexity Density: 0.41 |
|
57 |
|
public class FileLoader implements Runnable |
58 |
|
{ |
59 |
|
String file; |
60 |
|
|
61 |
|
DataSourceType protocol; |
62 |
|
|
63 |
|
FileFormatI format; |
64 |
|
|
65 |
|
AlignmentFileReaderI source = null; |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
AlignViewport viewport; |
71 |
|
|
72 |
|
AlignFrame alignFrame; |
73 |
|
|
74 |
|
long loadtime; |
75 |
|
|
76 |
|
long memused; |
77 |
|
|
78 |
|
boolean raiseGUI = true; |
79 |
|
|
80 |
|
private File selectedFile; |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
85 |
70 |
public FileLoader()... |
86 |
|
{ |
87 |
70 |
this(true); |
88 |
|
} |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
@param |
94 |
|
|
95 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
96 |
97 |
public FileLoader(boolean raiseGUI)... |
97 |
|
{ |
98 |
97 |
this.raiseGUI = raiseGUI; |
99 |
|
} |
100 |
|
|
|
|
| 57.1% |
Uncovered Elements: 3 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
101 |
1 |
public void LoadFile(AlignViewport viewport, Object file,... |
102 |
|
DataSourceType protocol, FileFormatI format) |
103 |
|
{ |
104 |
1 |
this.viewport = viewport; |
105 |
1 |
if (file instanceof File) { |
106 |
0 |
this.selectedFile = (File) file; |
107 |
0 |
file = selectedFile.getPath(); |
108 |
|
} |
109 |
1 |
LoadFile(file.toString(), protocol, format); |
110 |
|
} |
111 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
112 |
1 |
public void LoadFile(String file, DataSourceType protocol,... |
113 |
|
FileFormatI format) |
114 |
|
{ |
115 |
1 |
this.file = file; |
116 |
1 |
this.protocol = protocol; |
117 |
1 |
this.format = format; |
118 |
|
|
119 |
1 |
final Thread loader = new Thread(this); |
120 |
|
|
121 |
1 |
SwingUtilities.invokeLater(new Runnable() |
122 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
123 |
1 |
@Override... |
124 |
|
public void run() |
125 |
|
{ |
126 |
1 |
loader.start(); |
127 |
|
} |
128 |
|
}); |
129 |
|
} |
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
@param |
135 |
|
@param |
136 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
137 |
0 |
public void LoadFile(String file, DataSourceType protocol)... |
138 |
|
{ |
139 |
0 |
LoadFile(file, protocol, null); |
140 |
|
} |
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
@param |
146 |
|
@param |
147 |
|
@return |
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
149 |
84 |
public AlignFrame LoadFileWaitTillLoaded(String file,... |
150 |
|
DataSourceType sourceType) |
151 |
|
{ |
152 |
84 |
return LoadFileWaitTillLoaded(file, sourceType, null); |
153 |
|
} |
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
@param |
159 |
|
@param |
160 |
|
@param |
161 |
|
@return |
162 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
163 |
89 |
public AlignFrame LoadFileWaitTillLoaded(String file,... |
164 |
|
DataSourceType sourceType, FileFormatI format) |
165 |
|
{ |
166 |
89 |
this.file = file; |
167 |
89 |
this.protocol = sourceType; |
168 |
89 |
this.format = format; |
169 |
89 |
return _LoadFileWaitTillLoaded(); |
170 |
|
} |
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
@param |
176 |
|
@param |
177 |
|
@param |
178 |
|
@return |
179 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
180 |
0 |
public AlignFrame LoadFileWaitTillLoaded(File file,... |
181 |
|
DataSourceType sourceType, FileFormatI format) |
182 |
|
{ |
183 |
0 |
this.selectedFile = file; |
184 |
0 |
this.file = file.getPath(); |
185 |
0 |
this.protocol = sourceType; |
186 |
0 |
this.format = format; |
187 |
0 |
return _LoadFileWaitTillLoaded(); |
188 |
|
} |
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
@param |
194 |
|
@param |
195 |
|
@return |
196 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
197 |
0 |
public AlignFrame LoadFileWaitTillLoaded(AlignmentFileReaderI source,... |
198 |
|
FileFormatI format) |
199 |
|
{ |
200 |
0 |
this.source = source; |
201 |
|
|
202 |
0 |
file = source.getInFile(); |
203 |
0 |
protocol = source.getDataSourceType(); |
204 |
0 |
this.format = format; |
205 |
0 |
return _LoadFileWaitTillLoaded(); |
206 |
|
} |
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
@return |
213 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
214 |
89 |
protected AlignFrame _LoadFileWaitTillLoaded()... |
215 |
|
{ |
216 |
89 |
this.run(); |
217 |
89 |
return alignFrame; |
218 |
|
} |
219 |
|
|
|
|
| 97.3% |
Uncovered Elements: 1 (37) |
Complexity: 11 |
Complexity Density: 0.52 |
|
220 |
89 |
public void updateRecentlyOpened()... |
221 |
|
{ |
222 |
89 |
Vector<String> recent = new Vector<>(); |
223 |
89 |
if (protocol == DataSourceType.PASTE) |
224 |
|
{ |
225 |
|
|
226 |
|
|
227 |
32 |
return; |
228 |
|
} |
229 |
57 |
if (file != null |
230 |
|
&& file.indexOf(System.getProperty("java.io.tmpdir")) > -1) |
231 |
|
{ |
232 |
|
|
233 |
10 |
return; |
234 |
|
} |
235 |
47 |
String type = protocol == DataSourceType.FILE ? "RECENT_FILE" |
236 |
|
: "RECENT_URL"; |
237 |
|
|
238 |
47 |
String historyItems = Cache.getProperty(type); |
239 |
|
|
240 |
47 |
StringTokenizer st; |
241 |
|
|
242 |
47 |
if (historyItems != null) |
243 |
|
{ |
244 |
47 |
st = new StringTokenizer(historyItems, "\t"); |
245 |
|
|
246 |
185 |
while (st.hasMoreTokens()) |
247 |
|
{ |
248 |
138 |
recent.addElement(st.nextToken().trim()); |
249 |
|
} |
250 |
|
} |
251 |
|
|
252 |
47 |
if (recent.contains(file)) |
253 |
|
{ |
254 |
37 |
recent.remove(file); |
255 |
|
} |
256 |
|
|
257 |
47 |
StringBuffer newHistory = new StringBuffer(file); |
258 |
148 |
for (int i = 0; i < recent.size() && i < 10; i++) |
259 |
|
{ |
260 |
101 |
newHistory.append("\t"); |
261 |
101 |
newHistory.append(recent.elementAt(i)); |
262 |
|
} |
263 |
|
|
264 |
47 |
Cache.setProperty(type, newHistory.toString()); |
265 |
|
|
266 |
47 |
if (protocol == DataSourceType.FILE) |
267 |
|
{ |
268 |
43 |
Cache.setProperty("DEFAULT_FILE_FORMAT", format.getName()); |
269 |
|
} |
270 |
|
} |
271 |
|
|
|
|
| 54.4% |
Uncovered Elements: 77 (169) |
Complexity: 41 |
Complexity Density: 0.38 |
|
272 |
90 |
@Override... |
273 |
|
public void run() |
274 |
|
{ |
275 |
90 |
String title = protocol == DataSourceType.PASTE |
276 |
|
? "Copied From Clipboard" |
277 |
|
: file; |
278 |
90 |
Runtime rt = Runtime.getRuntime(); |
279 |
90 |
try |
280 |
|
{ |
281 |
90 |
if (Desktop.instance != null) |
282 |
|
{ |
283 |
89 |
Desktop.instance.startLoading(file); |
284 |
|
} |
285 |
90 |
if (format == null) |
286 |
|
{ |
287 |
|
|
288 |
84 |
if (source != null) |
289 |
|
{ |
290 |
0 |
format = new IdentifyFile().identify(source, false); |
291 |
|
|
292 |
|
} |
293 |
84 |
else if (selectedFile != null) { |
294 |
0 |
format = new IdentifyFile().identify(selectedFile, protocol); |
295 |
|
} |
296 |
|
else |
297 |
|
{ |
298 |
84 |
format = new IdentifyFile().identify(file, protocol); |
299 |
|
} |
300 |
|
|
301 |
|
} |
302 |
|
|
303 |
89 |
if (format == null) |
304 |
|
{ |
305 |
0 |
Desktop.instance.stopLoading(); |
306 |
0 |
System.err.println("The input file \"" + file |
307 |
|
+ "\" has null or unidentifiable data content!"); |
308 |
0 |
if (!Jalview.isHeadlessMode()) |
309 |
|
{ |
310 |
0 |
JvOptionPane.showInternalMessageDialog(Desktop.desktop, |
311 |
|
MessageManager.getString("label.couldnt_read_data") |
312 |
|
+ " in " + file + "\n" |
313 |
|
+ AppletFormatAdapter.getSupportedFormats(), |
314 |
|
MessageManager.getString("label.couldnt_read_data"), |
315 |
|
JvOptionPane.WARNING_MESSAGE); |
316 |
|
} |
317 |
0 |
return; |
318 |
|
} |
319 |
|
|
320 |
|
|
321 |
89 |
if (Desktop.desktop != null && Desktop.desktop.isShowMemoryUsage()) |
322 |
|
{ |
323 |
0 |
System.gc(); |
324 |
0 |
memused = (rt.maxMemory() - rt.totalMemory() + rt.freeMemory()); |
325 |
|
|
326 |
|
|
327 |
|
|
328 |
|
} |
329 |
89 |
loadtime = -System.currentTimeMillis(); |
330 |
89 |
AlignmentI al = null; |
331 |
|
|
332 |
89 |
if (FileFormat.Jalview.equals(format)) |
333 |
|
{ |
334 |
20 |
if (source != null) |
335 |
|
{ |
336 |
|
|
337 |
0 |
System.err.println( |
338 |
|
"IMPLEMENTATION ERROR: Cannot read consecutive Jalview XML projects from a stream."); |
339 |
|
|
340 |
|
} |
341 |
20 |
alignFrame = new Jalview2XML(raiseGUI).loadJalviewAlign(file); |
342 |
|
} |
343 |
|
else |
344 |
|
{ |
345 |
69 |
String error = AppletFormatAdapter.getSupportedFormats(); |
346 |
69 |
try |
347 |
|
{ |
348 |
69 |
if (source != null) |
349 |
|
{ |
350 |
|
|
351 |
0 |
al = new FormatAdapter().readFromFile(source, format); |
352 |
|
} |
353 |
|
else |
354 |
|
{ |
355 |
|
|
356 |
|
|
357 |
69 |
FormatAdapter fa = new FormatAdapter(); |
358 |
69 |
boolean downloadStructureFile = format.isStructureFile() |
359 |
|
&& protocol.equals(DataSourceType.URL); |
360 |
69 |
if (downloadStructureFile) |
361 |
|
{ |
362 |
0 |
String structExt = format.getExtensions().split(",")[0]; |
363 |
0 |
String urlLeafName = file.substring( |
364 |
|
file.lastIndexOf( |
365 |
|
System.getProperty("file.separator")), |
366 |
|
file.lastIndexOf(".")); |
367 |
0 |
String tempStructureFileStr = createNamedJvTempFile( |
368 |
|
urlLeafName, structExt); |
369 |
|
|
370 |
|
|
371 |
|
|
372 |
0 |
File tempFile = new File(tempStructureFileStr); |
373 |
0 |
UrlDownloadClient.download(file, tempFile); |
374 |
|
|
375 |
0 |
al = fa.readFile(tempFile, DataSourceType.FILE, |
376 |
|
format); |
377 |
0 |
source = fa.getAlignFile(); |
378 |
|
} |
379 |
|
else |
380 |
|
{ |
381 |
69 |
if (selectedFile == null) { |
382 |
69 |
al = fa.readFile(file, protocol, format); |
383 |
|
|
384 |
|
} else { |
385 |
0 |
al = fa.readFile(selectedFile, protocol, format); |
386 |
|
} |
387 |
69 |
source = fa.getAlignFile(); |
388 |
|
|
389 |
|
|
390 |
|
} |
391 |
|
} |
392 |
|
} catch (java.io.IOException ex) |
393 |
|
{ |
394 |
0 |
error = ex.getMessage(); |
395 |
|
} |
396 |
|
|
397 |
69 |
if ((al != null) && (al.getHeight() > 0) && al.hasValidSequence()) |
398 |
|
{ |
399 |
|
|
400 |
69 |
for (SequenceI sq : al.getSequences()) |
401 |
|
{ |
402 |
577 |
while (sq.getDatasetSequence() != null) |
403 |
|
{ |
404 |
2 |
sq = sq.getDatasetSequence(); |
405 |
|
} |
406 |
575 |
if (sq.getAllPDBEntries() != null) |
407 |
|
{ |
408 |
575 |
for (PDBEntry pdbe : sq.getAllPDBEntries()) |
409 |
|
{ |
410 |
|
|
411 |
|
|
412 |
30 |
StructureSelectionManager |
413 |
|
.getStructureSelectionManager(Desktop.instance) |
414 |
|
.registerPDBEntry(pdbe); |
415 |
|
} |
416 |
|
} |
417 |
|
} |
418 |
|
|
419 |
69 |
FeatureSettingsModelI proxyColourScheme = source |
420 |
|
.getFeatureColourScheme(); |
421 |
69 |
if (viewport != null) |
422 |
|
{ |
423 |
1 |
if (proxyColourScheme != null) |
424 |
|
{ |
425 |
1 |
viewport.applyFeaturesStyle(proxyColourScheme); |
426 |
|
} |
427 |
|
|
428 |
1 |
viewport.addAlignment(al, title); |
429 |
|
} |
430 |
|
else |
431 |
|
{ |
432 |
|
|
433 |
|
|
434 |
68 |
if (source instanceof ComplexAlignFile) |
435 |
|
{ |
436 |
0 |
HiddenColumns colSel = ((ComplexAlignFile) source) |
437 |
|
.getHiddenColumns(); |
438 |
0 |
SequenceI[] hiddenSeqs = ((ComplexAlignFile) source) |
439 |
|
.getHiddenSequences(); |
440 |
0 |
String colourSchemeName = ((ComplexAlignFile) source) |
441 |
|
.getGlobalColourScheme(); |
442 |
0 |
FeaturesDisplayedI fd = ((ComplexAlignFile) source) |
443 |
|
.getDisplayedFeatures(); |
444 |
0 |
alignFrame = new AlignFrame(al, hiddenSeqs, colSel, |
445 |
|
AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); |
446 |
0 |
alignFrame.getViewport().setFeaturesDisplayed(fd); |
447 |
0 |
alignFrame.getViewport().setShowSequenceFeatures( |
448 |
|
((ComplexAlignFile) source).isShowSeqFeatures()); |
449 |
0 |
ColourSchemeI cs = ColourSchemeMapper |
450 |
|
.getJalviewColourScheme(colourSchemeName, al); |
451 |
0 |
if (cs != null) |
452 |
|
{ |
453 |
0 |
alignFrame.changeColour(cs); |
454 |
|
} |
455 |
|
} |
456 |
|
else |
457 |
|
{ |
458 |
68 |
alignFrame = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH, |
459 |
|
AlignFrame.DEFAULT_HEIGHT); |
460 |
68 |
if (source instanceof FeaturesSourceI) |
461 |
|
{ |
462 |
1 |
alignFrame.getViewport().setShowSequenceFeatures(true); |
463 |
|
} |
464 |
|
} |
465 |
|
|
466 |
68 |
if (!(protocol == DataSourceType.PASTE)) |
467 |
|
{ |
468 |
36 |
alignFrame.setFileName(file, format); |
469 |
36 |
alignFrame.setFileObject(selectedFile); |
470 |
|
} |
471 |
68 |
if (proxyColourScheme != null) |
472 |
|
{ |
473 |
9 |
alignFrame.getViewport() |
474 |
|
.applyFeaturesStyle(proxyColourScheme); |
475 |
|
} |
476 |
68 |
alignFrame.setStatus(MessageManager.formatMessage( |
477 |
|
"label.successfully_loaded_file", new String[] |
478 |
|
{ title })); |
479 |
|
|
480 |
68 |
if (raiseGUI) |
481 |
|
{ |
482 |
|
|
483 |
|
|
484 |
|
|
485 |
|
|
486 |
|
|
487 |
54 |
Desktop.addInternalFrame(alignFrame, title, |
488 |
|
AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); |
489 |
|
} |
490 |
|
|
491 |
68 |
try |
492 |
|
{ |
493 |
68 |
alignFrame.setMaximum(jalview.bin.Cache |
494 |
|
.getDefault("SHOW_FULLSCREEN", false)); |
495 |
|
} catch (java.beans.PropertyVetoException ex) |
496 |
|
{ |
497 |
|
} |
498 |
|
} |
499 |
|
} |
500 |
|
else |
501 |
|
{ |
502 |
0 |
if (Desktop.instance != null) |
503 |
|
{ |
504 |
0 |
Desktop.instance.stopLoading(); |
505 |
|
} |
506 |
|
|
507 |
0 |
final String errorMessage = MessageManager.getString( |
508 |
|
"label.couldnt_load_file") + " " + title + "\n" + error; |
509 |
|
|
510 |
|
|
511 |
0 |
if (raiseGUI && Desktop.desktop != null) |
512 |
|
{ |
513 |
0 |
javax.swing.SwingUtilities.invokeLater(new Runnable() |
514 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
515 |
0 |
@Override... |
516 |
|
public void run() |
517 |
|
{ |
518 |
0 |
JvOptionPane.showInternalMessageDialog(Desktop.desktop, |
519 |
|
errorMessage, |
520 |
|
MessageManager |
521 |
|
.getString("label.error_loading_file"), |
522 |
|
JvOptionPane.WARNING_MESSAGE); |
523 |
|
} |
524 |
|
}); |
525 |
|
} |
526 |
|
else |
527 |
|
{ |
528 |
0 |
System.err.println(errorMessage); |
529 |
|
} |
530 |
|
} |
531 |
|
} |
532 |
|
|
533 |
89 |
updateRecentlyOpened(); |
534 |
|
|
535 |
|
} catch (Exception er) |
536 |
|
{ |
537 |
0 |
System.err.println("Exception whilst opening file '" + file); |
538 |
0 |
er.printStackTrace(); |
539 |
0 |
if (raiseGUI) |
540 |
|
{ |
541 |
0 |
javax.swing.SwingUtilities.invokeLater(new Runnable() |
542 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
543 |
0 |
@Override... |
544 |
|
public void run() |
545 |
|
{ |
546 |
0 |
JvOptionPane.showInternalMessageDialog(Desktop.desktop, |
547 |
|
MessageManager.formatMessage( |
548 |
|
"label.problems_opening_file", new String[] |
549 |
|
{ file }), |
550 |
|
MessageManager.getString("label.file_open_error"), |
551 |
|
JvOptionPane.WARNING_MESSAGE); |
552 |
|
} |
553 |
|
}); |
554 |
|
} |
555 |
0 |
alignFrame = null; |
556 |
|
} catch (OutOfMemoryError er) |
557 |
|
{ |
558 |
|
|
559 |
0 |
er.printStackTrace(); |
560 |
0 |
alignFrame = null; |
561 |
0 |
if (raiseGUI) |
562 |
|
{ |
563 |
0 |
javax.swing.SwingUtilities.invokeLater(new Runnable() |
564 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
565 |
0 |
@Override... |
566 |
|
public void run() |
567 |
|
{ |
568 |
0 |
JvOptionPane.showInternalMessageDialog(Desktop.desktop, |
569 |
|
MessageManager.formatMessage( |
570 |
|
"warn.out_of_memory_loading_file", new String[] |
571 |
|
{ file }), |
572 |
|
MessageManager.getString("label.out_of_memory"), |
573 |
|
JvOptionPane.WARNING_MESSAGE); |
574 |
|
} |
575 |
|
}); |
576 |
|
} |
577 |
0 |
System.err.println("Out of memory loading file " + file + "!!"); |
578 |
|
|
579 |
|
} |
580 |
90 |
loadtime += System.currentTimeMillis(); |
581 |
|
|
582 |
|
|
583 |
|
|
584 |
90 |
memused = memused |
585 |
|
- (rt.maxMemory() - rt.totalMemory() + rt.freeMemory()); |
586 |
|
|
587 |
|
|
588 |
|
|
589 |
|
|
590 |
90 |
if (Desktop.desktop != null && Desktop.desktop.isShowMemoryUsage()) |
591 |
|
{ |
592 |
0 |
if (alignFrame != null) |
593 |
|
{ |
594 |
0 |
AlignmentI al = alignFrame.getViewport().getAlignment(); |
595 |
|
|
596 |
0 |
System.out.println("Loaded '" + title + "' in " |
597 |
|
+ (loadtime / 1000.0) + "s, took an additional " |
598 |
|
+ (1.0 * memused / (1024.0 * 1024.0)) + " MB (" |
599 |
|
+ al.getHeight() + " seqs by " + al.getWidth() + " cols)"); |
600 |
|
} |
601 |
|
else |
602 |
|
{ |
603 |
|
|
604 |
|
|
605 |
0 |
System.out.println("Failed to load '" + title + "' in " |
606 |
|
+ (loadtime / 1000.0) + "s, took an additional " |
607 |
|
+ (1.0 * memused / (1024.0 * 1024.0)) |
608 |
|
+ " MB (alignment is null)"); |
609 |
|
} |
610 |
|
} |
611 |
|
|
612 |
90 |
if (Desktop.instance != null) |
613 |
|
{ |
614 |
89 |
Desktop.instance.stopLoading(); |
615 |
|
} |
616 |
|
|
617 |
|
} |
618 |
|
|
619 |
|
|
620 |
|
|
621 |
|
|
622 |
|
|
623 |
|
|
624 |
|
@param |
625 |
|
|
626 |
|
@param |
627 |
|
|
628 |
|
@return |
629 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
630 |
0 |
private static String createNamedJvTempFile(String fileName,... |
631 |
|
String extension) throws IOException |
632 |
|
{ |
633 |
0 |
String seprator = System.getProperty("file.separator"); |
634 |
0 |
String jvTempDir = System.getProperty("java.io.tmpdir") + "jalview" |
635 |
|
+ seprator + System.currentTimeMillis(); |
636 |
0 |
File tempStructFile = new File( |
637 |
|
jvTempDir + seprator + fileName + "." + extension); |
638 |
0 |
tempStructFile.mkdirs(); |
639 |
0 |
return tempStructFile.toString(); |
640 |
|
} |
641 |
|
|
642 |
|
|
643 |
|
|
644 |
|
@param |
645 |
|
@return |
646 |
|
@throws |
647 |
|
|
|
|
| 30% |
Uncovered Elements: 7 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
648 |
9 |
@SuppressWarnings("unused")... |
649 |
|
public static BufferedReader getBuffereReader(Object file) throws FileNotFoundException { |
650 |
9 |
if (file instanceof String) |
651 |
9 |
return new BufferedReader(new FileReader((String) file)); |
652 |
|
|
653 |
0 |
byte[] bytes = null; |
654 |
0 |
if (bytes != null) |
655 |
0 |
return new BufferedReader(new InputStreamReader(new ByteArrayInputStream(bytes))); |
656 |
0 |
return new BufferedReader(new FileReader((File) file)); |
657 |
|
} |
658 |
|
|
659 |
|
} |