1 package jalview.ext.forester.io;
3 import jalview.ext.archaeopteryx.ArchaeopteryxInit;
4 import jalview.gui.Desktop;
5 import jalview.gui.JvOptionPane;
6 import jalview.util.MessageManager;
7 import jalview.viewmodel.AlignmentViewport;
10 import java.io.IOException;
12 import org.forester.archaeopteryx.Archaeopteryx;
13 import org.forester.archaeopteryx.MainFrame;
14 import org.forester.util.ForesterUtil;
16 public class ForesterTreeParser implements ExternalTreeParserI<MainFrame>
18 private final String filePath;
20 private final File file;
22 public ForesterTreeParser(final String treeFilePath)
24 final String possibleError = ForesterUtil.isReadableFile(treeFilePath);
25 if (possibleError != null)
27 JvOptionPane.showMessageDialog(Desktop.desktop, possibleError,
28 MessageManager.getString("label.problem_reading_tree_file"),
29 JvOptionPane.WARNING_MESSAGE);
32 filePath = treeFilePath;
33 file = new File(filePath);
38 public ForesterTreeParser(final File treeFile) throws IOException
40 final String possibleError = ForesterUtil.isReadableFile(treeFile);
41 if (possibleError != null)
43 JvOptionPane.showMessageDialog(Desktop.desktop, possibleError,
44 MessageManager.getString("label.problem_reading_tree_file"),
45 JvOptionPane.WARNING_MESSAGE);
49 filePath = file.getCanonicalPath();
53 public MainFrame loadTree(AlignmentViewport viewport)
55 String[] AptxArgs = new String[] { "-c",
56 "_aptx_jalview_configuration_file", filePath };
57 MainFrame aptx = Archaeopteryx.main(AptxArgs);
58 ArchaeopteryxInit.bindFrameToJalview(aptx);