From: James Procter Date: Tue, 31 Oct 2023 13:22:30 +0000 (+0000) Subject: JAL-4260 fix up click/drags on ruler area in wrapped mode. X-Git-Tag: Release_2_11_4_0~122^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=3a6dc40b8dd1b8d811fd4c70f4145e6e6102c9c8;p=jalview.git JAL-4260 fix up click/drags on ruler area in wrapped mode. --- diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 422601d..4365845 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -107,14 +107,11 @@ public class ScalePanel extends JPanel @Override public void mousePressed(MouseEvent evt) { - int x = (evt.getX() / av.getCharWidth()) + av.getRanges().getStartRes(); - final int res; + int res = ap.getSeqPanel().findColumn(evt); - if (av.hasHiddenColumns()) - { - x = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(x); + if (res==-1) { + return; } - res = Math.min(x, av.getAlignment().getWidth() - 1); min = res; max = res; @@ -286,20 +283,15 @@ public class ScalePanel extends JPanel mouseDragging = false; ap.getSeqPanel().stopScrolling(); - // todo res calculation should be a method on AlignViewport - int xCords = Math.max(0, evt.getX()); // prevent negative X coordinates - ViewportRanges ranges = av.getRanges(); - int res = (xCords / av.getCharWidth()) + ranges.getStartRes(); - res = Math.min(res, ranges.getEndRes()); - if (av.hasHiddenColumns()) - { - res = av.getAlignment().getHiddenColumns() - .visibleToAbsoluteColumn(res); - } - res = Math.max(0, res); - + int res = ap.getSeqPanel().findColumn(evt); + if (!stretchingGroup) { + if (res==-1) + { + return; + } + if (evt.isPopupTrigger()) // Windows: mouseReleased { rightMouseButtonPressed(evt, res); @@ -313,7 +305,7 @@ public class ScalePanel extends JPanel SequenceGroup sg = av.getSelectionGroup(); - if (sg != null) + if (res != -1 && sg != null) { if (res > sg.getStartRes()) { @@ -350,18 +342,15 @@ public class ScalePanel extends JPanel @Override public void mouseDragged(MouseEvent evt) { + + int res = ap.getSeqPanel().findColumn(evt); + if (res==-1) { + return; + } mouseDragging = true; ColumnSelection cs = av.getColumnSelection(); - HiddenColumns hidden = av.getAlignment().getHiddenColumns(); - - int res = (evt.getX() / av.getCharWidth()) - + av.getRanges().getStartRes(); - res = Math.max(0, res); - res = hidden.visibleToAbsoluteColumn(res); - res = Math.min(res, av.getAlignment().getWidth() - 1); min = Math.min(res, min); max = Math.max(res, max); - SequenceGroup sg = av.getSelectionGroup(); if (sg != null) { @@ -410,22 +399,19 @@ public class ScalePanel extends JPanel { this.setToolTipText(null); reveal = null; - if (!av.hasHiddenColumns()) + final int res = ap.getSeqPanel().findColumn(evt); + + if (res==-1) { - int res = (evt.getX() / av.getCharWidth()) - + av.getRanges().getStartRes(); - highlightAllStructPos(res); return; } - - int res = (evt.getX() / av.getCharWidth()) - + av.getRanges().getStartRes(); - + + highlightAllStructPos(res); + if (!av.hasHiddenColumns()) { + return; + } reveal = av.getAlignment().getHiddenColumns() .getRegionWithEdgeAtRes(res); - - res = av.getAlignment().getHiddenColumns().visibleToAbsoluteColumn(res); - highlightAllStructPos(res); ToolTipManager.sharedInstance().registerComponent(this); this.setToolTipText( MessageManager.getString("label.reveal_hidden_columns"));