From 7440c240e784fa663228f579b51694e023a30ae3 Mon Sep 17 00:00:00 2001 From: James Procter Date: Mon, 22 May 2023 16:35:38 +0100 Subject: [PATCH] JAL-4134 map between column and node selections better (but not quite right still.. tests needed!) --- src/jalview/gui/TreeCanvas.java | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index bb028bf..425f710 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -1109,12 +1109,33 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, } ColumnSelection cs = av.getColumnSelection(); HiddenColumns hc = av.getAlignment().getHiddenColumns(); - int offp = (rseq != null) ? rseq.findIndex(rseq.getStart() + colm) + AlignmentAnnotation aa = tp.getAssocAnnotation(); + int offp=-1; + if (aa != null) + { + ContactMatrixI cm = av.getContactMatrix(aa); + if (cm instanceof MappableContactMatrixI) + { + MappableContactMatrixI mcm = (MappableContactMatrixI) cm; + int pos[]=mcm.getMappedPositionsFor(rseq, colm); + if (pos!=null) + { + offp=rseq.findIndex(pos[0])-1; + } else { + offp=-2; + } + } + } + if (offp==-1) + { + // assume a direct mapping to reference or column number + offp = (rseq != null) ? rseq.findIndex(rseq.getStart() + colm) : colm; + } if (!av.hasHiddenColumns()) { - return cs.contains(offp - 1); + return cs.contains(offp); } if (hc.isVisible(offp - 1)) { @@ -1191,7 +1212,7 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable, continue; } // TODO: handle ranges... - offp = seqpos[0]; + offp = seqpos[0]-1; } else { -- 1.7.10.2