X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fviewmodel%2FOverviewDimensions.java;h=60b4ee988a031030bce8fc22a0abfa0307183759;hb=f20144e54bcecee1a25b94dddf6c9bf802012b38;hp=1f18a1022fc4327a0fa26e1b6a24a7a94a3fc35a;hpb=1f015ae6034c51f7e7ab619fe428943899755d1c;p=jalview.git diff --git a/src/jalview/viewmodel/OverviewDimensions.java b/src/jalview/viewmodel/OverviewDimensions.java index 1f18a10..60b4ee9 100644 --- a/src/jalview/viewmodel/OverviewDimensions.java +++ b/src/jalview/viewmodel/OverviewDimensions.java @@ -138,19 +138,11 @@ public class OverviewDimensions { x = 0; } - else if (x >= alwidth) - { - x = alwidth - 1; - } if (y < 0) { y = 0; } - else if (y >= alheight) - { - y = alheight - 1; - } // // Convert x value to residue position @@ -170,19 +162,23 @@ public class OverviewDimensions // 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 - xAsRes = hiddenCols.adjustForHiddenColumns(hiddenCols - .findColumnPosition(xAsRes)); - - // get where end res should be by adding the viewport width on - int endRes = xAsRes + vpwidth; + int visXAsRes = hiddenCols.findColumnPosition(xAsRes); // check in case we went off the edge of the alignment - if (endRes > alwidth) + int visAlignWidth = hiddenCols.findColumnPosition(alwidth - 1); + if (visXAsRes + vpwidth - 1 > visAlignWidth) { // went past the end of the alignment, adjust backwards - endRes = alwidth; - // recalc xAsRes backwards from endRes - xAsRes = endRes - vpwidth; + + // if last position was before the end of the alignment, need to update + if ((scrollCol + vpwidth - 1) < visAlignWidth) + { + visXAsRes = hiddenCols.findColumnNToLeft(vpwidth - 1, alwidth - 1); + } + else + { + visXAsRes = scrollCol; + } } // @@ -193,6 +189,7 @@ public class OverviewDimensions int yAsSeq = Math.round((float) y * alheight / sequencesHeight); // get viewport height in sequences + // add 1 because height includes both endSeq and startSeq int vpheight = props.getEndSeq() - props.getStartSeq() + 1; // get where y should be when accounting for hidden rows @@ -203,21 +200,30 @@ public class OverviewDimensions .findIndexWithoutHiddenSeqs(yAsSeq)); // get where end seq should be by adding the viewport height on - int endSeq = yAsSeq + vpheight; + int endSeq = yAsSeq + vpheight - 1; // check in case we went off the edge of the alignment - if (endSeq > alheight) + int visAlignHeight = hiddenSeqs.findIndexWithoutHiddenSeqs(alheight); + int visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq); + if (hiddenSeqs.findIndexWithoutHiddenSeqs(endSeq) > visAlignHeight) { // went past the end of the alignment, adjust backwards - endSeq = alheight; - // recalc yAsSeq backwards from endSeq - yAsSeq = endSeq - vpheight + 1; + if ((scrollRow + vpheight - 1) < visAlignHeight) + { + visYAsRes = hiddenSeqs + .findIndexNAboveRow(vpheight - 1, alheight - 1); + } + else + { + visYAsRes = scrollRow; + } } // convert absolute positions back to visible alignment positions for // viewport scrolling - scrollCol = hiddenCols.findColumnPosition(xAsRes); - scrollRow = hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq); + scrollCol = visXAsRes; + scrollRow = visYAsRes; // hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq); + } /** @@ -250,6 +256,8 @@ public class OverviewDimensions boxY = Math.round((float) startSeq * sequencesHeight / alheight); // boxWidth is the width in residues translated to pixels + // since the box includes both the start and end residues, add 1 to the + // difference boxWidth = Math .round((float) (endRes - startRes + 1) * width / alwidth); // boxHeight is the height in sequences translated to pixels