X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fappletgui%2FTreePanel.java;h=671fee1f721f7a550beffa0524d2a594e65bb379;hb=ed512fe4ab6c8a61bbf2e3b9d2b09ea9746af78d;hp=7595a50cc71832fc0cb1625ce439577f52a99f7b;hpb=362f2db1b01f3562784864a1d6ac5f7b9be0a18a;p=jalview.git
diff --git a/src/jalview/appletgui/TreePanel.java b/src/jalview/appletgui/TreePanel.java
index 7595a50..671fee1 100644
--- a/src/jalview/appletgui/TreePanel.java
+++ b/src/jalview/appletgui/TreePanel.java
@@ -1,32 +1,52 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ 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.
- *
+ * 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 .
+ * 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.appletgui;
-import java.awt.*;
-import java.awt.event.*;
-import java.util.Hashtable;
-
-import jalview.analysis.*;
-import jalview.datamodel.*;
-import jalview.io.*;
-
-public class TreePanel extends EmbmenuFrame implements ActionListener,
- ItemListener
+import jalview.analysis.AverageDistanceTree;
+import jalview.analysis.NJTree;
+import jalview.analysis.TreeBuilder;
+import jalview.analysis.TreeModel;
+import jalview.analysis.scoremodels.ScoreModels;
+import jalview.analysis.scoremodels.SimilarityParams;
+import jalview.api.analysis.ScoreModelI;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.SequenceI;
+import jalview.io.NewickFile;
+import jalview.util.MessageManager;
+
+import java.awt.BorderLayout;
+import java.awt.CheckboxMenuItem;
+import java.awt.Color;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
+import java.awt.ScrollPane;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+public class TreePanel extends EmbmenuFrame
+ implements ActionListener, ItemListener, AutoCloseable
{
SequenceI[] seq;
@@ -40,39 +60,29 @@ public class TreePanel extends EmbmenuFrame implements ActionListener,
TreeCanvas treeCanvas;
- NJTree tree;
+ TreeModel tree;
+
AlignmentPanel ap;
AlignViewport av;
- public NJTree getTree()
+ public TreeModel getTree()
{
return tree;
}
-
- public void finalize() throws Throwable {
- ap=null;
- av=null;
- super.finalize();
+
+ @Override
+ public void close()
+ {
+ ap = null;
+ av = null;
+ super.close();
}
/**
* 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)
+ public TreePanel(AlignmentPanel alignPanel, String type, String pwtype)
{
try
{
@@ -83,22 +93,12 @@ public class TreePanel extends EmbmenuFrame implements ActionListener,
ex.printStackTrace();
}
- initTreePanel(ap, type, pwtype, null);
+ initTreePanel(alignPanel, 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!
*/
public TreePanel(AlignmentPanel ap, String type, String pwtype,
NewickFile newtree)
@@ -139,7 +139,7 @@ public class TreePanel extends EmbmenuFrame implements ActionListener,
// yields unaligned seqs)
// or create a selection box around columns in alignment view
// test Alignment(SeqCigar[])
- if (tree.seqData != null)
+ if (tree.getOriginalData() != null)
{
char gc = '-';
try
@@ -150,9 +150,9 @@ public class TreePanel extends EmbmenuFrame implements ActionListener,
} catch (Exception ex)
{
}
- ;
- Object[] alAndColsel = tree.seqData
- .getAlignmentAndColumnSelection(gc);
+
+ Object[] alAndColsel = tree.getOriginalData()
+ .getAlignmentAndHiddenColumns(gc);
if (alAndColsel != null && alAndColsel[0] != null)
{
@@ -160,7 +160,8 @@ public class TreePanel extends EmbmenuFrame implements ActionListener,
AlignFrame af = new AlignFrame(al, av.applet,
"Original Data for Tree", false);
- af.viewport.setHiddenColumns((ColumnSelection) alAndColsel[1]);
+ af.viewport.getAlignment()
+ .setHiddenColumns((HiddenColumns) alAndColsel[1]);
}
}
else
@@ -180,41 +181,23 @@ public class TreePanel extends EmbmenuFrame implements ActionListener,
this.newtree = newtree;
}
+ @Override
public void run()
{
if (newtree != null)
{
- if (odata == null)
- {
- tree = new NJTree(av.alignment.getSequencesArray(), newtree);
- }
- else
- {
- tree = new NJTree(av.alignment.getSequencesArray(), odata,
- newtree);
- }
-
+ tree = new TreeModel(av.getAlignment().getSequencesArray(), odata,
+ newtree);
}
else
{
- int start, end;
- SequenceI[] seqs;
- AlignmentView seqStrings = av.getAlignmentView(av
- .getSelectionGroup() != null);
- if (av.getSelectionGroup() == null)
- {
- start = 0;
- end = av.alignment.getWidth();
- seqs = av.alignment.getSequencesArray();
- }
- else
- {
- start = av.getSelectionGroup().getStartRes();
- end = av.getSelectionGroup().getEndRes() + 1;
- seqs = av.getSelectionGroup().getSequencesInOrder(av.alignment);
- }
-
- tree = new NJTree(seqs, seqStrings, type, pwtype, start, end);
+ ScoreModelI sm1 = ScoreModels.getInstance().getScoreModel(pwtype,
+ treeCanvas.ap);
+ ScoreModelI sm = sm1;
+ TreeBuilder njtree = type.equals(TreeBuilder.NEIGHBOUR_JOINING)
+ ? new NJTree(av, sm, SimilarityParams.Jalview)
+ : new AverageDistanceTree(av, sm, SimilarityParams.Jalview);
+ tree = new TreeModel(njtree);
}
tree.reCount(tree.getTopNode());
@@ -234,8 +217,8 @@ public class TreePanel extends EmbmenuFrame implements ActionListener,
bootstrapMenu.setState(showBoots);
treeCanvas.setShowBootstrap(showBoots);
treeCanvas.setShowDistances(showDist);
- treeCanvas.setMarkPlaceholders(av.applet.getDefaultParameter(
- "showUnlinkedTreeNodes", false));
+ treeCanvas.setMarkPlaceholders(av.applet
+ .getDefaultParameter("showUnlinkedTreeNodes", false));
}
treeCanvas.repaint();
@@ -245,6 +228,7 @@ public class TreePanel extends EmbmenuFrame implements ActionListener,
}
}
+ @Override
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource() == newickOutput)
@@ -261,6 +245,7 @@ public class TreePanel extends EmbmenuFrame implements ActionListener,
}
}
+ @Override
public void itemStateChanged(ItemEvent evt)
{
if (evt.getSource() == fitToWindow)
@@ -348,22 +333,24 @@ public class TreePanel extends EmbmenuFrame implements ActionListener,
setLayout(borderLayout1);
this.setBackground(Color.white);
this.setFont(new java.awt.Font("Verdana", 0, 12));
- jMenu2.setLabel("View");
- fontSize.setLabel("Font...");
+ jMenu2.setLabel(MessageManager.getString("action.view"));
+ fontSize.setLabel(MessageManager.getString("action.font"));
fontSize.addActionListener(this);
- bootstrapMenu.setLabel("Show Bootstrap Values");
+ bootstrapMenu.setLabel(
+ MessageManager.getString("label.show_bootstrap_values"));
bootstrapMenu.addItemListener(this);
- distanceMenu.setLabel("Show Distances");
+ distanceMenu.setLabel(MessageManager.getString("label.show_distances"));
distanceMenu.addItemListener(this);
- placeholdersMenu.setLabel("Mark Unassociated Leaves");
+ placeholdersMenu.setLabel(
+ MessageManager.getString("label.mark_unassociated_leaves"));
placeholdersMenu.addItemListener(this);
fitToWindow.setState(true);
- fitToWindow.setLabel("Fit To Window");
+ fitToWindow.setLabel(MessageManager.getString("label.fit_to_window"));
fitToWindow.addItemListener(this);
- fileMenu.setLabel("File");
- newickOutput.setLabel("Newick Format");
+ fileMenu.setLabel(MessageManager.getString("action.file"));
+ newickOutput.setLabel(MessageManager.getString("label.newick_format"));
newickOutput.addActionListener(this);
- inputData.setLabel("Input Data...");
+ inputData.setLabel(MessageManager.getString("label.input_data"));
add(scrollPane, BorderLayout.CENTER);
jMenuBar1.add(fileMenu);