git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
JAL-4134 compute normalised dot product for contact matrix similarities
[jalview.git]
/
src
/
jalview
/
gui
/
TreeCanvas.java
diff --git
a/src/jalview/gui/TreeCanvas.java
b/src/jalview/gui/TreeCanvas.java
index
40cf080
..
a1bcebd
100755
(executable)
--- a/
src/jalview/gui/TreeCanvas.java
+++ b/
src/jalview/gui/TreeCanvas.java
@@
-50,6
+50,7
@@
import javax.swing.ToolTipManager;
import jalview.analysis.Conservation;
import jalview.analysis.TreeModel;
import jalview.api.AlignViewportI;
import jalview.analysis.Conservation;
import jalview.analysis.TreeModel;
import jalview.api.AlignViewportI;
+import jalview.datamodel.BinaryNode;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
@@
-106,9
+107,9
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
Map<Object, Rectangle> nameHash = new Hashtable<>();
Map<Object, Rectangle> nameHash = new Hashtable<>();
- Map<SequenceNode, Rectangle> nodeHash = new Hashtable<>();
+ Map<BinaryNode, Rectangle> nodeHash = new Hashtable<>();
- SequenceNode highlightNode;
+ BinaryNode highlightNode;
boolean applyToAllViews = false;
boolean applyToAllViews = false;
@@
-173,15
+174,15
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
tree.findHeight(tree.getTopNode());
// Now have to calculate longest name based on the leaves
tree.findHeight(tree.getTopNode());
// Now have to calculate longest name based on the leaves
- Vector<SequenceNode> leaves = tree.findLeaves(tree.getTopNode());
+ Vector<BinaryNode> leaves = tree.findLeaves(tree.getTopNode());
boolean has_placeholders = false;
longestName = "";
for (int i = 0; i < leaves.size(); i++)
{
boolean has_placeholders = false;
longestName = "";
for (int i = 0; i < leaves.size(); i++)
{
- SequenceNode lf = leaves.elementAt(i);
+ BinaryNode lf = leaves.elementAt(i);
- if (lf.isPlaceholder())
+ if (lf instanceof SequenceNode && ((SequenceNode)lf).isPlaceholder())
{
has_placeholders = true;
}
{
has_placeholders = true;
}
@@
-215,7
+216,7
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
* @param offy
* DOCUMENT ME!
*/
* @param offy
* DOCUMENT ME!
*/
- public void drawNode(Graphics g, SequenceNode node, float chunk,
+ public void drawNode(Graphics g, BinaryNode node, float chunk,
double wscale, int width, int offx, int offy)
{
if (node == null)
double wscale, int width, int offx, int offy)
{
if (node == null)
@@
-259,7
+260,7
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
if (showDistances && (node.dist > 0))
{
if (showDistances && (node.dist > 0))
{
- nodeLabel = new Format("%-.2f").form(node.dist);
+ nodeLabel = new Format("%g").form(node.dist);
}
if (showBootstrap && node.bootstrap > -1)
}
if (showBootstrap && node.bootstrap > -1)
@@
-277,7
+278,7
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
g.drawString(nodeLabel, xstart + 2, ypos - 2);
}
g.drawString(nodeLabel, xstart + 2, ypos - 2);
}
- String name = (markPlaceholders && node.isPlaceholder())
+ String name = (markPlaceholders && ((node instanceof SequenceNode && ((SequenceNode)node).isPlaceholder())))
? (PLACEHOLDER + node.getName())
: node.getName();
? (PLACEHOLDER + node.getName())
: node.getName();
@@
-306,9
+307,9
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
}
else
{
}
else
{
- drawNode(g, (SequenceNode) node.left(), chunk, wscale, width, offx,
+ drawNode(g, (BinaryNode) node.left(), chunk, wscale, width, offx,
offy);
offy);
- drawNode(g, (SequenceNode) node.right(), chunk, wscale, width, offx,
+ drawNode(g, (BinaryNode) node.right(), chunk, wscale, width, offx,
offy);
double height = node.height;
offy);
double height = node.height;
@@
-332,9
+333,9
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
}
int ystart = (node.left() == null ? 0
}
int ystart = (node.left() == null ? 0
- : (int) (((SequenceNode) node.left()).ycount * chunk)) + offy;
+ : (int) (((BinaryNode) node.left()).ycount * chunk)) + offy;
int yend = (node.right() == null ? 0
int yend = (node.right() == null ? 0
- : (int) (((SequenceNode) node.right()).ycount * chunk))
+ : (int) (((BinaryNode) node.right()).ycount * chunk))
+ offy;
Rectangle pos = new Rectangle(xend - 2, ypos - 2, 5, 5);
+ offy;
Rectangle pos = new Rectangle(xend - 2, ypos - 2, 5, 5);
@@
-347,7
+348,7
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
if (showDistances && (node.dist > 0))
{
if (showDistances && (node.dist > 0))
{
- nodeLabel = new Format("%-.2f").form(node.dist);
+ nodeLabel = new Format("%g").form(node.dist);
}
if (showBootstrap && node.bootstrap > -1)
}
if (showBootstrap && node.bootstrap > -1)
@@
-390,7
+391,7
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
}
}
}
}
- for (Entry<SequenceNode, Rectangle> entry : nodeHash.entrySet())
+ for (Entry<BinaryNode, Rectangle> entry : nodeHash.entrySet())
{
Rectangle rect = entry.getValue();
{
Rectangle rect = entry.getValue();
@@
-415,14
+416,14
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
int width = getWidth();
int height = getHeight();
int width = getWidth();
int height = getHeight();
- SequenceNode top = tree.getTopNode();
+ BinaryNode top = tree.getTopNode();
double wscale = ((width * .8) - (offx * 2)) / tree.getMaxHeight();
if (top.count == 0)
{
double wscale = ((width * .8) - (offx * 2)) / tree.getMaxHeight();
if (top.count == 0)
{
- top.count = ((SequenceNode) top.left()).count
- + ((SequenceNode) top.right()).count;
+ top.count = ((BinaryNode) top.left()).count
+ + ((BinaryNode) top.right()).count;
}
float chunk = (float) (height - (offy)) / top.count;
}
float chunk = (float) (height - (offy)) / top.count;
@@
-448,7
+449,7
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
* @param offy
* DOCUMENT ME!
*/
* @param offy
* DOCUMENT ME!
*/
- public void pickNode(Rectangle pickBox, SequenceNode node, float chunk,
+ public void pickNode(Rectangle pickBox, BinaryNode node, float chunk,
double wscale, int width, int offx, int offy)
{
if (node == null)
double wscale, int width, int offx, int offy)
{
if (node == null)
@@
-459,8
+460,8
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
if ((node.left() == null) && (node.right() == null))
{
double height = node.height;
if ((node.left() == null) && (node.right() == null))
{
double height = node.height;
-// double dist = node.dist;
-// int xstart = (int) ((height - dist) * wscale) + offx;
+ // double dist = node.dist;
+ // int xstart = (int) ((height - dist) * wscale) + offx;
int xend = (int) (height * wscale) + offx;
int ypos = (int) (node.ycount * chunk) + offy;
int xend = (int) (height * wscale) + offx;
int ypos = (int) (node.ycount * chunk) + offy;
@@
-481,9
+482,9
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
}
else
{
}
else
{
- pickNode(pickBox, (SequenceNode) node.left(), chunk, wscale, width,
+ pickNode(pickBox, (BinaryNode) node.left(), chunk, wscale, width,
offx, offy);
offx, offy);
- pickNode(pickBox, (SequenceNode) node.right(), chunk, wscale, width,
+ pickNode(pickBox, (BinaryNode) node.right(), chunk, wscale, width,
offx, offy);
}
}
offx, offy);
}
}
@@
-496,7
+497,7
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
* @param c
* DOCUMENT ME!
*/
* @param c
* DOCUMENT ME!
*/
- public void setColor(SequenceNode node, Color c)
+ public void setColor(BinaryNode node, Color c)
{
if (node == null)
{
{
if (node == null)
{
@@
-516,8
+517,8
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
}
}
}
}
}
}
- setColor((SequenceNode) node.left(), c);
- setColor((SequenceNode) node.right(), c);
+ setColor((BinaryNode) node.left(), c);
+ setColor((BinaryNode) node.right(), c);
}
/**
}
/**
@@
-713,12
+714,12
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
double wscale = (width - labelLength - (offx * 2))
/ tree.getMaxHeight();
double wscale = (width - labelLength - (offx * 2))
/ tree.getMaxHeight();
- SequenceNode top = tree.getTopNode();
+ BinaryNode top = tree.getTopNode();
if (top.count == 0)
{
if (top.count == 0)
{
- top.count = ((SequenceNode) top.left()).count
- + ((SequenceNode) top.right()).count;
+ top.count = ((BinaryNode) top.left()).count
+ + ((BinaryNode) top.right()).count;
}
float chunk = (float) (height - (offy)) / top.count;
}
float chunk = (float) (height - (offy)) / top.count;
@@
-804,7
+805,7
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
}
else
{
}
else
{
- Vector<SequenceNode> leaves = tree.findLeaves(highlightNode);
+ Vector<BinaryNode> leaves = tree.findLeaves(highlightNode);
for (int i = 0; i < leaves.size(); i++)
{
for (int i = 0; i < leaves.size(); i++)
{
@@
-826,7
+827,8
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
void chooseSubtreeColour()
{
String ttl = MessageManager.getString("label.select_subtree_colour");
void chooseSubtreeColour()
{
String ttl = MessageManager.getString("label.select_subtree_colour");
- ColourChooserListener listener = new ColourChooserListener() {
+ ColourChooserListener listener = new ColourChooserListener()
+ {
@Override
public void colourSelected(Color c)
{
@Override
public void colourSelected(Color c)
{
@@
-835,7
+837,8
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
repaint();
}
};
repaint();
}
};
- JalviewColourChooser.showColourChooser(this, ttl, highlightNode.color, listener);
+ JalviewColourChooser.showColourChooser(this, ttl, highlightNode.color,
+ listener);
}
@Override
}
@Override
@@
-845,9
+848,9
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
Object ob = findElement(evt.getX(), evt.getY());
Object ob = findElement(evt.getX(), evt.getY());
- if (ob instanceof SequenceNode)
+ if (ob instanceof BinaryNode)
{
{
- highlightNode = (SequenceNode) ob;
+ highlightNode = (BinaryNode) ob;
this.setToolTipText(
"<html>" + MessageManager.getString("label.highlightnode"));
repaint();
this.setToolTipText(
"<html>" + MessageManager.getString("label.highlightnode"));
repaint();
@@
-914,12
+917,13
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
if (ob instanceof SequenceI)
{
treeSelectionChanged((Sequence) ob);
if (ob instanceof SequenceI)
{
treeSelectionChanged((Sequence) ob);
- PaintRefresher.Refresh(tp, getAssociatedPanel().av.getSequenceSetId());
+ PaintRefresher.Refresh(tp,
+ getAssociatedPanel().av.getSequenceSetId());
repaint();
av.sendSelection();
return;
}
repaint();
av.sendSelection();
return;
}
- else if (!(ob instanceof SequenceNode))
+ else if (!(ob instanceof BinaryNode))
{
// Find threshold
if (tree.getMaxHeight() != 0)
{
// Find threshold
if (tree.getMaxHeight() != 0)
@@
-927,7
+931,7
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
threshold = (float) (x - offx)
/ (float) (getWidth() - labelLength - (2 * offx));
threshold = (float) (x - offx)
/ (float) (getWidth() - labelLength - (2 * offx));
- List<SequenceNode> groups = tree.groupNodes(threshold);
+ List<BinaryNode> groups = tree.groupNodes(threshold);
setColor(tree.getTopNode(), Color.black);
AlignmentPanel[] aps = getAssociatedPanels();
setColor(tree.getTopNode(), Color.black);
AlignmentPanel[] aps = getAssociatedPanels();
@@
-960,13
+964,14
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
}
}
}
}
- PaintRefresher.Refresh(tp, getAssociatedPanel().av.getSequenceSetId());
+ PaintRefresher.Refresh(tp,
+ getAssociatedPanel().av.getSequenceSetId());
repaint();
}
}
repaint();
}
}
- void colourGroups(List<SequenceNode> groups)
+ void colourGroups(List<BinaryNode> groups)
{
AlignmentPanel[] aps = getAssociatedPanels();
for (int i = 0; i < groups.size(); i++)
{
AlignmentPanel[] aps = getAssociatedPanels();
for (int i = 0; i < groups.size(); i++)
@@
-975,7
+980,7
@@
public class TreeCanvas extends JPanel implements MouseListener, Runnable,
(int) (Math.random() * 255), (int) (Math.random() * 255));
setColor(groups.get(i), col.brighter());
(int) (Math.random() * 255), (int) (Math.random() * 255));
setColor(groups.get(i), col.brighter());
- Vector<SequenceNode> l = tree.findLeaves(groups.get(i));
+ Vector<BinaryNode> l = tree.findLeaves(groups.get(i));
Vector<SequenceI> sequences = new Vector<>();
Vector<SequenceI> sequences = new Vector<>();