From: gmungoc Date: Mon, 4 Mar 2019 17:06:13 +0000 (+0000) Subject: Merge branch 'bug/JAL-3072scrollThread' into merge/JAL-3072_3073 X-Git-Tag: Release_2_11_0~17^2~75 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7e00183505bd4c58d1ce62ee121ed372c3b058f2;p=jalview.git Merge branch 'bug/JAL-3072scrollThread' into merge/JAL-3072_3073 Conflicts: src/jalview/datamodel/Alignment.java src/jalview/gui/ScalePanel.java src/jalview/gui/SeqPanel.java --- 7e00183505bd4c58d1ce62ee121ed372c3b058f2 diff --cc src/jalview/gui/IdPanel.java index 1fd9e49,3f43008..113fd9f --- a/src/jalview/gui/IdPanel.java +++ b/src/jalview/gui/IdPanel.java @@@ -484,9 -409,8 +485,9 @@@ public class IdPanel extends JPane { if (scrollThread != null) { - scrollThread.running = false; + scrollThread.stopScrolling(); } + MousePos pos = alignPanel.getSeqPanel().findMousePosition(e); mouseDragging = false; PaintRefresher.Refresh(this, av.getSequenceSetId()); diff --cc src/jalview/gui/ScalePanel.java index 9788ec6,6a44d06..0f2b765 --- a/src/jalview/gui/ScalePanel.java +++ b/src/jalview/gui/ScalePanel.java @@@ -274,12 -276,11 +275,11 @@@ public class ScalePanel extends JPane public void mouseReleased(MouseEvent evt) { mouseDragging = false; + ap.getSeqPanel().stopScrolling(); - // todo res calculation should be a method on AlignViewport - int res = (evt.getX() / av.getCharWidth()) + int xCords = Math.max(0, evt.getX()); // prevent negative X coordinates - + int res = (xCords / av.getCharWidth()) + av.getRanges().getStartRes(); - if (av.hasHiddenColumns()) { res = av.getAlignment().getHiddenColumns() diff --cc src/jalview/gui/SeqPanel.java index 7abbd7d,401bd0a..4a1a9ee --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@@ -2337,66 -1997,48 +2331,74 @@@ public class SeqPanel extends JPane mouseDragging = true; - if ((scrollThread != null) && (scrollThread.isRunning())) + if (scrollThread != null) { - scrollThread.setEvent(evt); + scrollThread.setMousePosition(evt.getPoint()); } + + /* + * construct a status message showing the range of the selection + */ + StringBuilder status = new StringBuilder(64); + List seqs = stretchGroup.getSequences(); + String name = seqs.get(0).getName(); + if (name.length() > 20) + { + name = name.substring(0, 20); + } + status.append(name).append(" - "); + name = seqs.get(seqs.size() - 1).getName(); + if (name.length() > 20) + { + name = name.substring(0, 20); + } + status.append(name).append(" "); + int startRes = stretchGroup.getStartRes(); + status.append(" cols ").append(String.valueOf(startRes + 1)) + .append("-"); + int endRes = stretchGroup.getEndRes(); + status.append(String.valueOf(endRes + 1)); + status.append(" (").append(String.valueOf(seqs.size())).append(" x ") + .append(String.valueOf(endRes - startRes + 1)).append(")"); + ap.alignFrame.setStatus(status.toString()); } - void scrollCanvas(MouseEvent evt) + /** + * Stops the scroll thread if it is running + */ + void stopScrolling() { - if (evt == null) + if (scrollThread != null) { - if ((scrollThread != null) && (scrollThread.isRunning())) - { - scrollThread.stopScrolling(); - scrollThread = null; - } - mouseDragging = false; + scrollThread.stopScrolling(); + scrollThread = null; } - else - { - if (scrollThread == null) - { - scrollThread = new ScrollThread(); - } + mouseDragging = false; + } - mouseDragging = true; - scrollThread.setEvent(evt); + /** + * Starts a thread to scroll the alignment, towards a given mouse position + * outside the panel bounds + * + * @param mousePos + */ + void startScrolling(Point mousePos) + { + if (scrollThread == null) + { + scrollThread = new ScrollThread(); } + mouseDragging = true; + scrollThread.setMousePosition(mousePos); } - // this class allows scrolling off the bottom of the visible alignment + /** + * Performs scrolling of the visible alignment left, right, up or down + */ class ScrollThread extends Thread { - MouseEvent evt; + private Point mousePos; private volatile boolean threadRunning = true;