From 3bb698360710c62e9d0a4c98830504d2790c44ae Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 28 Jun 2024 17:03:51 +0100 Subject: [PATCH] JAL-4386 annotate internal nodes either side of partition with the set of labels on branches --- src/jalview/gui/TreeCanvas.java | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index 993d563..05c33c6 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -40,6 +40,7 @@ import java.util.ArrayList; import java.util.BitSet; import java.util.HashMap; import java.util.Hashtable; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -1073,9 +1074,10 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, setColor(groups.get(i), col.brighter()); Vector l = tree.findLeaves(groups.get(i)); + gatherLabelsTo(groups.get(i),l); if (!tp.isColumnWise()) { - createSeqGroupFor(aps, l, col); + createSeqGroupFor(aps, l, col); } else { @@ -1118,6 +1120,29 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, } } + private void gatherLabelsTo(BinaryNode binaryNode, Vector l) + { + LinkedHashSet labelsForNode = new LinkedHashSet(); + for (BinaryNode leaf:l) + { + if (leaf.hasLabel()) + { + labelsForNode.add(leaf.getLabel()); + } + } + StringBuilder sb = new StringBuilder(); + boolean first=true; + for (String label:labelsForNode) + { + if (!first) { + sb.append(" | "); + } + first=false; + sb.append(label); + } + binaryNode.setLabel(sb.toString()); + } + private int parseColumnNode(BinaryNode bn) throws NumberFormatException { return Integer.parseInt( -- 1.7.10.2