X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FTreeCanvas.java;h=028552c27b3d9e30787d466f872d8b0dde951265;hb=b600601cfc5f7d03b8793a1d32ffa78c0fbab8cd;hp=dc08b9ad084f3a6cf2b41150dd4f32661eea0bf3;hpb=1b032d3acf34d0c4166c84366f89e29ff4c784eb;p=jalview.git
diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java
index dc08b9a..c1a6b0a 100755
--- a/src/jalview/gui/TreeCanvas.java
+++ b/src/jalview/gui/TreeCanvas.java
@@ -1,881 +1,1410 @@
/*
- * 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
+ * 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.
- *
- * 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 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
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.gui;
-import jalview.analysis.*;
-
-import jalview.datamodel.*;
-
-import jalview.schemes.*;
-
-import jalview.util.*;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.print.*;
-
-import java.util.*;
-
-import javax.swing.*;
-
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.print.PageFormat;
+import java.awt.print.Printable;
+import java.awt.print.PrinterException;
+import java.awt.print.PrinterJob;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Vector;
+
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.SwingUtilities;
+import javax.swing.ToolTipManager;
+
+import jalview.analysis.Conservation;
+import jalview.analysis.TreeModel;
+import jalview.api.AlignViewportI;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.Annotation;
+import jalview.datamodel.BinaryNode;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.ContactMatrixI;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+import jalview.datamodel.SequenceNode;
+import jalview.gui.JalviewColourChooser.ColourChooserListener;
+import jalview.schemes.ColourSchemeI;
+import jalview.structure.SelectionSource;
+import jalview.util.Format;
+import jalview.util.MessageManager;
+import jalview.ws.datamodel.MappableContactMatrixI;
/**
* DOCUMENT ME!
- *
+ *
* @author $author$
* @version $Revision$
*/
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
- Printable, MouseMotionListener
+ Printable, MouseMotionListener, SelectionSource
{
- /** DOCUMENT ME!! */
- public static final String PLACEHOLDER = " * ";
- NJTree tree;
- JScrollPane scrollPane;
- AlignViewport av;
- AlignmentPanel ap;
- Font font;
- FontMetrics fm;
- boolean fitToWindow = true;
- boolean showDistances = false;
- boolean showBootstrap = false;
- boolean markPlaceholders = false;
- int offx = 20;
- int offy;
- float threshold;
- String longestName;
- int labelLength = -1;
-
- Hashtable nameHash = new Hashtable();
- Hashtable nodeHash = new Hashtable();
- SequenceNode highlightNode;
-
- /**
- * Creates a new TreeCanvas object.
- *
- * @param av DOCUMENT ME!
- * @param tree DOCUMENT ME!
- * @param scroller DOCUMENT ME!
- * @param label DOCUMENT ME!
- */
- public TreeCanvas(AlignmentPanel ap, JScrollPane scroller)
- {
- this.av = ap.av;
- this.ap = ap;
- font = av.getFont();
- scrollPane = scroller;
- addMouseListener(this);
- addMouseMotionListener(this);
- PaintRefresher.Register(this, ap.av.getSequenceSetId());
- ToolTipManager.sharedInstance().registerComponent(this);
- }
+ /** DOCUMENT ME!! */
+ public static final String PLACEHOLDER = " * ";
+ TreeModel tree;
- /**
- * DOCUMENT ME!
- *
- * @param sequence DOCUMENT ME!
- */
- public void treeSelectionChanged(SequenceI sequence)
- {
- SequenceGroup selected = av.getSelectionGroup();
+ JScrollPane scrollPane;
- if (selected == null)
- {
- selected = new SequenceGroup();
- av.setSelectionGroup(selected);
- }
+ TreePanel tp;
- selected.setEndRes(av.alignment.getWidth()-1);
- selected.addOrRemove(sequence, true);
- }
+ private AlignViewport av;
- /**
- * DOCUMENT ME!
- *
- * @param tree DOCUMENT ME!
- */
- public void setTree(NJTree tree)
- {
- this.tree = tree;
- tree.findHeight(tree.getTopNode());
+ private AlignmentPanel ap;
- // Now have to calculate longest name based on the leaves
- Vector leaves = tree.findLeaves(tree.getTopNode(), new Vector());
- boolean has_placeholders = false;
- longestName = "";
+ Font font;
- for (int i = 0; i < leaves.size(); i++)
- {
- SequenceNode lf = (SequenceNode) leaves.elementAt(i);
+ FontMetrics fm;
- if (lf.isPlaceholder())
- {
- has_placeholders = true;
- }
+ boolean fitToWindow = true;
- if (longestName.length() < ( (Sequence) lf.element()).getName()
- .length())
- {
- longestName = TreeCanvas.PLACEHOLDER +
- ( (Sequence) lf.element()).getName();
- }
- }
+ boolean showDistances = false;
- setMarkPlaceholders(has_placeholders);
- }
+ boolean showBootstrap = false;
- /**
- * DOCUMENT ME!
- *
- * @param g DOCUMENT ME!
- * @param node DOCUMENT ME!
- * @param chunk DOCUMENT ME!
- * @param scale DOCUMENT ME!
- * @param width DOCUMENT ME!
- * @param offx DOCUMENT ME!
- * @param offy DOCUMENT ME!
- */
- public void drawNode(Graphics g, SequenceNode node, float chunk,
- float scale, int width, int offx, int offy)
- {
- if (node == null)
- {
- return;
- }
+ boolean markPlaceholders = false;
- if ((node.left() == null) && (node.right() == null))
- {
- // Drawing leaf node
- float height = node.height;
- float dist = node.dist;
+ int offx = 20;
- int xstart = (int) ((height - dist) * scale) + offx;
- int xend = (int) (height * scale) + offx;
+ int offy;
- int ypos = (int) (node.ycount * chunk) + offy;
+ private float threshold;
- if (node.element() instanceof SequenceI)
- {
- SequenceI seq = (SequenceI)((SequenceNode) node).element();
-
- if (av.getSequenceColour(seq) == Color.white)
- {
- g.setColor(Color.black);
- }
- else
- {
- g.setColor(av.getSequenceColour(seq).darker());
- }
- }
- else
- {
- g.setColor(Color.black);
- }
+ String longestName;
- // Draw horizontal line
- g.drawLine(xstart, ypos, xend, ypos);
+ int labelLength = -1;
- String nodeLabel = "";
+ Map