X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FTreePanel.java;h=45fc0df055332438c83276ef852bc688e13fbcb1;hb=94e5a196ee42f9571348786abd0ee727014b65ae;hp=eef07fa999254bfb99c0ef2d40a4edc80ffc5f62;hpb=431b44bc25f290de99d6edd1f7f22c28f0f4d467;p=jalview.git diff --git a/src/jalview/gui/TreePanel.java b/src/jalview/gui/TreePanel.java index eef07fa..45fc0df 100755 --- a/src/jalview/gui/TreePanel.java +++ b/src/jalview/gui/TreePanel.java @@ -1,20 +1,19 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) - * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5) + * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle * - * This program 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 2 - * of the License, or (at your option) any later version. + * This file is part of Jalview. * - * This program 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. + * 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. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * 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 . */ package jalview.gui; @@ -141,6 +140,10 @@ public class TreePanel extends GTreePanel if (tree == null) { System.out.println("tree is null"); + // TODO: deal with case when a change event is received whilst a + // tree is still being calculated - should save reference for + // processing message later. + return; } if (evt.getNewValue() == null) { @@ -493,6 +496,7 @@ public class TreePanel extends GTreePanel /** * sort the associated alignment view by the current tree. + * * @param e */ public void sortByTree_actionPerformed(ActionEvent e) @@ -501,9 +505,8 @@ public class TreePanel extends GTreePanel SequenceI[] oldOrder = av.getAlignment().getSequencesArray(); AlignmentSorter.sortByTree(av.getAlignment(), tree); - ap.alignFrame - .addHistoryItem(new OrderCommand("Tree Sort", oldOrder, - av.alignment)); + ap.alignFrame.addHistoryItem(new OrderCommand("Tree Sort", oldOrder, + av.alignment)); ap.paintAlignment(true); @@ -690,55 +693,68 @@ public class TreePanel extends GTreePanel ex.printStackTrace(); } } + /** - * change node labels to the annotation referred to by labelClass - * TODO: promote to a datamodel modification that can be undone - * TODO: make argument one case of a generic transformation function ie { undoStep = apply(Tree, TransformFunction)}; + * change node labels to the annotation referred to by labelClass TODO: + * promote to a datamodel modification that can be undone TODO: make argument + * one case of a generic transformation function ie { undoStep = apply(Tree, + * TransformFunction)}; + * * @param labelClass */ public void changeNames(final String labelClass) { - tree.applyToNodes(new NodeTransformI() { + tree.applyToNodes(new NodeTransformI() + { public void transform(BinaryNode node) { - if (node instanceof SequenceNode && !((SequenceNode) node).isPlaceholder() && !((SequenceNode) node).isDummy()) + if (node instanceof SequenceNode + && !((SequenceNode) node).isPlaceholder() + && !((SequenceNode) node).isDummy()) { - String newname=null; + String newname = null; SequenceI sq = (SequenceI) ((SequenceNode) node).element(); - if (sq!=null) + if (sq != null) { // search dbrefs, features and annotation - DBRefEntry[] refs = jalview.util.DBRefUtils.selectRefs(sq.getDBRef(), new String[] {labelClass.toUpperCase()}); - if (refs!=null) + DBRefEntry[] refs = jalview.util.DBRefUtils.selectRefs(sq + .getDBRef(), new String[] + { labelClass.toUpperCase() }); + if (refs != null) { - for (int i=0; i