From: James Procter Date: Mon, 22 May 2023 15:35:38 +0000 (+0100) Subject: JAL-4134 map between column and node selections better (but not quite right still... X-Git-Tag: Release_2_11_3_0~14^2~3^2^2~14 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7440c240e784fa663228f579b51694e023a30ae3;p=jalview.git JAL-4134 map between column and node selections better (but not quite right still.. tests needed!) --- 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 {