JAL-4134 leaves marked when columns are selected - doesn’t refresh automatically...
authorJames Procter <j.procter@dundee.ac.uk>
Mon, 27 Feb 2023 18:43:23 +0000 (18:43 +0000)
committerJames Procter <j.procter@dundee.ac.uk>
Mon, 27 Feb 2023 18:43:23 +0000 (18:43 +0000)
src/jalview/gui/TreeCanvas.java

index b8bcc74..7bdb673 100755 (executable)
@@ -294,10 +294,22 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
       nameHash.put(node.element(), rect);
 
       // Colour selected leaves differently
-      SequenceGroup selected = av.getSelectionGroup();
+      boolean isSelected = false;
+      if (tp.getColumnWise())
+      {
+        isSelected = isColumnForNodeSelected(node);
+      }
+      else
+      {
+        SequenceGroup selected = av.getSelectionGroup();
 
-      if ((selected != null)
-              && selected.getSequences(null).contains(node.element()))
+        if ((selected != null)
+                && selected.getSequences(null).contains(node.element()))
+        {
+          isSelected = true;
+        }
+      }
+      if (isSelected)
       {
         g.setColor(Color.gray);
 
@@ -1009,6 +1021,30 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
     }
   }
 
+  private boolean isColumnForNodeSelected(BinaryNode bn)
+  {
+    SequenceI rseq = tp.assocAnnotation.sequenceRef;
+    int colm = -1;
+    try
+    {
+      colm = Integer.parseInt(
+              bn.getName().substring(bn.getName().indexOf("c") + 1));
+    } catch (Exception e)
+    {
+      return false;
+    }
+    ColumnSelection cs = av.getColumnSelection();
+    HiddenColumns hc = av.getAlignment().getHiddenColumns();
+    int offp = (rseq != null) ? rseq.findIndex(rseq.getStart() - 1 + colm)
+            : colm;
+
+    if (!av.hasHiddenColumns() || hc.isVisible(offp))
+    {
+      return cs.contains(offp);
+    }
+    return false;
+  }
+
   private void markColumnsFor(AlignmentPanel[] aps, Vector<BinaryNode> l,
           Color col)
   {