import jalview.util.Platform;
import jalview.ws.utils.UrlDownloadClient;
+import java.awt.Dimension;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
public class FileLoader implements Runnable
{
+ private File selectedFile;
+
String file;
DataSourceType protocol;
FileFormatI format;
- AlignmentFileReaderI source = null; // alternative specification of where data
- // comes
+ AlignmentFileReaderI source; // alternative specification of where data
+ // comes from
- // from
+ /**
+ * It is critical that all these fields are set, as this instance is reused.
+ *
+ * @param source
+ * @param file
+ * @param inFile
+ * @param dataSourceType
+ * @param format
+ */
+ private void setFileFields(AlignmentFileReaderI source, File file,
+ String inFile, DataSourceType dataSourceType, FileFormatI format)
+ {
+ this.source = source;
+ this.file = inFile;
+ this.selectedFile = file;
+ this.protocol = dataSourceType;
+ this.format = format;
+ }
AlignViewport viewport;
boolean raiseGUI = true;
- private File selectedFile;
-
/**
* default constructor always raised errors in GUI dialog boxes
*/
this.raiseGUI = raiseGUI;
}
- public void LoadFile(AlignViewport viewport, Object file,
+ public void loadFile(AlignViewport viewport, Object file,
DataSourceType protocol, FileFormatI format)
{
this.viewport = viewport;
this.selectedFile = (File) file;
file = selectedFile.getPath();
}
- LoadFile(file.toString(), protocol, format);
+ loadFile(file.toString(), protocol, format);
}
- public void LoadFile(String file, DataSourceType protocol,
+ public void loadFile(String file, DataSourceType protocol,
FileFormatI format)
{
this.file = file;
*/
public void LoadFile(String file, DataSourceType protocol)
{
- LoadFile(file, protocol, null);
+ loadFile(file, protocol, null);
}
/**
public AlignFrame LoadFileWaitTillLoaded(String file,
DataSourceType sourceType)
{
- return LoadFileWaitTillLoaded(file, sourceType, null);
+ return loadFileWaitTillLoaded(file, sourceType, null);
}
/**
* @param format
* @return alignFrame constructed from file contents
*/
- public AlignFrame LoadFileWaitTillLoaded(String file,
+ public AlignFrame loadFileWaitTillLoaded(String file,
DataSourceType sourceType, FileFormatI format)
{
- this.file = file;
- this.protocol = sourceType;
- this.format = format;
- return _LoadFileWaitTillLoaded();
+ setFileFields(null, null, file, sourceType, format);
+ return _loadFileWaitTillLoaded();
}
/**
* @param format
* @return alignFrame constructed from file contents
*/
- public AlignFrame LoadFileWaitTillLoaded(File file,
+ public AlignFrame loadFileWaitTillLoaded(File file,
DataSourceType sourceType, FileFormatI format)
{
- this.selectedFile = file;
- this.file = file.getPath();
- this.protocol = sourceType;
- this.format = format;
- return _LoadFileWaitTillLoaded();
+ setFileFields(null, file, null, sourceType, format);
+ return _loadFileWaitTillLoaded();
}
/**
* @param format
* @return alignFrame constructed from file contents
*/
- public AlignFrame LoadFileWaitTillLoaded(AlignmentFileReaderI source,
+ public AlignFrame loadFileWaitTillLoaded(AlignmentFileReaderI source,
FileFormatI format)
{
- this.source = source;
-
- file = source.getInFile();
- protocol = source.getDataSourceType();
- this.format = format;
- return _LoadFileWaitTillLoaded();
+ setFileFields(source, null, source.getInFile(),
+ source.getDataSourceType(), format);
+ return _loadFileWaitTillLoaded();
}
/**
*
* @return
*/
- protected AlignFrame _LoadFileWaitTillLoaded()
+ private AlignFrame _loadFileWaitTillLoaded()
{
this.run();
return alignFrame;
// We read the data anyway - it might make sense.
}
// BH 2018 switch to File object here instead of filename
+ Platform.timeCheck(null, Platform.TIME_MARK);
alignFrame = new Jalview2XML(raiseGUI).loadJalviewAlign(selectedFile == null ? file : selectedFile);
+ Platform.timeCheck("JVP loaded", Platform.TIME_MARK);
+
}
else
{
{
// register PDB entries with desktop's structure selection
// manager
- Desktop.getInstance().getStructureSelectionManager()
+ Desktop.getStructureSelectionManager()
.registerPDBEntry(pdbe);
}
}
// status in Jalview 3
// TODO: define 'virtual desktop' for benefit of headless scripts
// that perform queries to find the 'current working alignment'
- Desktop.addInternalFrame(alignFrame, title,
+
+
+ Dimension dim = Platform.getDimIfEmbedded(alignFrame,
AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
+ alignFrame.setSize(dim);
+ Desktop.addInternalFrame(alignFrame, title, dim.width,
+ dim.height);
}
try