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;
import jalview.javascript.MouseOverStructureListener;
import jalview.structure.SelectionListener;
import jalview.structure.StructureSelectionManager;
+import jalview.util.ColorUtils;
import jalview.util.HttpUtils;
import jalview.util.MessageManager;
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;
SequenceI rs = sel.getSequenceAt(0);
start = rs.findIndex(start);
end = rs.findIndex(end);
- List<Integer> cs = csel.getSelected();
+ List<Integer> cs = new ArrayList<Integer>(csel.getSelected());
csel.clear();
for (Integer selectedCol : cs)
{
{
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 "";
}
{
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;
}
}
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);
}
}
public boolean loadFeaturesFrom(AlignFrame alf, String features,
boolean autoenabledisplay)
{
- return alf.parseFeaturesFile(features, AppletFormatAdapter.PASTE,
+ return alf.parseFeaturesFile(features, DataSourceType.PASTE,
autoenabledisplay);
}
{
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();
}
/**
* State variable: protocol for access to file source
*/
- String protocol;
+ DataSourceType protocol;
String _file; // alignment file or URL spec
*/
if (path.startsWith("PASTE"))
{
- protocol = AppletFormatAdapter.PASTE;
+ protocol = DataSourceType.PASTE;
return path.substring(5);
}
*/
if (path.indexOf("://") != -1)
{
- protocol = AppletFormatAdapter.URL;
+ protocol = DataSourceType.URL;
return path;
}
System.err.println("Prepended document base '" + documentBase
+ "' to make: '" + withDocBase + "'");
}
- protocol = AppletFormatAdapter.URL;
+ protocol = DataSourceType.URL;
return withDocBase;
}
if (!withCodeBase.equals(withDocBase)
&& HttpUtils.isValidUrl(withCodeBase))
{
- protocol = AppletFormatAdapter.URL;
+ protocol = DataSourceType.URL;
if (debug)
{
System.err.println("Prepended codebase '" + codeBase
*/
if (inArchive(path))
{
- protocol = AppletFormatAdapter.CLASSLOADER;
+ protocol = DataSourceType.CLASSLOADER;
}
return path;
}
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))
// update the focus.
currentAlignFrame = newAlignFrame;
- if (protocol == AppletFormatAdapter.PASTE)
+ if (protocol == DataSourceType.PASTE)
{
newAlignFrame.setTitle(MessageManager.formatMessage(
"label.sequences_from", new Object[] { applet
}
else
{
- pdbs.addElement(new Object[] { pdb, seqs, chains,
- new String(protocol) });
+ pdbs.addElement(new Object[] { pdb, seqs, chains, protocol });
}
}
}
{
boolean result = false;
String param = applet.getParameter("jnetfile");
+ if (param == null)
+ {
+ // jnet became jpred around 2016
+ param = applet.getParameter("jpredfile");
+ }
if (param != null)
{
try
{
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()