X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FIdPanel.java;h=3f43008d08311e339901e18ce90d0ffdc7dc79ca;hb=9c3f777f8d20fef0fcf80a01874a5d24728ca229;hp=1f2a3add6733a631069619b0044320275262e443;hpb=d6768d73c421c774705be3acfa6fe0340e76d947;p=jalview.git diff --git a/src/jalview/gui/IdPanel.java b/src/jalview/gui/IdPanel.java index 1f2a3ad..3f43008 100755 --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@ -28,6 +28,7 @@ import jalview.io.SequenceAnnotationReport; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.viewmodel.AlignmentViewport; +import jalview.viewmodel.ViewportRanges; import java.awt.BorderLayout; import java.awt.event.MouseEvent; @@ -108,8 +109,7 @@ public class IdPanel extends JPanel SequenceI sequence = av.getAlignment().getSequenceAt(seq); StringBuilder tip = new StringBuilder(64); seqAnnotReport.createTooltipAnnotationReport(tip, sequence, - av.isShowDBRefs(), av.isShowNPFeats(), - sp.seqCanvas.fr.getMinMax()); + av.isShowDBRefs(), av.isShowNPFeats(), sp.seqCanvas.fr); setToolTipText(JvSwingUtils.wrapTooltip(true, sequence.getDisplayId(true) + " " + tip.toString())); } @@ -148,7 +148,8 @@ public class IdPanel extends JPanel public void mouseWheelMoved(MouseWheelEvent e) { e.consume(); - if (e.getWheelRotation() > 0) + double wheelRotation = e.getPreciseWheelRotation(); + if (wheelRotation > 0) { if (e.isShiftDown()) { @@ -159,7 +160,7 @@ public class IdPanel extends JPanel av.getRanges().scrollUp(false); } } - else + else if (wheelRotation < 0) { if (e.isShiftDown()) { @@ -224,7 +225,7 @@ public class IdPanel extends JPanel { if (scrollThread != null) { - scrollThread.running = false; + scrollThread.stopScrolling(); } } @@ -331,7 +332,8 @@ public class IdPanel extends JPanel * and any non-positional features */ List nlinks = Preferences.sequenceUrlLinks.getLinksForMenu(); - for (SequenceFeature sf : sq.getFeatures().getNonPositionalFeatures()) + List features = sq.getFeatures().getNonPositionalFeatures(); + for (SequenceFeature sf : features) { if (sf.links != null) { @@ -342,7 +344,7 @@ public class IdPanel extends JPanel } } - PopupMenu pop = new PopupMenu(alignPanel, sq, nlinks, + PopupMenu pop = new PopupMenu(alignPanel, sq, features, Preferences.getGroupURLLinks()); pop.show(this, e.getX(), e.getY()); } @@ -407,7 +409,7 @@ public class IdPanel extends JPanel { if (scrollThread != null) { - scrollThread.running = false; + scrollThread.stopScrolling(); } mouseDragging = false; @@ -456,24 +458,42 @@ public class IdPanel extends JPanel this.idCanvas = idCanvas; } - // this class allows scrolling off the bottom of the visible alignment + /** + * Performs scrolling of the visible alignment up or down, adding newly + * visible sequences to the current selection + */ class ScrollThread extends Thread { - boolean running = false; + private boolean running = false; - boolean up = true; + private boolean up; + /** + * Constructor for a thread that scrolls either up or down + * + * @param up + */ public ScrollThread(boolean up) { this.up = up; + setName("IdPanel$ScrollThread$" + String.valueOf(up)); start(); } + /** + * Sets a flag to stop the scrolling + */ public void stopScrolling() { running = false; } + /** + * Scrolls the alignment either up or down, one row at a time, adding newly + * visible sequences to the current selection. Speed is limited to a maximum + * of ten rows per second. The thread exits when the end of the alignment is + * reached or a flag is set to stop it. + */ @Override public void run() { @@ -481,29 +501,20 @@ public class IdPanel extends JPanel while (running) { - if (av.getRanges().scrollUp(up)) + ViewportRanges ranges = IdPanel.this.av.getRanges(); + if (ranges.scrollUp(up)) { - // scroll was ok, so add new sequence to selection - int seq = av.getRanges().getStartSeq(); - - if (!up) - { - seq = av.getRanges().getEndSeq(); - } - - if (seq < lastid) - { - selectSeqs(lastid - 1, seq); - } - else if (seq > lastid) - { - selectSeqs(lastid + 1, seq); - } - - lastid = seq; + int toSeq = up ? ranges.getStartSeq() : ranges.getEndSeq(); + int fromSeq = toSeq < lastid ? lastid - 1 : lastid + 1; + IdPanel.this.selectSeqs(fromSeq, toSeq); + + lastid = toSeq; } else { + /* + * scroll did nothing - reached limit of visible alignment + */ running = false; }