From 581a86ef3fc695b8a906bc6d1746cc5f39fcba35 Mon Sep 17 00:00:00 2001 From: James Procter Date: Mon, 27 Feb 2023 18:43:23 +0000 Subject: [PATCH] =?utf8?q?JAL-4134=20leaves=20marked=20when=20columns=20are=20?= =?utf8?q?selected=20-=20doesn=E2=80=99t=20refresh=20automatically=20from=20?= =?utf8?q?alignment=20yet=20(only=20when=20tree=20panel=20repainted)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/gui/TreeCanvas.java | 42 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index b8bcc74..7bdb673 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -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 l, Color col) { -- 1.7.10.2