From 2afaba8da802954edbedf5c0748412d965763a2c Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Thu, 20 Oct 2022 11:23:36 +0100 Subject: [PATCH] JAL-2349 (still buggy) interactive selection - time to write tests! --- src/jalview/gui/AnnotationPanel.java | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 7f606c8..4f5b7d0 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -852,7 +852,11 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, */ int fromY = Math.min(firstDragY, evt.getY()); int toY = Math.max(firstDragY, evt.getY()); + int fromX = Math.min(firstDragX, evt.getX()); + int toX = Math.max(firstDragX, evt.getX()); + int deltaY = toY - fromY; + int deltaX = toX - fromX; int[] rowIndex = getRowIndexAndOffset(fromY, av.getAlignment().getAlignmentAnnotation()); @@ -873,20 +877,20 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, AlignmentAnnotation cma = av.getAlignment() .getAlignmentAnnotation()[rowIndex[0]]; - int fromXp = Math.min(firstDragX, evt.getX()); - int toXp = Math.max(firstDragX, evt.getX()); - int lastX = getColumnForXPos(fromXp); - int currentX = getColumnForXPos(toXp); - ContactListI forLastX = av.getContactList(cma, lastX); - ContactListI forCurrentX = av.getContactList(cma, currentX); - if (forLastX != null && forCurrentX != null) + int lastX = getColumnForXPos(fromX); + int currentX = getColumnForXPos(toX); + int fromXc = Math.min(lastX, currentX); + int toXc = Math.max(lastX, currentX); + ContactListI forFromX = av.getContactList(cma, fromXc); + ContactListI forToX = av.getContactList(cma, toXc); + + if (forFromX != null && forToX != null) { - ContactGeometry lastXcgeom = new ContactGeometry(forLastX, + ContactGeometry lastXcgeom = new ContactGeometry(forFromX, cma.graphHeight); - ContactGeometry.contactInterval lastXci = lastXcgeom.mapFor( - rowIndex[1], - rowIndex[1] + ((fromY == firstDragY) ? -deltaY : deltaY)); - ContactGeometry cXcgeom = new ContactGeometry(forCurrentX, + ContactGeometry.contactInterval lastXci = lastXcgeom + .mapFor(rowIndex[1], rowIndex[1] + deltaY); + ContactGeometry cXcgeom = new ContactGeometry(forToX, cma.graphHeight); ContactGeometry.contactInterval cXci = cXcgeom.mapFor(rowIndex[1], rowIndex[1] + deltaY); -- 1.7.10.2