/*
- * Jalview - A Sequence Alignment Editor and Viewer
- * Copyright (C) 2007 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
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
+ * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ *
+ * 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 <http://www.gnu.org/licenses/>.
*/
-
package jalview.appletgui;
import java.awt.*;
import jalview.datamodel.*;
import jalview.io.*;
-public class TreePanel
- extends EmbmenuFrame implements ActionListener, ItemListener
+public class TreePanel extends EmbmenuFrame implements ActionListener,
+ ItemListener
{
SequenceI[] seq;
+
String type;
+
String pwtype;
+
int start;
+
int end;
+
TreeCanvas treeCanvas;
+
NJTree tree;
+ AlignmentPanel ap;
+
AlignViewport av;
public NJTree getTree()
{
return tree;
}
+
+ public void finalize() throws Throwable {
+ ap=null;
+ av=null;
+ super.finalize();
+ }
/**
* 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!
+ *
+ * @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(AlignViewport av, String type, String pwtype)
+ public TreePanel(AlignmentPanel ap, String type, String pwtype)
{
try
{
jbInit();
this.setMenuBar(jMenuBar1);
- }
- catch (Exception ex)
+ } catch (Exception ex)
{
ex.printStackTrace();
}
- initTreePanel(av, type, pwtype, null);
+ initTreePanel(ap, type, pwtype, null);
}
/**
* 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!
+ *
+ * @param av
+ * DOCUMENT ME!
+ * @param seqVector
+ * DOCUMENT ME!
+ * @param newtree
+ * DOCUMENT ME!
+ * @param type
+ * DOCUMENT ME!
+ * @param pwtype
+ * DOCUMENT ME!
*/
- public TreePanel(AlignViewport av,
- String type,
- String pwtype,
- NewickFile newtree)
+ public TreePanel(AlignmentPanel ap, String type, String pwtype,
+ NewickFile newtree)
{
try
{
jbInit();
this.setMenuBar(jMenuBar1);
- }
- catch (Exception e)
+ } catch (Exception e)
{
e.printStackTrace();
}
- initTreePanel(av, type, pwtype, newtree);
+ initTreePanel(ap, type, pwtype, newtree);
}
- void initTreePanel(AlignViewport av,
- String type,
- String pwtype,
- NewickFile newTree)
+
+ void initTreePanel(AlignmentPanel ap, String type, String pwtype,
+ NewickFile newTree)
{
- this.av = av;
+ this.ap = ap;
+ this.av = ap.av;
this.type = type;
this.pwtype = pwtype;
-
+ treeCanvas = new TreeCanvas(ap, scrollPane);
TreeLoader tl = new TreeLoader(newTree);
tl.start();
- treeCanvas = new TreeCanvas(av, scrollPane);
embedMenuIfNeeded(treeCanvas);
scrollPane.add(treeCanvas, BorderLayout.CENTER);
}
+
void showOriginalData()
{
- // decide if av alignment is sufficiently different to original data to warrant a new window to be created
- // create new alignmnt window with hidden regions (unhiding hidden regions yields unaligned seqs)
+ // decide if av alignment is sufficiently different to original data to
+ // warrant a new window to be created
+ // create new alignmnt window with hidden regions (unhiding hidden regions
+ // yields unaligned seqs)
// or create a selection box around columns in alignment view
// test Alignment(SeqCigar[])
if (tree.seqData != null)
{
- Object[] alAndColsel = tree.seqData.getAlignmentAndColumnSelection(av.
- getGapCharacter());
+ char gc = '-';
+ try
+ {
+ // we try to get the associated view's gap character
+ // but this may fail if the view was closed...
+ gc = av.getGapCharacter();
+ } catch (Exception ex)
+ {
+ }
+ ;
+ Object[] alAndColsel = tree.seqData
+ .getAlignmentAndColumnSelection(gc);
if (alAndColsel != null && alAndColsel[0] != null)
{
- Alignment al = new Alignment( (SequenceI[]) alAndColsel[0]);
- AlignFrame af = new AlignFrame(al,
- av.applet,
- "Original Data for Tree",
- false);
+ Alignment al = new Alignment((SequenceI[]) alAndColsel[0]);
+ AlignFrame af = new AlignFrame(al, av.applet,
+ "Original Data for Tree", false);
- af.viewport.setHiddenColumns( (ColumnSelection) alAndColsel[1]);
+ af.viewport.setHiddenColumns((ColumnSelection) alAndColsel[1]);
}
}
else
}
}
- class TreeLoader
- extends Thread
+ class TreeLoader extends Thread
{
NewickFile newtree;
+
jalview.datamodel.AlignmentView odata = null;
public TreeLoader(NewickFile newtree)
{
if (odata == null)
{
- tree = new NJTree(av.alignment.getSequencesArray(),
- newtree);
+ tree = new NJTree(av.alignment.getSequencesArray(), newtree);
}
else
{
- tree = new NJTree(av.alignment.getSequencesArray(), odata, newtree);
+ tree = new NJTree(av.alignment.getSequencesArray(), odata,
+ newtree);
}
}
{
int start, end;
SequenceI[] seqs;
- AlignmentView seqStrings = av.getAlignmentView(av.getSelectionGroup() != null);
+ AlignmentView seqStrings = av.getAlignmentView(av
+ .getSelectionGroup() != null);
if (av.getSelectionGroup() == null)
{
start = 0;
treeCanvas.setTree(tree);
if (newtree != null)
{
- distanceMenu.setState(newtree.HasDistances());
- bootstrapMenu.setState(newtree.HasBootstrap());
- treeCanvas.setShowBootstrap(newtree.HasBootstrap());
- treeCanvas.setShowDistances(newtree.HasDistances());
+ // Set default view, paying lip service to any overriding tree view
+ // parameter settings
+ boolean showDist = newtree.HasDistances()
+ && av.applet.getDefaultParameter("showTreeDistances",
+ newtree.HasDistances());
+ boolean showBoots = newtree.HasBootstrap()
+ && av.applet.getDefaultParameter("showTreeBootstraps",
+ newtree.HasBootstrap());
+ distanceMenu.setState(showDist);
+ bootstrapMenu.setState(showBoots);
+ treeCanvas.setShowBootstrap(showBoots);
+ treeCanvas.setShowDistances(showDist);
+ treeCanvas.setMarkPlaceholders(av.applet.getDefaultParameter(
+ "showUnlinkedTreeNodes", false));
}
treeCanvas.repaint();
public void newickOutput_actionPerformed()
{
- jalview.io.NewickFile fout = new jalview.io.NewickFile(tree.getTopNode());
+ jalview.io.NewickFile fout = new jalview.io.NewickFile(
+ tree.getTopNode());
String output = fout.print(false, true);
CutAndPasteTransfer cap = new CutAndPasteTransfer(false, null);
cap.setText(output);
}
BorderLayout borderLayout1 = new BorderLayout();
+
protected ScrollPane scrollPane = new ScrollPane();
+
MenuBar jMenuBar1 = new MenuBar();
+
Menu jMenu2 = new Menu();
+
protected MenuItem fontSize = new MenuItem();
+
protected CheckboxMenuItem bootstrapMenu = new CheckboxMenuItem();
+
protected CheckboxMenuItem distanceMenu = new CheckboxMenuItem();
+
protected CheckboxMenuItem placeholdersMenu = new CheckboxMenuItem();
+
protected CheckboxMenuItem fitToWindow = new CheckboxMenuItem();
+
Menu fileMenu = new Menu();
+
MenuItem newickOutput = new MenuItem();
+
MenuItem inputData = new MenuItem();
- private void jbInit()
- throws Exception
+ private void jbInit() throws Exception
{
setLayout(borderLayout1);
this.setBackground(Color.white);