/* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2006 AM Waterhouse, J Procter, 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 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. * * 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 */ package jalview.gui; import jalview.analysis.*; import jalview.datamodel.*; import jalview.io.*; import jalview.jbgui.*; import org.jibble.epsgraphics.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.io.*; import java.util.*; import javax.swing.*; import javax.imageio.*; import java.beans.PropertyChangeEvent; /** * DOCUMENT ME! * * @author $author$ * @version $Revision$ */ public class TreePanel extends GTreePanel { String type; String pwtype; TreeCanvas treeCanvas; NJTree tree; AlignViewport av; /** * Creates a new TreePanel object. * * @param av DOCUMENT ME! * @param seqVector DOCUMENT ME! * @param type DOCUMENT ME! * @param pwtype DOCUMENT ME! * @param s DOCUMENT ME! * @param e DOCUMENT ME! */ public TreePanel(AlignmentPanel ap, String type, String pwtype) { super(); initTreePanel(ap, type, pwtype, null, null); // We know this tree has distances. JBPNote TODO: prolly should add this as a userdefined default // showDistances(true); } /** * Creates a new TreePanel object. * * @param av DOCUMENT ME! * @param seqVector DOCUMENT ME! * @param newtree DOCUMENT ME! * @param type DOCUMENT ME! * @param pwtype DOCUMENT ME! */ public TreePanel(AlignmentPanel ap, String type, String pwtype, NewickFile newtree) { super(); initTreePanel(ap, type, pwtype, newtree, null); } public TreePanel(AlignmentPanel av, String type, String pwtype, NewickFile newtree, AlignmentView inputData) { super(); initTreePanel(av,type,pwtype,newtree,inputData); } public AlignmentI getAlignment() { return treeCanvas.av.getAlignment(); } public AlignViewport getViewPort() { return treeCanvas.av; } void initTreePanel(AlignmentPanel ap, String type, String pwtype, NewickFile newTree, AlignmentView inputData) { av = ap.av; this.type = type; this.pwtype = pwtype; treeCanvas = new TreeCanvas(this, ap, scrollPane); scrollPane.setViewportView(treeCanvas); PaintRefresher.Register(this, ap.av.getSequenceSetId()); buildAssociatedViewMenu(); av.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("alignment")) { if(tree==null) System.out.println("tree is null"); if(evt.getNewValue()==null) System.out.println("new alignment sequences vector value is null"); tree.UpdatePlaceHolders( (Vector) evt.getNewValue()); treeCanvas.nameHash.clear(); // reset the mapping between canvas rectangles and leafnodes repaint(); } } }); TreeLoader tl = new TreeLoader(newTree); if (inputData!=null) { tl.odata=inputData; } tl.start(); } public void viewMenu_menuSelected() { buildAssociatedViewMenu(); } void buildAssociatedViewMenu() { AlignmentPanel [] aps = PaintRefresher.getAssociatedPanels(av.getSequenceSetId()); if(aps.length==1 && treeCanvas.ap==aps[0]) { associateLeavesMenu.setVisible(false); return; } associateLeavesMenu.setVisible(true); if( (viewMenu.getItem(viewMenu.getItemCount()-2) instanceof JMenuItem)) { viewMenu.insertSeparator(viewMenu.getItemCount()-1); } associateLeavesMenu.removeAll(); JRadioButtonMenuItem item; ButtonGroup buttonGroup = new ButtonGroup(); int i, iSize = aps.length; final TreePanel thisTreePanel = this; for(i=0; i