X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FTreePanel.java;h=e8f78d83d546cd7006bc718769d901dc9aef0e1f;hb=91bea2a1185e438bfd52fc1848cf615068016192;hp=366b97f202712e0084b30b1f4b1524e446f12a88;hpb=0e50368033402ab4eb49fb7473fbb232d7b6091b;p=jalview.git diff --git a/src/jalview/gui/TreePanel.java b/src/jalview/gui/TreePanel.java index 366b97f..e8f78d8 100755 --- a/src/jalview/gui/TreePanel.java +++ b/src/jalview/gui/TreePanel.java @@ -21,13 +21,7 @@ package jalview.gui; import jalview.analysis.AlignmentSorter; -import jalview.analysis.AverageDistanceTree; -import jalview.analysis.NJTree; -import jalview.analysis.TreeBuilder; import jalview.analysis.TreeModel; -import jalview.analysis.scoremodels.ScoreModels; -import jalview.api.analysis.ScoreModelI; -import jalview.api.analysis.SimilarityParamsI; import jalview.bin.Cache; import jalview.commands.CommandI; import jalview.commands.OrderCommand; @@ -41,7 +35,6 @@ import jalview.datamodel.NodeTransformI; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.datamodel.SequenceNode; -import jalview.ext.archaeopteryx.ArchaeopteryxInit; import jalview.io.JalviewFileChooser; import jalview.io.JalviewFileView; import jalview.io.NewickFile; @@ -75,14 +68,12 @@ import org.jibble.epsgraphics.EpsGraphics2D; */ public class TreePanel extends GTreePanel { - String treeType; + String substitutionMatrix; - String scoreModelName; // if tree computed + String treeType; String treeTitle; // if tree loaded - SimilarityParamsI similarityParams; - TreeCanvas treeCanvas; TreeModel tree; @@ -93,28 +84,38 @@ public class TreePanel extends GTreePanel * Creates a new TreePanel object. * * @param ap - * @param type - * @param modelName - * @param options + * @param tree + * @param treeType + * @param substitutionMatrix */ - public TreePanel(AlignmentPanel ap, String type, String modelName, - SimilarityParamsI options) + public TreePanel(AlignmentPanel ap, TreeModel tree, String treeType, + String substitutionMatrix) { super(); - this.similarityParams = options; - initTreePanel(ap, type, modelName, null, null); + this.treeType = treeType; + this.substitutionMatrix = substitutionMatrix; + this.tree = tree; + initTreePanel(ap, tree); // We know this tree has distances. JBPNote TODO: prolly should add this as // a userdefined default // showDistances(true); } + /** + * Creates a new TreePanel object. + * + * @param alignPanel + * @param newtree + * @param theTitle + * @param inputData + */ public TreePanel(AlignmentPanel alignPanel, NewickFile newtree, String theTitle, AlignmentView inputData) { super(); this.treeTitle = theTitle; - initTreePanel(alignPanel, null, null, newtree, inputData); + initTreePanel(alignPanel, newtree, inputData); } public AlignmentI getAlignment() @@ -127,17 +128,44 @@ public class TreePanel extends GTreePanel return treeCanvas.av; } - void initTreePanel(AlignmentPanel ap, String type, String modelName, - NewickFile newTree, AlignmentView inputData) + /** + * Initialize a tree panel based on a calculated tree + * + * @param ap + * @param tree + */ + void initTreePanel(AlignmentPanel ap, TreeModel tree) + { + buildTreeCanvas(ap); + + TreeLoader tl = new TreeLoader(null, null); + tl.start(); + + } + + /** + * Initialize a tree panel based on a loaded in tree file. + * + * @param ap + * @param loadedTree + * @param inputData + */ + void initTreePanel(AlignmentPanel ap, + NewickFile loadedTree, AlignmentView inputData) { + buildTreeCanvas(ap); + + TreeLoader tl = new TreeLoader(loadedTree, inputData); + tl.start(); + } - av = ap.av; - this.treeType = type; - this.scoreModelName = modelName; +public void buildTreeCanvas(AlignmentPanel ap) { + av = ap.av; treeCanvas = new TreeCanvas(this, ap, scrollPane); scrollPane.setViewportView(treeCanvas); + PaintRefresher.Register(this, ap.av.getSequenceSetId()); buildAssociatedViewMenu(); @@ -172,8 +200,7 @@ public class TreePanel extends GTreePanel }); - TreeLoader tl = new TreeLoader(newTree, inputData); - tl.start(); + } @@ -281,22 +308,12 @@ public class TreePanel extends GTreePanel } - else - { - ScoreModelI sm = ScoreModels.getInstance() - .getScoreModel(scoreModelName, treeCanvas.ap); - TreeBuilder njtree = treeType.equals(TreeBuilder.NEIGHBOUR_JOINING) - ? new NJTree(av, sm, similarityParams) - : new AverageDistanceTree(av, sm, similarityParams); - tree = new TreeModel(njtree); - showDistances(true); - - - - } - ArchaeopteryxInit archae = new ArchaeopteryxInit(tree); - archae.startArchaeopteryx(); + showTree(tree); + } + + public void showTree(TreeModel tree) + { tree.reCount(tree.getTopNode()); tree.findHeight(tree.getTopNode()); treeCanvas.setTree(tree); @@ -307,6 +324,7 @@ public class TreePanel extends GTreePanel { sortByTree_actionPerformed(); } + } } @@ -501,7 +519,7 @@ public class TreePanel extends GTreePanel * @param e */ @Override - public void sortByTree_actionPerformed() + public void sortByTree_actionPerformed()// modify for Aptx { if (treeCanvas.applyToAllViews) @@ -563,13 +581,14 @@ public class TreePanel extends GTreePanel public CommandI sortAlignmentIn(AlignmentPanel ap) { + // TODO: move to alignment view controller AlignmentViewport viewport = ap.av; SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray(); AlignmentSorter.sortByTree(viewport.getAlignment(), tree); CommandI undo; undo = new OrderCommand("Tree Sort", oldOrder, viewport.getAlignment()); - ap.paintAlignment(true); + ap.paintAlignment(true, false); return undo; } @@ -841,29 +860,31 @@ public class TreePanel extends GTreePanel * * @return */ - public String getPanelTitle() + public String getPanelTitle() // to be moved/fixed { if (treeTitle != null) { return treeTitle; } - - /* - * i18n description of Neighbour Joining or Average Distance method - */ - String treecalcnm = MessageManager - .getString("label.tree_calc_" + treeType.toLowerCase()); - - /* - * short score model name (long description can be too long) - */ - String smn = scoreModelName; - - /* - * put them together as Using - */ - final String ttl = MessageManager.formatMessage("label.treecalc_title", - treecalcnm, smn); - return ttl; + else + { + /* + * i18n description of Neighbour Joining or Average Distance method + */ + String treecalcnm = MessageManager + .getString("label.tree_calc_" + treeType.toLowerCase()); + + /* + * short score model name (long description can be too long) + */ + String smn = substitutionMatrix; + + /* + * put them together as Using + */ + final String ttl = MessageManager + .formatMessage("label.treecalc_title", treecalcnm, smn); + return ttl; + } } }