X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FAppletFormatAdapter.java;h=5de14a43272af4839a79231ca98976b92b67128d;hb=17b7d054cf7faa5ee57ad8c8c4c9daa495d8cb35;hp=8c376fcfbfd3c5ea7f681e09f4d8b32c099a87d8;hpb=b879c4a2d32d3489e63ac06917e81637e6bb4068;p=jalview.git diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index 8c376fc..5de14a4 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -20,16 +20,20 @@ */ package jalview.io; +import java.util.Locale; + import jalview.api.AlignExportSettingsI; import jalview.api.AlignmentViewPanel; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; +import jalview.datamodel.SeqDistanceContactMatrix; import jalview.datamodel.PDBEntry.Type; import jalview.datamodel.SequenceI; import jalview.ext.jmol.JmolParser; import jalview.structure.StructureImportSettings; +import jalview.util.Platform; import java.io.File; import java.io.IOException; @@ -151,14 +155,17 @@ public class AppletFormatAdapter { return readFile(null, file, sourceType, fileFormat); } - - public AlignmentI readFile(File selectedFile, String file, DataSourceType sourceType, - FileFormatI fileFormat) throws IOException + + public AlignmentI readFile(File selectedFile, String file, + DataSourceType sourceType, FileFormatI fileFormat) + throws IOException { this.selectedFile = selectedFile; if (selectedFile != null) + { this.inFile = selectedFile.getPath(); + } this.inFile = file; try { @@ -174,7 +181,8 @@ public class AppletFormatAdapter if (isParseWithJMOL) { // needs a File option - alignFile = new JmolParser(selectedFile == null ? inFile : selectedFile, sourceType); + alignFile = new JmolParser( + selectedFile == null ? inFile : selectedFile, sourceType); } else { @@ -187,9 +195,12 @@ public class AppletFormatAdapter ((StructureFile) alignFile).setDbRefType( FileFormat.PDB.equals(fileFormat) ? Type.PDB : Type.MMCIF); } - else if (selectedFile != null) { - alignFile = fileFormat.getReader(new FileParse(selectedFile, sourceType)); - } else + else if (selectedFile != null) + { + alignFile = fileFormat + .getReader(new FileParse(selectedFile, sourceType)); + } + else { // alignFile = fileFormat.getAlignmentFile(inFile, sourceType); alignFile = fileFormat.getReader(new FileParse(inFile, sourceType)); @@ -421,30 +432,32 @@ public class AppletFormatAdapter return null; } - /** * Determines the protocol (i.e DataSourceType.{FILE|PASTE|URL}) for the input * data * * BH 2018 allows File or String, and can return RELATIVE_URL * - * @param dataObject File or String + * @param dataObject + * File or String * @return the protocol for the input data */ public static DataSourceType checkProtocol(Object dataObject) { - if(dataObject instanceof File) + if (dataObject instanceof File) + { return DataSourceType.FILE; - + } + String data = dataObject.toString(); DataSourceType protocol = DataSourceType.PASTE; - String ft = data.toLowerCase().trim(); + String ft = data.toLowerCase(Locale.ROOT).trim(); if (ft.indexOf("http:") == 0 || ft.indexOf("https:") == 0 || ft.indexOf("file:") == 0) { protocol = DataSourceType.URL; } - else if (jalview.bin.Jalview.isJS()) + else if (Platform.isJS()) { protocol = DataSourceType.RELATIVE_URL; } @@ -455,6 +468,10 @@ public class AppletFormatAdapter return protocol; } + /** + * @param args + * @j2sIgnore + */ public static void main(String[] args) { int i = 0;