From: kiramt Date: Fri, 10 Mar 2017 12:08:45 +0000 (+0000) Subject: JAL-2388 Moving some alignment panel logic into overview (in progress) X-Git-Tag: Release_2_10_2~3^2~92^2~44 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=7e66b58086ec1368feaa6c32e6478d66734c152a JAL-2388 Moving some alignment panel logic into overview (in progress) --- diff --git a/src/jalview/viewmodel/OverviewDimensions.java b/src/jalview/viewmodel/OverviewDimensions.java index 4a2dd29..4af4175 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 >= width) - { - x = alwidth - 1; - } if (y < 0) { y = 0; } - else if (y >= sequencesHeight) - { - y = alheight - 1; - } // // Convert x value to residue position @@ -178,13 +170,14 @@ public class OverviewDimensions int endRes = xAsRes + vpwidth - 1; // check in case we went off the edge of the alignment - if (endRes > alwidth) + int visAlignWidth = hiddenCols.findColumnPosition(alwidth); + if (endRes > visAlignWidth - 1) { // went past the end of the alignment, adjust backwards - endRes = alwidth; + endRes = visAlignWidth - 1; // recalc xAsRes backwards from endRes // add 1 because width includes xAsRes - xAsRes = endRes - vpwidth + 1; + xAsRes = hiddenCols.adjustForHiddenColumns(endRes - vpwidth + 1); } // @@ -209,10 +202,11 @@ public class OverviewDimensions int endSeq = yAsSeq + vpheight - 1; // check in case we went off the edge of the alignment - if (endSeq > alheight) + int visAlignHeight = hiddenSeqs.findIndexWithoutHiddenSeqs(alheight); + if (hiddenSeqs.findIndexWithoutHiddenSeqs(endSeq) > visAlignHeight - 1) { // went past the end of the alignment, adjust backwards - endSeq = alheight; + endSeq = visAlignHeight - 1; // recalc yAsSeq backwards from endSeq yAsSeq = endSeq - vpheight + 1; } diff --git a/test/jalview/viewmodel/OverviewDimensionsTest.java b/test/jalview/viewmodel/OverviewDimensionsTest.java index e86f41b..8ceadba 100644 --- a/test/jalview/viewmodel/OverviewDimensionsTest.java +++ b/test/jalview/viewmodel/OverviewDimensionsTest.java @@ -39,28 +39,8 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @Test(singleThreaded = true) -public class OverviewDimensionsTest { - - SequenceI seq1 = new Sequence( - "Seq1", - "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); - - SequenceI seq2 = new Sequence( - "Seq2", - "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); - - SequenceI seq3 = new Sequence( - "Seq3", - "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); - - SequenceI seq4 = new Sequence( - "Seq4", - "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); - - SequenceI seq5 = new Sequence( - "Seq5", - "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC"); - +public class OverviewDimensionsTest +{ AlignmentI al; OverviewDimensions od; @@ -509,19 +489,18 @@ public class OverviewDimensionsTest { // click to left of hidden cols, with overlap // boxX and scrollCol adjusted for hidden cols, width normal - /* xpos = Math.round((float) 145 * od.getWidth() / alwidth) - boxWidth; - mouseClick(od, xpos, 0); - assertEquals( - od.getBoxX(), - Math.round((firstHidden - 1) * od.getWidth() / alwidth) - - boxWidth); - assertEquals(od.getBoxY(), 0); - assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(od.getScrollCol(), - Math.round(od.getBoxX() * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), 0); - */ + xpos = Math.round((float) 145 * od.getWidth() / alwidth) - boxWidth; + mouseClick(od, xpos, 0); + assertEquals(od.getBoxX(), + Math.round((firstHidden - 1) * od.getWidth() / alwidth) + - boxWidth); + assertEquals(od.getBoxY(), 0); + assertEquals(od.getBoxWidth(), boxWidth); + assertEquals(od.getBoxHeight(), boxHeight); + assertEquals(od.getScrollCol(), + Math.round(od.getBoxX() * alwidth / od.getWidth())); + assertEquals(od.getScrollRow(), 0); + // click in hidden cols // boxX and scrollCol adjusted for hidden cols, width normal // TODO breaks as above test