JAL-2805 viewport is passed along to the tree parser
[jalview.git] / src / jalview / ext / forester / io / ForesterTreeParser.java
1 package jalview.ext.forester.io;
2
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;
8
9 import java.io.File;
10 import java.io.IOException;
11
12 import org.forester.archaeopteryx.Archaeopteryx;
13 import org.forester.archaeopteryx.MainFrame;
14 import org.forester.util.ForesterUtil;
15
16 public class ForesterTreeParser implements ExternalTreeParserI<MainFrame>
17 {
18   private final String filePath;
19
20   private final File file;
21
22   public ForesterTreeParser(final String treeFilePath)
23   {
24     final String possibleError = ForesterUtil.isReadableFile(treeFilePath);
25     if (possibleError != null)
26     {
27       JvOptionPane.showMessageDialog(Desktop.desktop, possibleError,
28               MessageManager.getString("label.problem_reading_tree_file"),
29               JvOptionPane.WARNING_MESSAGE);
30
31     }
32     filePath = treeFilePath;
33     file = new File(filePath);
34
35
36   }
37
38   public ForesterTreeParser(final File treeFile) throws IOException
39   {
40     final String possibleError = ForesterUtil.isReadableFile(treeFile);
41     if (possibleError != null)
42     {
43       JvOptionPane.showMessageDialog(Desktop.desktop, possibleError,
44               MessageManager.getString("label.problem_reading_tree_file"),
45               JvOptionPane.WARNING_MESSAGE);
46
47     }
48     file = treeFile;
49     filePath = file.getCanonicalPath();
50   }
51
52   @Override
53   public MainFrame loadTree(AlignmentViewport viewport)
54   {
55     String[] AptxArgs = new String[] { "-c",
56         "_aptx_jalview_configuration_file", filePath };
57     MainFrame aptx = Archaeopteryx.main(AptxArgs);
58     ArchaeopteryxInit.bindFrameToJalview(aptx);
59     return aptx;
60
61
62   }
63
64 }
65
66
67
68
69
70