JAL-2805 undid accidental double (buggy) binding, more interface support
[jalview.git] / src / jalview / ext / forester / io / TreeParser.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
8 import java.io.File;
9 import java.io.IOException;
10
11 import org.forester.archaeopteryx.Archaeopteryx;
12 import org.forester.archaeopteryx.MainFrame;
13 import org.forester.util.ForesterUtil;
14
15 public class TreeParser
16 {
17   private final String filePath;
18
19   private final File file;
20
21   public TreeParser(final String treeFilePath)
22   {
23     final String possibleError = ForesterUtil.isReadableFile(treeFilePath);
24     if (possibleError != null)
25     {
26       JvOptionPane.showMessageDialog(Desktop.desktop, possibleError,
27               MessageManager.getString("label.problem_reading_tree_file"),
28               JvOptionPane.WARNING_MESSAGE);
29
30     }
31     filePath = treeFilePath;
32     file = new File(filePath);
33
34
35   }
36
37   public TreeParser(final File treeFile) throws IOException
38   {
39     final String possibleError = ForesterUtil.isReadableFile(treeFile);
40     if (possibleError != null)
41     {
42       JvOptionPane.showMessageDialog(Desktop.desktop, possibleError,
43               MessageManager.getString("label.problem_reading_tree_file"),
44               JvOptionPane.WARNING_MESSAGE);
45
46     }
47     file = treeFile;
48     filePath = file.getCanonicalPath();
49   }
50
51   public MainFrame loadTree()
52   {
53     String[] AptxArgs = new String[] { "-c",
54         "_aptx_jalview_configuration_file", filePath };
55     MainFrame aptx = Archaeopteryx.main(AptxArgs);
56     ArchaeopteryxInit.bindFrameToJalview(aptx);
57     return aptx;
58
59
60   }
61 }
62
63 /**
64  * Mostly refactored from Archaeopteryx.main() and
65  * MainFrameApplication.readPhylogeniesFromFile()
66  */
67 // boolean nhx_or_nexus = false;
68 // Configuration config = new Configuration(
69 // "_aptx_jalview_configuration_file", false, false, false);
70 // try
71 // {
72 // final PhylogenyParser p = ParserUtils.createParserDependingOnFileType(
73 // file, config.isValidatePhyloXmlAgainstSchema());
74 //
75 // if (p instanceof NHXParser)
76 // {
77 // nhx_or_nexus = true;
78 // final NHXParser nhx = (NHXParser) p;
79 // nhx.setReplaceUnderscores(false);
80 // nhx.setIgnoreQuotes(false);
81 // nhx.setTaxonomyExtraction(config.getTaxonomyExtraction());
82 // }
83 // else if (p instanceof NexusPhylogeniesParser)
84 // {
85 // nhx_or_nexus = true;
86 // final NexusPhylogeniesParser nex = (NexusPhylogeniesParser) p;
87 // nex.setReplaceUnderscores(config.isReplaceUnderscoresInNhParsing());
88 // nex.setIgnoreQuotes(false);
89 // }
90 // else if (p instanceof PhyloXmlParser)
91 // {
92 //
93 // }
94 // Phylogeny[] phylogenies = PhylogenyMethods.readPhylogenies(p, file);
95 // if (nhx_or_nexus
96 // && config.isInternalNumberAreConfidenceForNhParsing())
97 // {
98 // for (final Phylogeny phy : phylogenies)
99 // {
100 // PhylogenyMethods.transferInternalNodeNamesToConfidence(phy, "");
101 //
102 // }
103 // }
104 // }
105 //
106 // catch (IOException e)
107 // {
108 // // TODO Auto-generated catch block
109 // e.printStackTrace();
110 // }
111 // }
112
113
114
115
116
117