X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FJalviewLite.java;h=7fa514710dbf1cfbfeca9faed7d1c98beffe759b;hb=aba253e57b22ce7d1f4fe376935e42aeb4f6d591;hp=210a07a3823e12ab35b13de8b5233eaeb4b5454d;hpb=c2d8f2308b066224de8e2a07e4d6b6f9720b8e88;p=jalview.git diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 210a07a..7fa5147 100644 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -37,6 +37,9 @@ import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.io.AnnotationFile; import jalview.io.AppletFormatAdapter; +import jalview.io.DataSourceType; +import jalview.io.FileFormatI; +import jalview.io.FileFormats; import jalview.io.FileParse; import jalview.io.IdentifyFile; import jalview.io.JPredFile; @@ -48,6 +51,7 @@ import jalview.javascript.JsCallBack; import jalview.javascript.MouseOverStructureListener; import jalview.structure.SelectionListener; import jalview.structure.StructureSelectionManager; +import jalview.util.ColorUtils; import jalview.util.HttpUtils; import jalview.util.MessageManager; @@ -63,6 +67,7 @@ import java.awt.event.ActionEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.BufferedReader; +import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.util.ArrayList; @@ -466,7 +471,7 @@ public class JalviewLite extends Applet implements SequenceI rs = sel.getSequenceAt(0); start = rs.findIndex(start); end = rs.findIndex(end); - List cs = csel.getSelected(); + List cs = new ArrayList(csel.getSelected()); csel.clear(); for (Integer selectedCol : cs) { @@ -513,21 +518,23 @@ public class JalviewLite extends Applet implements { try { + FileFormatI theFormat = FileFormats.getInstance().forName(format); boolean seqlimits = suffix.equalsIgnoreCase(TRUE); if (alf.viewport.getSelectionGroup() != null) { // JBPNote: getSelectionAsNewSequence behaviour has changed - this // method now returns a full copy of sequence data // TODO consider using getSequenceSelection instead here - String reply = new AppletFormatAdapter().formatSequences(format, + String reply = new AppletFormatAdapter().formatSequences(theFormat, new Alignment(alf.viewport.getSelectionAsNewSequence()), seqlimits); return reply; } - } catch (Exception ex) + } catch (IllegalArgumentException ex) { ex.printStackTrace(); - return "Error retrieving alignment in " + format + " format. "; + return "Error retrieving alignment, possibly invalid format specifier: " + + format; } return ""; } @@ -709,13 +716,15 @@ public class JalviewLite extends Applet implements { boolean seqlimits = suffix.equalsIgnoreCase(TRUE); - String reply = new AppletFormatAdapter().formatSequences(format, + FileFormatI theFormat = FileFormats.getInstance().forName(format); + String reply = new AppletFormatAdapter().formatSequences(theFormat, alf.viewport.getAlignment(), seqlimits); return reply; - } catch (Exception ex) + } catch (IllegalArgumentException ex) { ex.printStackTrace(); - return "Error retrieving alignment in " + format + " format. "; + return "Error retrieving alignment, possibly invalid format specifier: " + + format; } } @@ -741,14 +750,14 @@ public class JalviewLite extends Applet implements public void loadAnnotationFrom(AlignFrame alf, String annotation) { if (new AnnotationFile().annotateAlignmentView(alf.getAlignViewport(), - annotation, AppletFormatAdapter.PASTE)) + annotation, DataSourceType.PASTE)) { alf.alignPanel.fontChanged(); alf.alignPanel.setScrollValues(0, 0); } else { - alf.parseFeaturesFile(annotation, AppletFormatAdapter.PASTE); + alf.parseFeaturesFile(annotation, DataSourceType.PASTE); } } @@ -774,7 +783,7 @@ public class JalviewLite extends Applet implements public boolean loadFeaturesFrom(AlignFrame alf, String features, boolean autoenabledisplay) { - return alf.parseFeaturesFile(features, AppletFormatAdapter.PASTE, + return alf.parseFeaturesFile(features, DataSourceType.PASTE, autoenabledisplay); } @@ -882,17 +891,17 @@ public class JalviewLite extends Applet implements { AlignmentI al = null; - String format = new IdentifyFile().identify(text, - AppletFormatAdapter.PASTE); try { - al = new AppletFormatAdapter().readFile(text, - AppletFormatAdapter.PASTE, format); + FileFormatI format = new IdentifyFile().identify(text, + DataSourceType.PASTE); + al = new AppletFormatAdapter().readFile(text, DataSourceType.PASTE, + format); if (al.getHeight() > 0) { return new AlignFrame(al, this, title, false); } - } catch (java.io.IOException ex) + } catch (IOException ex) { ex.printStackTrace(); } @@ -1818,7 +1827,7 @@ public class JalviewLite extends Applet implements /** * State variable: protocol for access to file source */ - String protocol; + DataSourceType protocol; String _file; // alignment file or URL spec @@ -1848,7 +1857,7 @@ public class JalviewLite extends Applet implements */ if (path.startsWith("PASTE")) { - protocol = AppletFormatAdapter.PASTE; + protocol = DataSourceType.PASTE; return path.substring(5); } @@ -1857,7 +1866,7 @@ public class JalviewLite extends Applet implements */ if (path.indexOf("://") != -1) { - protocol = AppletFormatAdapter.URL; + protocol = DataSourceType.URL; return path; } @@ -1873,7 +1882,7 @@ public class JalviewLite extends Applet implements System.err.println("Prepended document base '" + documentBase + "' to make: '" + withDocBase + "'"); } - protocol = AppletFormatAdapter.URL; + protocol = DataSourceType.URL; return withDocBase; } @@ -1886,7 +1895,7 @@ public class JalviewLite extends Applet implements if (!withCodeBase.equals(withDocBase) && HttpUtils.isValidUrl(withCodeBase)) { - protocol = AppletFormatAdapter.URL; + protocol = DataSourceType.URL; if (debug) { System.err.println("Prepended codebase '" + codeBase @@ -1901,7 +1910,7 @@ public class JalviewLite extends Applet implements */ if (inArchive(path)) { - protocol = AppletFormatAdapter.CLASSLOADER; + protocol = DataSourceType.CLASSLOADER; } return path; } @@ -2015,11 +2024,12 @@ public class JalviewLite extends Applet implements return null; } String resolvedFile = resolveFileProtocol(fileParam); - String format = new IdentifyFile().identify(resolvedFile, protocol); - dbgMsg("File identified as '" + format + "'"); AlignmentI al = null; try { + FileFormatI format = new IdentifyFile().identify(resolvedFile, + protocol); + dbgMsg("File identified as '" + format + "'"); al = new AppletFormatAdapter().readFile(resolvedFile, protocol, format); if ((al != null) && (al.getHeight() > 0)) @@ -2036,7 +2046,7 @@ public class JalviewLite extends Applet implements // update the focus. currentAlignFrame = newAlignFrame; - if (protocol == AppletFormatAdapter.PASTE) + if (protocol == DataSourceType.PASTE) { newAlignFrame.setTitle(MessageManager.formatMessage( "label.sequences_from", new Object[] { applet @@ -2207,8 +2217,7 @@ public class JalviewLite extends Applet implements } else { - pdbs.addElement(new Object[] { pdb, seqs, chains, - new String(protocol) }); + pdbs.addElement(new Object[] { pdb, seqs, chains, protocol }); } } } @@ -2247,6 +2256,11 @@ public class JalviewLite extends Applet implements { boolean result = false; String param = applet.getParameter("jnetfile"); + if (param == null) + { + // jnet became jpred around 2016 + param = applet.getParameter("jpredfile"); + } if (param != null) { try @@ -2875,22 +2889,13 @@ public class JalviewLite extends Applet implements { return defcolour; } - Color col = jalview.schemes.ColourSchemeProperty - .getAWTColorFromName(colprop); + Color col = ColorUtils.parseColourString(colprop); if (col == null) { - try - { - col = new jalview.schemes.UserColourScheme(colprop).findColour('A'); - } catch (Exception ex) - { - System.err.println("Couldn't parse '" + colprop - + "' as a colour for " + colparam); - col = null; - } + System.err.println("Couldn't parse '" + colprop + + "' as a colour for " + colparam); } return (col == null) ? defcolour : col; - } public void openJalviewHelpUrl()