X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Farchaeopteryx%2FArchaeopteryxInit.java;h=3bd9d1927b1294c35c0a03f0a279078905bdd874;hb=1b929b92d3e782165fb17776a6fadd8aa447c760;hp=8fdf83a0f8e1890ba0e905c67b30ab727d5c8d7f;hpb=8dbf6e85ebb3dbcd84635f194457cd4dc65010cf;p=jalview.git diff --git a/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java b/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java index 8fdf83a..3bd9d19 100644 --- a/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java +++ b/src/jalview/ext/archaeopteryx/ArchaeopteryxInit.java @@ -1,129 +1,65 @@ -/******************************************************************************* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $(date) 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); - - // System.out.println(writer.checkError()); - 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() + private static MainFrame createBoundAptxFrame(Phylogeny[] aptxTrees) { - return filePath; + MainFrame aptxApp = Archaeopteryx.createApplication(aptxTrees, + "_aptx_jalview_configuration_file", null); + return bindFrameToJalview(aptxApp); } - public void setFilePath(String newFilePath) - { - this.filePath = newFilePath; - } - public TreeModel getTree() - { - return tree; - } - public void setTree(TreeModel newTree) + private static MainFrame bindFrameToJalview(MainFrame aptxApp) { - this.tree = newTree; - } + int width = 400; + int height = 550; + aptxApp.setMinimumSize(new Dimension(width, height)); - public NewickFile getNewickTree() - { - return newickTree; - } + Desktop.addInternalFrame(aptxApp, "Archaeopteryx Tree View", true, + width, height, true, true); - public void setNewickTree(NewickFile newNewickTree) - { - this.newickTree = newNewickTree; - } + return aptxApp; - public static NewickFile treeToNewick(TreeModel tree) - { - NewickFile newickTree = new NewickFile(tree.getTopNode(), - tree.hasBootstrap(), tree.hasDistances(), - tree.hasRootDistance()); - /* System.out.println(newickTree.print(tree.hasBootstrap(), - tree.hasDistances(), tree.hasRootDistance())); - - System.out.println(newickTree.print(newickTree.hasBootstrap(), - newickTree.hasDistances(), newickTree.hasRootDistance()));*/ - - return newickTree; } -} \ No newline at end of file + +}