X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FSeqPanel.java;h=de67c39e6f3f5e228cd9bad5026fbaca1b1df518;hb=13ab52271b76b41ece153044b30316c23c4386a2;hp=04ceea6c10a567dcf3466486a7674f2e727f9ec8;hpb=09976d9f77b1a3a6486735b0fd9caeb158f1834f;p=jalview.git diff --git a/src/jalview/gui/SeqPanel.java b/src/jalview/gui/SeqPanel.java index 04ceea6..de67c39 100644 --- a/src/jalview/gui/SeqPanel.java +++ b/src/jalview/gui/SeqPanel.java @@ -134,7 +134,6 @@ public class SeqPanel extends JPanel MousePos o = (MousePos) obj; boolean b = (column == o.column && seqIndex == o.seqIndex && annotationIndex == o.annotationIndex); - // System.out.println(obj + (b ? "= " : "!= ") + this); return b; } @@ -321,8 +320,10 @@ public class SeqPanel extends JPanel } else { - seqIndex = Math.min((y / charHeight) + av.getRanges().getStartSeq(), + ViewportRanges ranges = av.getRanges(); + seqIndex = Math.min((y / charHeight) + ranges.getStartSeq(), alignmentHeight - 1); + seqIndex = Math.min(seqIndex, ranges.getEndSeq()); } return new MousePos(col, seqIndex, annIndex); @@ -1502,7 +1503,6 @@ public class SeqPanel extends JPanel return; } - // System.out.print(y1+" "+y2+" "+fixedLeft+" "+fixedRight+"~~"); // Selection spans a hidden region if (fixedLeft < y1 && (fixedRight > y2 || fixedRight == -1)) { @@ -1940,13 +1940,23 @@ public class SeqPanel extends JPanel @Override public void mouseExited(MouseEvent e) { + lastMousePosition = null; ap.alignFrame.setStatus(" "); + if (av.getWrapAlignment()) { return; } - if (mouseDragging && scrollThread == null) + /* + * start scrolling if mouse dragging, whether the drag started + * in the scale panel or this panel + */ + if (ap.getScalePanel().isMouseDragging()) + { + ap.getScalePanel().mouseExited(e); + } + else if (mouseDragging && scrollThread == null) { startScrolling(e.getPoint()); } @@ -2405,14 +2415,7 @@ public class SeqPanel extends JPanel { scrollThread = new ScrollThread(); scrollThread.setMousePosition(mousePos); - if (!Platform.isJS()) - { - /* - * Java - run in a new thread - */ - scrollThread.start(); - } - else + if (Platform.isJS()) { /* * Javascript - run every 20ms until scrolling stopped @@ -2428,22 +2431,22 @@ public class SeqPanel extends JPanel // if (!scrollOnce() {t.stop();}) gives compiler error :-( scrollThread.scrollOnce(); } - } - }); - t.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { if (scrollThread == null) { // SeqPanel.stopScrolling called - t.stop(); + ((Timer) e.getSource()).stop(); } } }); t.start(); } + else + { + /* + * Java - run in a new thread + */ + scrollThread.start(); + } } } @@ -2767,4 +2770,45 @@ public class SeqPanel extends JPanel { return lastSearchResults; } + + /** + * scroll to the given row/column - or nearest visible location + * + * @param row + * @param column + */ + public void scrollTo(int row, int column) + { + + row = row < 0 ? ap.av.getRanges().getStartSeq() : row; + column = column < 0 ? ap.av.getRanges().getStartRes() : column; + ap.scrollTo(column, column, row, true, true); + } + + /** + * scroll to the given row - or nearest visible location + * + * @param row + */ + public void scrollToRow(int row) + { + + row = row < 0 ? ap.av.getRanges().getStartSeq() : row; + ap.scrollTo(ap.av.getRanges().getStartRes(), + ap.av.getRanges().getStartRes(), row, true, true); + } + + /** + * scroll to the given column - or nearest visible location + * + * @param column + */ + public void scrollToColumn(int column) + { + + column = column < 0 ? ap.av.getRanges().getStartRes() : column; + ap.scrollTo(column, column, ap.av.getRanges().getStartSeq(), true, + true); + } + }