newickStrings.addElement(new String[] { treeName, newickString });
}
- protected int getTreeCount()
+ @Override
+ public int getTreeCount()
{
return newickStrings == null ? 0 : newickStrings.size();
}
@Override
+ public boolean hasTrees()
+ {
+ return getTreeCount()>0;
+ }
+
+ @Override
+ public List<String[]> getNewickTrees()
+ {
+ return newickStrings;
+ }
+ @Override
public void addGroups(AlignmentI al)
{
*/
package jalview.io;
+import java.util.Arrays;
+import java.util.List;
+
import jalview.api.AlignExportSettingsI;
import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureSettingsModelI;
FeatureSettingsModelI getFeatureColourScheme();
+ default int getTreeCount() {
+ return 0;
+ }
+
+ default boolean hasTrees() {
+ return false;
+ }
+
+ default List<String[]> getNewickTrees() {
+ return Arrays.asList(new String[][] {});
+ }
+
}
import jalview.api.FeaturesDisplayedI;
import jalview.api.FeaturesSourceI;
import jalview.bin.Cache;
+import jalview.bin.Console;
import jalview.bin.Jalview;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.HiddenColumns;
}
loadtime = -System.currentTimeMillis();
AlignmentI al = null;
-
if (FileFormat.Jalview.equals(format))
{
if (source != null)
}
else
{
+ FormatAdapter fa = null; // populated for simple and complex flatfile formats - but not Jalview Projects
String error = AppletFormatAdapter.getSupportedFormats();
try
{
if (source != null)
{
+ fa=new FormatAdapter();
// read from the provided source
- al = new FormatAdapter().readFromFile(source, format);
+ al = fa.readFromFile(source, format);
}
else
{
// open a new source and read from it
- FormatAdapter fa = new FormatAdapter();
+ fa = new FormatAdapter();
boolean downloadStructureFile = format.isStructureFile()
&& protocol.equals(DataSourceType.URL);
if (downloadStructureFile)
alignFrame.getViewport()
.applyFeaturesStyle(proxyColourScheme);
}
+ if (source.hasTrees())
+ {
+ for (String[] nhxtree : source.getNewickTrees())
+ {
+ NewickFile fin = null;
+ try
+ {
+ fin = new NewickFile(new FileParse(nhxtree[1],
+ DataSourceType.PASTE));
+ if (fin.hasWarningMessage())
+ {
+ Console.warn(
+ "Warnings when importing tree from file: "
+ + fin.getWarningMessage());
+ }
+ if (fin.isValid())// && fin.getTree() != null)
+ {
+ alignFrame.showNewickTree(fin, nhxtree[0]);
+ } else {
+ Console.warn("Ignoring tree "+nhxtree[0]+"\t"+nhxtree[1]);
+ }
+ } catch (Throwable thr)
+ {
+ Console.warn("Couldn't import tree from file", thr);
+ }
+ }
+ }
alignFrame.setStatus(MessageManager.formatMessage(
"label.successfully_loaded_file", new String[]
{ title }));