From: kiramt Date: Sat, 22 Jul 2017 09:18:41 +0000 (+0200) Subject: Merge branch 'develop' into feature/JAL-2611 X-Git-Tag: Release_2_10_3b1~132^2~30^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4a9a2fc8a1b1a66b21e66429083f27a6fc8541b9;p=jalview.git Merge branch 'develop' into feature/JAL-2611 Conflicts: src/jalview/gui/OverviewPanel.java src/jalview/viewmodel/OverviewDimensionsHideHidden.java src/jalview/viewmodel/OverviewDimensionsShowHidden.java --- 4a9a2fc8a1b1a66b21e66429083f27a6fc8541b9 diff --cc src/jalview/gui/OverviewPanel.java index 1c01108,7a4456e..c81ac2f --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@@ -110,39 -107,11 +110,37 @@@ public class OverviewPanel extends JPan @Override public void mouseDragged(MouseEvent evt) { - if (!SwingUtilities.isRightMouseButton(evt) - && !av.getWrapAlignment()) + if (!SwingUtilities.isRightMouseButton(evt)) { - od.updateViewportFromMouse(evt.getX(), evt.getY(), av + if (draggingBox) + { + // set the mouse position as a fixed point in the box + // and drag relative to that position + od.adjustViewportFromMouse(evt.getX(), + evt.getY(), av.getAlignment().getHiddenSequences(), + av.getAlignment().getHiddenColumns()); + } + else + { + od.updateViewportFromMouse(evt.getX(), evt.getY(), av .getAlignment().getHiddenSequences(), av.getAlignment() .getHiddenColumns()); + } - + } + } + + @Override + public void mouseMoved(MouseEvent evt) + { + if (od.isPositionInBox(evt.getX(), evt.getY())) + { + // display drag cursor at mouse position + setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); + } + else + { + // reset cursor + setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); @@@ -159,33 -128,12 +157,34 @@@ showPopupMenu(evt); } } - else if (!av.getWrapAlignment()) + else + // if (!av.getWrapAlignment()) { - od.updateViewportFromMouse(evt.getX(), evt.getY(), av - .getAlignment().getHiddenSequences(), av.getAlignment() - .getHiddenColumns()); + if (!od.isPositionInBox(evt.getX(), evt.getY())) + { + // don't do anything if the mouse press is in the overview's box + // (wait to see if it's a drag instead) + // otherwise update the viewport + od.updateViewportFromMouse(evt.getX(), evt.getY(), + av.getAlignment().getHiddenSequences(), + av.getAlignment().getHiddenColumns()); + } + else + { + draggingBox = true; + od.setDragPoint(evt.getX(), evt.getY(), + av.getAlignment().getHiddenSequences(), + av.getAlignment().getHiddenColumns()); + } + } + } + + @Override + public void mouseReleased(MouseEvent evt) + { + if (draggingBox) + { + draggingBox = false; } } diff --cc src/jalview/viewmodel/OverviewDimensionsHideHidden.java index 7eec343,4d64f1c..c78b8a3 --- a/src/jalview/viewmodel/OverviewDimensionsHideHidden.java +++ b/src/jalview/viewmodel/OverviewDimensionsHideHidden.java @@@ -30,48 -24,37 +30,51 @@@ public class OverviewDimensionsHideHidd public void updateViewportFromMouse(int mousex, int mousey, HiddenSequences hiddenSeqs, HiddenColumns hiddenCols) { - resetAlignmentDims(); + int xAsRes = getLeftXFromCentreX(mousex, hiddenCols); + int yAsSeq = getTopYFromCentreY(mousey, hiddenSeqs); + + updateViewportFromTopLeft(xAsRes, yAsSeq, hiddenSeqs, hiddenCols); + + } + + @Override + public void adjustViewportFromMouse(int mousex, int mousey, + HiddenSequences hiddenSeqs, HiddenColumns hiddenCols) + { + // calculate translation in pixel terms: + // get mouse location in viewport coords, add translation in viewport + // coords, and update viewport as usual + int vpx = Math.round((float) mousex * alwidth / width); + int vpy = Math.round((float) mousey * alheight / sequencesHeight); - int x = mousex; - int y = mousey; + updateViewportFromTopLeft(vpx + xdiff, vpy + ydiff, hiddenSeqs, + hiddenCols); - if (x < 0) + } + + @Override + protected void updateViewportFromTopLeft(int leftx, int topy, + HiddenSequences hiddenSeqs, HiddenColumns hiddenCols) + { + int xAsRes = leftx; + int yAsSeq = topy; + resetAlignmentDims(); + + if (xAsRes < 0) { - x = 0; + xAsRes = 0; } - if (y < 0) + if (yAsSeq < 0) { - y = 0; + yAsSeq = 0; } - // Determine where scrollCol should be, given visXAsRes + if (ranges.isWrappedMode()) + { - y = 0; // sorry, no vertical scroll when wrapped ++ yAsSeq = 0; // sorry, no vertical scroll when wrapped + } - // - // Convert x value to residue position - // - - // need to determine where scrollCol should be, given x - // to do this also need to know width of viewport, and some hidden column - // correction - - // convert x to residues - this is an absolute position - int xAsRes = Math.round((float) x * alwidth / width); - // get viewport width in residues int vpwidth = ranges.getViewportWidth(); diff --cc src/jalview/viewmodel/OverviewDimensionsShowHidden.java index c4b69a8,62e8000..5bd4bba --- a/src/jalview/viewmodel/OverviewDimensionsShowHidden.java +++ b/src/jalview/viewmodel/OverviewDimensionsShowHidden.java @@@ -72,60 -66,36 +72,62 @@@ public class OverviewDimensionsShowHidd public void updateViewportFromMouse(int mousex, int mousey, HiddenSequences hiddenSeqs, HiddenColumns hiddenCols) { - int x = mousex; - int y = mousey; + // convert mousex and mousey to alignment units as well as + // translating to top left corner of viewport - this is an absolute position + int xAsRes = getLeftXFromCentreX(mousex, hiddenCols); + int yAsSeq = getTopYFromCentreY(mousey, hiddenSeqs); - resetAlignmentDims(); + // convert to visible positions + int visXAsRes = hiddenCols.findColumnPosition(xAsRes); + yAsSeq = hiddenSeqs.adjustForHiddenSeqs( + hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq)); ++ yAsSeq = Math.max(yAsSeq, 0); // -1 if before first visible sequence + int visYAsSeq = hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq); ++ visYAsSeq = Math.max(visYAsSeq, 0); // -1 if before first visible sequence - if (x < 0) - { - x = 0; - } + // update viewport accordingly + updateViewportFromTopLeft(visXAsRes, visYAsSeq, hiddenSeqs, hiddenCols); + } + + @Override + public void adjustViewportFromMouse(int mousex, int mousey, + HiddenSequences hiddenSeqs, HiddenColumns hiddenCols) + { + // calculate translation in pixel terms: + // get mouse location in viewport coords, add translation in viewport + // coords, + // convert back to pixel coords + int vpx = Math.round((float) mousex * alwidth / width); + int visXAsRes = hiddenCols.findColumnPosition(vpx) + xdiff; + + int vpy = Math.round((float) mousey * alheight / sequencesHeight); + int visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(vpy) + ydiff; + + // update viewport accordingly + updateViewportFromTopLeft(visXAsRes, visYAsRes, + hiddenSeqs, + hiddenCols); + } + + @Override + protected void updateViewportFromTopLeft(int leftx, int topy, + HiddenSequences hiddenSeqs, HiddenColumns hiddenCols) + { + int visXAsRes = leftx; + int visYAsSeq = topy; + resetAlignmentDims(); - if (y < 0) + if (visXAsRes < 0) { - y = 0; + visXAsRes = 0; } - if (ranges.isWrappedMode()) + if (visYAsSeq < 0) { - y = 0; // sorry, no vertical scroll when wrapped + visYAsSeq = 0; } - // - // Convert x value to residue position - // - - // need to determine where scrollCol should be, given x - // to do this also need to know width of viewport, and some hidden column - // correction - - // convert x to residues - this is an absolute position - int xAsRes = Math.round((float) x * alwidth / width); + // Determine where scrollCol should be, given visXAsRes // get viewport width in residues int vpwidth = ranges.getViewportWidth();