X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Farchaeopteryx%2FArchaeopteryxInit.java;h=3bd9d1927b1294c35c0a03f0a279078905bdd874;hb=5cdc53bb8a76f6bd364188254e873437d7ac2c7f;hp=04147cee82437227d4f808680666aa932d724eea;hpb=0e50368033402ab4eb49fb7473fbb232d7b6091b;p=jalview.git diff --git a/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java b/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java index 04147ce..3bd9d19 100644 --- a/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java +++ b/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java @@ -1,123 +1,65 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ package jalview.ext.archaeopteryx; -import jalview.analysis.TreeModel; -import jalview.io.NewickFile; +import jalview.analysis.TreeBuilder; +import jalview.gui.Desktop; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.PrintWriter; +import java.awt.Dimension; import org.forester.archaeopteryx.Archaeopteryx; +import org.forester.archaeopteryx.MainFrame; +import org.forester.phylogeny.Phylogeny; -public class ArchaeopteryxInit +public final class ArchaeopteryxInit { - private String filePath = "/tmp/jalviewtree.nwk"; - - private TreeModel tree; - - private NewickFile newickTree; - - public ArchaeopteryxInit(TreeModel jalviewTreeModel) + public static MainFrame createInstance(Phylogeny[] aptxTrees) { - this.tree = jalviewTreeModel; - this.newickTree = treeToNewick(tree); - } + return createBoundAptxFrame(aptxTrees); - public ArchaeopteryxInit(NewickFile newickTreeModel) - { - this.newickTree = newickTreeModel; } - public void startArchaeopteryx() + public static MainFrame createInstance(Phylogeny aptxTree) { - String newickOutput = newickTree.print(newickTree.hasBootstrap(), - newickTree.hasDistances(), newickTree.hasRootDistance()); - - File newickFile = new File(filePath); - PrintWriter writer; + Phylogeny[] aptxTrees = { aptxTree }; // future possibility to load in + // several trees simultaneously + return createBoundAptxFrame(aptxTrees); - try - { - writer = new PrintWriter(newickFile); - writer.println(newickOutput); - - writer.close(); - - String[] commandLineArgs = { "-open", newickFile.getCanonicalPath() }; - Archaeopteryx.main(commandLineArgs); + } - } catch (FileNotFoundException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } + public static MainFrame createInstance( + TreeBuilder calculatedTree) + { + ArchaeopteryxTreeConverter aptxTreeBuilder = new ArchaeopteryxTreeConverter( + calculatedTree); + Phylogeny aptxTree = aptxTreeBuilder.buildAptxTree(); + Phylogeny[] aptxTrees = { aptxTree }; // future possibility to load in + // several trees simultaneously + return createBoundAptxFrame(aptxTrees); } - public String getFilePath() - { - return filePath; - } - - public void setFilePath(String newFilePath) + private static MainFrame createBoundAptxFrame(Phylogeny[] aptxTrees) { - this.filePath = newFilePath; + MainFrame aptxApp = Archaeopteryx.createApplication(aptxTrees, + "_aptx_jalview_configuration_file", null); + return bindFrameToJalview(aptxApp); } - public TreeModel getTree() - { - return tree; - } - public void setTree(TreeModel newTree) - { - this.tree = newTree; - } - public NewickFile getNewickTree() + private static MainFrame bindFrameToJalview(MainFrame aptxApp) { - return newickTree; - } + int width = 400; + int height = 550; + aptxApp.setMinimumSize(new Dimension(width, height)); - public void setNewickTree(NewickFile newNewickTree) - { - this.newickTree = newNewickTree; - } + Desktop.addInternalFrame(aptxApp, "Archaeopteryx Tree View", true, + width, height, true, true); - public static NewickFile treeToNewick(TreeModel tree) - { - NewickFile newickTree = new NewickFile(tree.getTopNode(), - tree.hasBootstrap(), tree.hasDistances(), - tree.hasRootDistance()); + return aptxApp; - return newickTree; } -} \ No newline at end of file + +}