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;
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;
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++)
{
- SequenceNode lf = leaves.elementAt(i);
+ BinaryNode lf = leaves.elementAt(i);
- if (lf.isPlaceholder())
+ if (lf instanceof SequenceNode && ((SequenceNode)lf).isPlaceholder())
{
has_placeholders = true;
}
* @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)
if (showDistances && (node.dist > 0))
{
- nodeLabel = new Format("%-.2f").form(node.dist);
+ nodeLabel = new Format("%g").form(node.dist);
}
if (showBootstrap && node.bootstrap > -1)
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();
}
else
{
- drawNode(g, (SequenceNode) node.left(), chunk, wscale, width, offx,
+ drawNode(g, (BinaryNode) node.left(), chunk, wscale, width, offx,
offy);
- drawNode(g, (SequenceNode) node.right(), chunk, wscale, width, offx,
+ drawNode(g, (BinaryNode) node.right(), chunk, wscale, width, offx,
offy);
double height = node.height;
}
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) (((SequenceNode) node.right()).ycount * chunk))
+ : (int) (((BinaryNode) node.right()).ycount * chunk))
+ offy;
Rectangle pos = new Rectangle(xend - 2, ypos - 2, 5, 5);
if (showDistances && (node.dist > 0))
{
- nodeLabel = new Format("%-.2f").form(node.dist);
+ nodeLabel = new Format("%g").form(node.dist);
}
if (showBootstrap && node.bootstrap > -1)
}
}
- for (Entry<SequenceNode, Rectangle> entry : nodeHash.entrySet())
+ for (Entry<BinaryNode, Rectangle> entry : nodeHash.entrySet())
{
Rectangle rect = entry.getValue();
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)
{
- 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;
* @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)
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;
}
else
{
- pickNode(pickBox, (SequenceNode) node.left(), chunk, wscale, width,
+ pickNode(pickBox, (BinaryNode) node.left(), chunk, wscale, width,
offx, offy);
- pickNode(pickBox, (SequenceNode) node.right(), chunk, wscale, width,
+ pickNode(pickBox, (BinaryNode) node.right(), chunk, wscale, width,
offx, offy);
}
}
* @param c
* DOCUMENT ME!
*/
- public void setColor(SequenceNode node, Color c)
+ public void setColor(BinaryNode node, Color c)
{
if (node == null)
{
}
}
}
- setColor((SequenceNode) node.left(), c);
- setColor((SequenceNode) node.right(), c);
+ setColor((BinaryNode) node.left(), c);
+ setColor((BinaryNode) node.right(), c);
}
/**
double wscale = (width - labelLength - (offx * 2))
/ tree.getMaxHeight();
- SequenceNode top = tree.getTopNode();
+ BinaryNode top = tree.getTopNode();
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;
}
else
{
- Vector<SequenceNode> leaves = tree.findLeaves(highlightNode);
+ Vector<BinaryNode> leaves = tree.findLeaves(highlightNode);
for (int i = 0; i < leaves.size(); i++)
{
void chooseSubtreeColour()
{
String ttl = MessageManager.getString("label.select_subtree_colour");
- ColourChooserListener listener = new ColourChooserListener() {
+ ColourChooserListener listener = new ColourChooserListener()
+ {
@Override
public void colourSelected(Color c)
{
repaint();
}
};
- JalviewColourChooser.showColourChooser(this, ttl, highlightNode.color, listener);
+ JalviewColourChooser.showColourChooser(this, ttl, highlightNode.color,
+ listener);
}
@Override
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();
if (ob instanceof SequenceI)
{
treeSelectionChanged((Sequence) ob);
- PaintRefresher.Refresh(tp, getAssociatedPanel().av.getSequenceSetId());
+ PaintRefresher.Refresh(tp,
+ getAssociatedPanel().av.getSequenceSetId());
repaint();
av.sendSelection();
return;
}
- else if (!(ob instanceof SequenceNode))
+ else if (!(ob instanceof BinaryNode))
{
// Find threshold
if (tree.getMaxHeight() != 0)
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();
}
}
- PaintRefresher.Refresh(tp, getAssociatedPanel().av.getSequenceSetId());
+ PaintRefresher.Refresh(tp,
+ getAssociatedPanel().av.getSequenceSetId());
repaint();
}
}
- void colourGroups(List<SequenceNode> groups)
+ void colourGroups(List<BinaryNode> groups)
{
AlignmentPanel[] aps = getAssociatedPanels();
for (int i = 0; i < groups.size(); i++)
(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<>();