From: kiramt Date: Mon, 17 Jul 2017 15:02:03 +0000 (+0100) Subject: JAL-2611 Still not happy with behaviour X-Git-Tag: Release_2_10_3b1~132^2~30^2~4 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=236efa0d06562386ba9a5e44764143298e0306d2;p=jalview.git JAL-2611 Still not happy with behaviour --- diff --git a/src/jalview/gui/OverviewPanel.java b/src/jalview/gui/OverviewPanel.java index 0f276d7..5fbefb5 100755 --- a/src/jalview/gui/OverviewPanel.java +++ b/src/jalview/gui/OverviewPanel.java @@ -28,6 +28,7 @@ import jalview.viewmodel.OverviewDimensionsShowHidden; import jalview.viewmodel.ViewportListenerI; import java.awt.BorderLayout; +import java.awt.Cursor; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -134,12 +135,12 @@ public class OverviewPanel extends JPanel implements Runnable, 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)); } } }); diff --git a/src/jalview/viewmodel/OverviewDimensionsShowHidden.java b/src/jalview/viewmodel/OverviewDimensionsShowHidden.java index af95c45..4ab27de 100644 --- a/src/jalview/viewmodel/OverviewDimensionsShowHidden.java +++ b/src/jalview/viewmodel/OverviewDimensionsShowHidden.java @@ -81,14 +81,109 @@ public class OverviewDimensionsShowHidden extends OverviewDimensions // coords, // convert back to pixel coords int vpx = Math.round((float) mousex * alwidth / width); - int visXAsRes = hiddenCols.findColumnPosition(vpx); + // int visXAsRes = hiddenCols.findColumnPosition(vpx); int vpy = Math.round((float) mousey * alheight / sequencesHeight); - int visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(vpy); + // int visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(vpy); - updateViewportFromTopLeft(visXAsRes + transX, visYAsRes + transY, - hiddenSeqs, - hiddenCols); + System.out.println("vpx: " + vpx); + // System.out.println("VisXAsRes: " + visXAsRes); + System.out.println("transX: " + transX); + // updateViewportFromTopLeft(vpx + transX, vpy + transY, + // hiddenSeqs, + // hiddenCols); + + int xAsRes = vpx + transX; + int yAsSeq = vpy + transY; + + resetAlignmentDims(); + + if (xAsRes < 0) + { + xAsRes = 0; + } + + if (yAsSeq < 0) + { + yAsSeq = 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); + + // get viewport width in residues + int vpwidth = ranges.getViewportWidth(); + + // get where x should be when accounting for hidden cols + // if x is in a hidden col region, shift to left - but we still need + // absolute position + // so convert back after getting visible region position + // int visXAsRes = hiddenCols.findColumnPosition(xAsRes); + int visXAsRes = xAsRes; + + // check in case we went off the edge of the alignment + int visAlignWidth = hiddenCols.findColumnPosition(alwidth - 1); + /* if (visXAsRes + vpwidth - 1 > visAlignWidth) + { + // went past the end of the alignment, adjust backwards + + // if last position was before the end of the alignment, need to update + if (ranges.getEndRes() < visAlignWidth) + { + visXAsRes = hiddenCols.findColumnPosition(hiddenCols + .subtractVisibleColumns(vpwidth - 1, alwidth - 1)); + } + else + { + visXAsRes = ranges.getStartRes(); + } + }*/ + + // + // Convert y value to sequence position + // + + // convert y to residues + // int yAsSeq = Math.round((float) y * alheight / sequencesHeight); + + // get viewport height in sequences + int vpheight = ranges.getViewportHeight(); + + // get where y should be when accounting for hidden rows + // if y is in a hidden row region, shift up - but we still need absolute + // position, + // so convert back after getting visible region position + yAsSeq = hiddenSeqs.adjustForHiddenSeqs( + hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq)); + + // check in case we went off the edge of the alignment + int visAlignHeight = hiddenSeqs.findIndexWithoutHiddenSeqs(alheight); + int visYAsSeq = hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq); + if (visYAsSeq + vpheight - 1 > visAlignHeight) + { + // went past the end of the alignment, adjust backwards + if (ranges.getEndSeq() < visAlignHeight) + { + visYAsSeq = hiddenSeqs.findIndexWithoutHiddenSeqs( + hiddenSeqs.subtractVisibleRows(vpheight - 1, alheight - 1)); + } + else + { + visYAsSeq = ranges.getStartSeq(); + } + } + + // update viewport + ranges.setStartRes(visXAsRes); + ranges.setStartSeq(visYAsSeq); } @Override