X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fviewmodel%2FOverviewDimensionsHideHiddenTest.java;h=f6a9d32c71bd017ca50400329499116ab28204fc;hb=0b573ed90b14079f7326281f50c0c9cffdace586;hp=2bd9c474c03112cf3a12ce0ba3cbf39bd578d96f;hpb=460c037bef9ec113c2a46010c443d85e73347592;p=jalview.git diff --git a/test/jalview/viewmodel/OverviewDimensionsHideHiddenTest.java b/test/jalview/viewmodel/OverviewDimensionsHideHiddenTest.java index 2bd9c47..f6a9d32 100644 --- a/test/jalview/viewmodel/OverviewDimensionsHideHiddenTest.java +++ b/test/jalview/viewmodel/OverviewDimensionsHideHiddenTest.java @@ -21,6 +21,8 @@ package jalview.viewmodel; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; import jalview.analysis.AlignmentGenerator; import jalview.datamodel.Alignment; @@ -56,7 +58,7 @@ public class OverviewDimensionsHideHiddenTest ViewportRanges vpranges; - Hashtable hiddenRepSequences = new Hashtable(); + Hashtable hiddenRepSequences = new Hashtable<>(); HiddenColumns hiddenCols = new HiddenColumns(); @@ -79,10 +81,8 @@ public class OverviewDimensionsHideHiddenTest hiddenCols.revealAllHiddenColumns(colsel); vpranges = new ViewportRanges(al); - vpranges.setStartRes(0); - vpranges.setEndRes(62); - vpranges.setStartSeq(0); - vpranges.setEndSeq(17); + vpranges.setViewportStartAndHeight(0, 18); + vpranges.setViewportStartAndWidth(0, 63); viewHeight = vpranges.getEndSeq() - vpranges.getStartSeq() + 1; viewWidth = vpranges.getEndRes() - vpranges.getStartRes() + 1; @@ -204,52 +204,53 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getScrollCol(), 0); - assertEquals(od.getScrollRow(), 0); + assertEquals(vpranges.getStartRes(), 0); + assertEquals(vpranges.getStartSeq(), 0); // negative boxX value reset to 0 mouseClick(od, -5, 10); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(od.getScrollRow(), + assertEquals(vpranges.getStartSeq() + vpranges.getViewportHeight() / 2, Math.round((float) 10 * alheight / od.getSequencesHeight())); - assertEquals(od.getScrollCol(), 0); + assertEquals(vpranges.getStartRes(), 0); // negative boxY value reset to 0 mouseClick(od, 6, -2); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(od.getScrollCol(), - Math.round((float) 6 * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), 0); + assertEquals(vpranges.getStartRes(), 0); + assertEquals(vpranges.getStartSeq(), 0); // overly large boxX value reset to width-boxWidth - mouseClick(od, 100, 6); + mouseClick(od, 101, 6); assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth()); - assertEquals(od.getBoxY(), 6); + assertEquals(od.getBoxY(), 1); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(od.getScrollCol(), + assertEquals(vpranges.getStartRes(), Math.round((float) od.getBoxX() * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), + assertEquals( + vpranges.getStartSeq(), Math.round((float) od.getBoxY() * alheight / od.getSequencesHeight())); // overly large boxY value reset to sequenceHeight - boxHeight mouseClick(od, 10, 520); - assertEquals(od.getBoxX(), 10); + assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), od.getSequencesHeight() - od.getBoxHeight()); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(od.getScrollCol(), + assertEquals(vpranges.getStartRes(), Math.round((float) od.getBoxX() * alwidth / od.getWidth())); // here (float) od.getBoxY() * alheight / od.getSequencesHeight() = 507.5 // and round rounds to 508; however we get 507 working with row values // hence the subtraction of 1 - assertEquals(od.getScrollRow(), + assertEquals( + vpranges.getStartSeq(), Math.round((float) od.getBoxY() * alheight / od.getSequencesHeight()) - 1); @@ -258,35 +259,38 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth()); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(od.getScrollCol(), + assertEquals(vpranges.getStartRes(), Math.round((float) od.getBoxX() * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), + assertEquals( + vpranges.getStartSeq(), Math.round((float) od.getBoxY() * alheight / od.getSequencesHeight())); // move viewport so startRes non-zero and then mouseclick - moveViewportH(50); + moveViewportH(20); // click at viewport position int oldboxx = od.getBoxX(); int oldboxy = od.getBoxY(); - mouseClick(od, od.getBoxX() + 5, od.getBoxY() + 2); - assertEquals(od.getBoxX(), oldboxx + 5); + mouseClick(od, od.getBoxX() + od.getBoxWidth() / 2 + 6, + od.getBoxY() + od.getBoxHeight() / 2 + 3); + assertEquals(od.getBoxX(), oldboxx + 6); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(od.getScrollCol(), + assertEquals(vpranges.getStartRes(), Math.round((float) od.getBoxX() * alwidth / od.getWidth())); - assertEquals(od.getBoxY(), oldboxy + 2); - assertEquals(od.getScrollRow(), + assertEquals(od.getBoxY(), oldboxy + 3); + assertEquals( + vpranges.getStartSeq(), Math.round((float) od.getBoxY() * alheight / od.getSequencesHeight())); // click at top corner mouseClick(od, 0, 0); assertEquals(od.getBoxX(), 0); - assertEquals(od.getScrollCol(), 0); + assertEquals(vpranges.getStartRes(), 0); assertEquals(od.getBoxY(), 0); - assertEquals(od.getScrollRow(), 0); + assertEquals(vpranges.getStartSeq(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); } @@ -302,34 +306,34 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getScrollCol(), 0); - assertEquals(od.getScrollRow(), 0); + assertEquals(vpranges.getStartRes(), 0); + assertEquals(vpranges.getStartSeq(), 0); // hide cols at start and check updated box position is correct int lastHiddenCol = 30; hiddenCols.hideColumns(0, lastHiddenCol); - testBoxIsAtClickPoint(0, 0); + testBoxIsAtClickPoint(boxWidth / 2, boxHeight / 2); // click to right of hidden columns, box moves to click point - testBoxIsAtClickPoint(40, 0); - assertEquals(od.getScrollRow(), 0); - assertEquals(od.getScrollCol(), - Math.round((float) 40 * alwidth / od.getWidth())); + testBoxIsAtClickPoint(41 + boxWidth / 2, boxHeight / 2); + assertEquals(vpranges.getStartSeq(), 0); + assertEquals(vpranges.getStartRes(), + Math.round((float) 41 * alwidth / od.getWidth())); // click to right of hidden columns such that box runs over right hand side // of alignment // box position is adjusted away from the edge // overly large boxX value reset to width-boxWidth - int xpos = 100; - mouseClick(od, xpos, 0); + int xpos = 100 + boxWidth / 2; + mouseClick(od, xpos, boxHeight / 2); assertEquals(od.getBoxX(), Math.round(od.getWidth()) - boxWidth); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(od.getScrollCol(), + assertEquals(vpranges.getStartRes(), Math.round((float) od.getBoxX() * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), 0); + assertEquals(vpranges.getStartSeq(), 0); } /** @@ -340,12 +344,12 @@ public class OverviewDimensionsHideHiddenTest public void testFromMouseWithHiddenColsInMiddle() { od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols); - testBoxIsAtClickPoint(0, 0); + testBoxIsAtClickPoint(boxWidth / 2, boxHeight / 2); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getScrollCol(), 0); - assertEquals(od.getScrollRow(), 0); + assertEquals(vpranges.getStartRes(), 0); + assertEquals(vpranges.getStartSeq(), 0); // hide columns 63-73, no change to box position or dimensions int firstHidden = 63; @@ -353,61 +357,67 @@ public class OverviewDimensionsHideHiddenTest hiddenCols.hideColumns(firstHidden, lastHidden); od.setBoxPosition(al.getHiddenSequences(), hiddenCols); - testBoxIsAtClickPoint(0, 0); + testBoxIsAtClickPoint(boxWidth / 2, boxHeight / 2); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getScrollCol(), 0); - assertEquals(od.getScrollRow(), 0); + assertEquals(vpranges.getStartRes(), 0); + assertEquals(vpranges.getStartSeq(), 0); // move box so that it overlaps with hidden cols on one side // box width, boxX and scrollCol as for unhidden case - int xpos = 55 - boxWidth; // 55 is position in overview approx halfway + int xpos = 54 - boxWidth / 2; // 54 is position in overview approx halfway // between cols 60 and 70 - mouseClick(od, xpos, 0); - testBoxIsAtClickPoint(xpos, 0); - assertEquals(od.getScrollCol(), - Math.round(xpos * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), 0); + mouseClick(od, xpos, boxHeight / 2); + testBoxIsAtClickPoint(xpos, boxHeight / 2); + assertEquals(vpranges.getStartRes(), 1 + // rounding + Math.round((xpos - boxWidth / 2) * alwidth / od.getWidth())); + assertEquals(vpranges.getStartSeq(), 0); // move box so that it completely covers hidden cols // box width, boxX and scrollCol as for unhidden case xpos = 33; - mouseClick(od, xpos, 0); - testBoxIsAtClickPoint(xpos, 0); - assertEquals(od.getScrollCol(), - Math.round((float) xpos * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), 0); + mouseClick(od, xpos, boxHeight / 2); + testBoxIsAtClickPoint(xpos, boxHeight / 2); + assertEquals(vpranges.getStartRes(), + Math.round((float) (xpos - boxWidth / 2) * alwidth + / od.getWidth())); + assertEquals(vpranges.getStartSeq(), 0); // move box so boxX is in hidden cols, box overhangs at right // boxX and scrollCol at left of hidden area, box width unchanged - xpos = 50; - mouseClick(od, xpos, 0); - testBoxIsAtClickPoint(xpos, 0); - assertEquals(od.getScrollCol(), - Math.round((float) xpos * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), 0); + xpos = Math.round((float) 50 * od.getWidth() / alwidth) + boxWidth / 2; + mouseClick(od, xpos, boxHeight / 2); + assertEquals(od.getBoxX() + od.getBoxWidth() / 2, xpos); + assertEquals(od.getBoxY(), 0); + assertEquals(od.getBoxWidth(), boxWidth); + assertEquals(od.getBoxHeight(), boxHeight); + assertEquals(vpranges.getStartRes(), 50); + assertEquals(vpranges.getStartSeq(), 0); // move box so boxX is to right of hidden cols, but does not go beyond full // width of alignment // box width, boxX and scrollCol all as for non-hidden case - xpos = 75; - testBoxIsAtClickPoint(xpos, 0); - assertEquals(od.getScrollRow(), 0); - assertEquals(od.getScrollCol(), - Math.round(xpos * alwidth / od.getWidth())); + xpos = Math.round((float) 75 * od.getWidth() / alwidth) + boxWidth / 2; + mouseClick(od, xpos, boxHeight / 2); + assertEquals(od.getBoxX() + od.getBoxWidth() / 2, xpos); + assertEquals(od.getBoxY(), 0); + assertEquals(od.getBoxWidth(), boxWidth); + assertEquals(od.getBoxHeight(), boxHeight); + assertEquals(vpranges.getStartSeq(), 0); + assertEquals(vpranges.getStartRes(), 75); // move box so it goes beyond full width of alignment // boxX, scrollCol adjusted back, box width normal xpos = 3000; - mouseClick(od, xpos, 0); + mouseClick(od, xpos, boxHeight / 2); assertEquals(od.getBoxX(), Math.round(od.getWidth()) - boxWidth); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(od.getScrollCol(), + assertEquals(vpranges.getStartRes(), Math.round((float) od.getBoxX() * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), 0); + assertEquals(vpranges.getStartSeq(), 0); } @@ -422,8 +432,8 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getScrollCol(), 0); - assertEquals(od.getScrollRow(), 0); + assertEquals(vpranges.getStartRes(), 0); + assertEquals(vpranges.getStartSeq(), 0); // hide columns 140-164, no change to box position or dimensions int firstHidden = 140; @@ -433,25 +443,28 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getScrollCol(), 0); - assertEquals(od.getScrollRow(), 0); + assertEquals(vpranges.getStartRes(), 0); + assertEquals(vpranges.getStartSeq(), 0); // click to left of hidden cols, without overlapping // boxX, scrollCol and width as normal - int xpos = 5; - testBoxIsAtClickPoint(xpos, 0); - assertEquals(od.getScrollRow(), 0); - assertEquals(od.getScrollCol(), - Math.round((float) xpos * alwidth / od.getWidth())); + int xpos = 30; + int ypos = 6; + testBoxIsAtClickPoint(xpos, ypos); + assertEquals(vpranges.getStartSeq(), Math.round( + (float) (ypos - boxHeight / 2) * alheight / od.getHeight())); + assertEquals(vpranges.getStartRes(), Math.round( + (float) (xpos - boxWidth / 2) * alwidth / od.getWidth())); // 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); - testBoxIsAtClickPoint(xpos, 0); - assertEquals(od.getScrollCol(), - Math.round((float) xpos * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), 0); + xpos = Math.round((float) 144 * od.getWidth() / alwidth) - boxWidth; + mouseClick(od, xpos, boxHeight / 2); + testBoxIsAtClickPoint(xpos, boxHeight / 2); + assertEquals(vpranges.getStartRes(), + Math.round((float) (xpos - boxWidth / 2) * alwidth + / od.getWidth())); + assertEquals(vpranges.getStartSeq(), 0); // click off end of alignment // boxX and scrollCol adjusted backwards, width normal @@ -461,9 +474,9 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(od.getScrollCol(), + assertEquals(vpranges.getStartRes(), Math.round((float) od.getBoxX() * alwidth / od.getWidth())); - assertEquals(od.getScrollRow(), 0); + assertEquals(vpranges.getStartSeq(), 0); } /** @@ -750,8 +763,8 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxHeight(), boxHeight); assertEquals(od.getBoxWidth(), boxWidth); - assertEquals(od.getScrollCol(), 0); - assertEquals(od.getScrollRow(), 0); + assertEquals(vpranges.getStartRes(), 0); + assertEquals(vpranges.getStartSeq(), 0); // hide rows at start and check updated box position is correct int lastHiddenRow = 30; @@ -775,9 +788,9 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxHeight(), boxHeight); // click below hidden rows - mouseClick(od, 0, 150); + mouseClick(od, 0, 151 + boxHeight / 2); assertEquals(od.getBoxX(), 0); - assertEquals(od.getBoxY(), 150); + assertEquals(od.getBoxY(), 151); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); } @@ -795,8 +808,8 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(od.getScrollCol(), 0); - assertEquals(od.getScrollRow(), 0); + assertEquals(vpranges.getStartRes(), 0); + assertEquals(vpranges.getStartSeq(), 0); // hide rows in middle and check updated box position is correct // no changes @@ -823,22 +836,22 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxHeight(), boxHeight); // click above hidden rows, so that box overlaps - int ypos = 35; // column value in residues + int ypos = 35 + viewHeight / 2; // row value in residues mouseClick(od, 0, Math.round((float) ypos * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), - Math.round((float) ypos * od.getSequencesHeight() / alheight)); + Math.round((float) 35 * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); // click so that box straddles hidden rows - ypos = 44; // column value in residues + ypos = 45 + viewHeight / 2; // row value in residues mouseClick(od, 0, Math.round((float) ypos * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), - Math.round((float) ypos * od.getSequencesHeight() / alheight)); + Math.round((float) 45 * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); } @@ -855,8 +868,8 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(od.getScrollCol(), 0); - assertEquals(od.getScrollRow(), 0); + assertEquals(vpranges.getStartRes(), 0); + assertEquals(vpranges.getStartSeq(), 0); // hide rows at end and check updated box position is correct // no changes @@ -882,18 +895,18 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxHeight(), boxHeight); // click above hidden rows - int ypos = 40; // row 40 + int ypos = 41 + viewHeight / 2; // row 41 mouseClick(od, 0, Math.round((float) ypos * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxY(), - Math.round((float) ypos * od.getSequencesHeight() / alheight)); + Math.round((float) 41 * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); // click above hidden rows so box overlaps // boxY, boxHeight remains same - ypos = 497; // row 497 + ypos = 497 + viewHeight / 2; // row 497 mouseClick(od, 0, Math.round((float) ypos * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxX(), 0); @@ -906,13 +919,92 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxHeight(), boxHeight); } + /** + * Test the function to determine if a point is in the overview's box or not + */ + @Test(groups = { "Functional" }) + public void testPositionInBox() + { + od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols); + + assertFalse(od.isPositionInBox(0, 0)); + assertTrue(od.isPositionInBox(10, 9)); + assertFalse(od.isPositionInBox(0, 9)); + assertFalse(od.isPositionInBox(9, 0)); + assertFalse(od.isPositionInBox(75, 20)); + + // hide columns in the box area + // makes absolutely no difference + hiddenCols.hideColumns(1, 4); + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); + assertFalse(od.isPositionInBox(0, 0)); + assertTrue(od.isPositionInBox(10, 9)); + assertFalse(od.isPositionInBox(0, 9)); + assertFalse(od.isPositionInBox(9, 0)); + assertFalse(od.isPositionInBox(75, 20)); + + // hide sequences in box area + // makes absolutely no difference + hideSequences(1, 3); + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); + assertFalse(od.isPositionInBox(0, 0)); + assertTrue(od.isPositionInBox(10, 9)); + assertFalse(od.isPositionInBox(0, 9)); + assertFalse(od.isPositionInBox(9, 0)); + assertFalse(od.isPositionInBox(75, 20)); + } + + /** + * Test the dragging functionality + */ + @Test(groups = { "Functional" }) + public void testDragging() + { + od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols); + od.setDragPoint(4, 16, al.getHiddenSequences(), + hiddenCols); + od.adjustViewportFromMouse(20, 22, + al.getHiddenSequences(), hiddenCols); + + // updates require an OverviewPanel to exist which it doesn't here + // so call setBoxPosition() as it would be called by the AlignmentPanel + // normally + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); + + // corner moves 16 (20-4) right and 6 (22-16) up + assertEquals(od.getBoxX(), 16); + assertEquals(od.getBoxY(), 6); + + // hide columns - makes no difference + hiddenCols.hideColumns(1, 4); + od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols); + od.setDragPoint(4, 16, al.getHiddenSequences(), hiddenCols); + od.adjustViewportFromMouse(20, 22, al.getHiddenSequences(), hiddenCols); + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); + + // corner moves 16 (20-4) right and 6 (22-16) up + assertEquals(od.getBoxX(), 16); + assertEquals(od.getBoxY(), 6); + + // hide sequences in box area + // makes absolutely no difference + hideSequences(1, 3); + od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols); + od.setDragPoint(4, 16, al.getHiddenSequences(), hiddenCols); + od.adjustViewportFromMouse(20, 22, al.getHiddenSequences(), hiddenCols); + od.setBoxPosition(al.getHiddenSequences(), hiddenCols); + + // corner moves 16 (20-4) right and 6 (22-16) up + assertEquals(od.getBoxX(), 16); + assertEquals(od.getBoxY(), 6); + } + /* * Move viewport horizontally: startRes + previous width gives new horizontal extent. Vertical extent stays the same. */ private void moveViewportH(int startRes) { - vpranges.setStartRes(startRes); - vpranges.setEndRes(startRes + viewWidth - 1); + vpranges.setViewportStartAndWidth(startRes, viewWidth); od.setBoxPosition(al.getHiddenSequences(), hiddenCols); } @@ -921,8 +1013,7 @@ public class OverviewDimensionsHideHiddenTest */ private void moveViewportV(int startSeq) { - vpranges.setStartSeq(startSeq); - vpranges.setEndSeq(startSeq + viewHeight - 1); + vpranges.setViewportStartAndHeight(startSeq, viewHeight); od.setBoxPosition(al.getHiddenSequences(), hiddenCols); } @@ -931,28 +1022,21 @@ public class OverviewDimensionsHideHiddenTest */ private void moveViewport(int startRes, int startSeq) { - vpranges.setStartRes(startRes); - vpranges.setEndRes(startRes + viewWidth - 1); - vpranges.setStartSeq(startSeq); - vpranges.setEndSeq(startSeq + viewHeight - 1); + vpranges.setViewportStartAndWidth(startRes, viewWidth); + vpranges.setViewportStartAndHeight(startSeq, viewHeight); od.setBoxPosition(al.getHiddenSequences(), hiddenCols); } /* * Mouse click as position x,y in overview window */ - private void mouseClick(OverviewDimensionsHideHidden od, int x, int y) + private void mouseClick(OverviewDimensions od, int x, int y) { od.updateViewportFromMouse(x, y, al.getHiddenSequences(), hiddenCols); // updates require an OverviewPanel to exist which it doesn't here // so call setBoxPosition() as it would be called by the AlignmentPanel // normally - - vpranges.setStartRes(od.getScrollCol()); - vpranges.setEndRes(od.getScrollCol() + viewWidth - 1); - vpranges.setStartSeq(od.getScrollRow()); - vpranges.setEndSeq(od.getScrollRow() + viewHeight - 1); od.setBoxPosition(al.getHiddenSequences(), hiddenCols); } @@ -963,8 +1047,8 @@ public class OverviewDimensionsHideHiddenTest private void testBoxIsAtClickPoint(int xpos, int ypos) { mouseClick(od, xpos, ypos); - assertEquals(od.getBoxX(), xpos); - assertEquals(od.getBoxY(), ypos); + assertEquals(od.getBoxX() + od.getBoxWidth() / 2, xpos); + assertEquals(od.getBoxY() + od.getBoxHeight() / 2, ypos); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight);