From ad8b755b7d5daaa914a61fc4ca476196551b2f0a Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 25 Jul 2018 16:41:02 +0100 Subject: [PATCH] JAL-3074 don't scroll up/down on drag out of scale or annotation panel, performance tweaks --- src/jalview/datamodel/Alignment.java | 31 +------------------------------ src/jalview/gui/ScalePanel.java | 12 ++++++------ src/jalview/gui/SeqPanel.java | 5 +---- 3 files changed, 8 insertions(+), 40 deletions(-) diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 3ba35b6..93ad332 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -712,39 +712,10 @@ public class Alignment implements AlignmentI for (int i = 0; i < sequences.size(); i++) { - if (getSequenceAt(i).getLength() > maxLength) - { - maxLength = getSequenceAt(i).getLength(); - } + maxLength = Math.max(maxLength, getSequenceAt(i).getLength()); } - return maxLength; } - /* - @Override - public int getWidth() - { - final Wrapper temp = new Wrapper(); - - forEachSequence(new Consumer() - { - @Override - public void accept(SequenceI s) - { - if (s.getLength() > temp.inner) - { - temp.inner = s.getLength(); - } - } - }, 0, sequences.size() - 1); - - return temp.inner; - } - - public static class Wrapper - { - public int inner; - }*/ /** * DOCUMENT ME! diff --git a/src/jalview/gui/ScalePanel.java b/src/jalview/gui/ScalePanel.java index 581fb7d..ea4b42b 100755 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@ -35,6 +35,7 @@ import java.awt.Color; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.Point; import java.awt.RenderingHints; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -286,10 +287,7 @@ public class ScalePanel extends JPanel .visibleToAbsoluteColumn(res); } - if (res >= av.getAlignment().getWidth()) - { - res = av.getAlignment().getWidth() - 1; - } + res = Math.min(res, av.getAlignment().getWidth() - 1); if (!stretchingGroup) { @@ -363,14 +361,16 @@ public class ScalePanel extends JPanel /** * Action on leaving the panel bounds with mouse drag in progress is to start - * scrolling the alignment in the direction of the mouse + * scrolling the alignment in the direction of the mouse. To restrict + * scrolling to left-right (not up-down), the y-value of the mouse position is + * replaced with zero. */ @Override public void mouseExited(MouseEvent evt) { if (mouseDragging) { - ap.getSeqPanel().startScrolling(evt.getPoint()); + ap.getSeqPanel().startScrolling(new Point(evt.getX(), 0)); } } diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 134b337..401bd0a 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -1911,10 +1911,7 @@ public class SeqPanel extends JPanel return; } - if (res >= av.getAlignment().getWidth()) - { - res = av.getAlignment().getWidth() - 1; - } + res = Math.min(res, av.getAlignment().getWidth()-1); if (stretchGroup.getEndRes() == res) { -- 1.7.10.2