X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fviewmodel%2FOverviewDimensionsHideHiddenTest.java;h=4640674fd665a060c4fa55b351bdd9d5950d3155;hb=57738a1f3c19b1c3a00bd3ac5108f8cd0af32f99;hp=28b7029b5b5c718b5c8c3dfdbdcc8cb5047950aa;hpb=65935d012d531c438ccca3bd07056c0e7327a28a;p=jalview.git diff --git a/test/jalview/viewmodel/OverviewDimensionsHideHiddenTest.java b/test/jalview/viewmodel/OverviewDimensionsHideHiddenTest.java index 28b7029..4640674 100644 --- a/test/jalview/viewmodel/OverviewDimensionsHideHiddenTest.java +++ b/test/jalview/viewmodel/OverviewDimensionsHideHiddenTest.java @@ -50,10 +50,15 @@ public class OverviewDimensionsHideHiddenTest // cached widths and heights int boxWidth; + int boxHeight; + int viewHeight; + int viewWidth; + int alheight; + int alwidth; ViewportRanges vpranges; @@ -79,7 +84,7 @@ public class OverviewDimensionsHideHiddenTest } ColumnSelection colsel = new ColumnSelection(); hiddenCols.revealAllHiddenColumns(colsel); - + vpranges = new ViewportRanges(al); vpranges.setViewportStartAndHeight(0, 18); vpranges.setViewportStartAndWidth(0, 63); @@ -100,12 +105,12 @@ public class OverviewDimensionsHideHiddenTest alheight = vpranges.getVisibleAlignmentHeight(); alwidth = vpranges.getVisibleAlignmentWidth(); - boxWidth = Math.round((float) (vpranges.getEndRes() - - vpranges.getStartRes() + 1) - * od.getWidth() / alwidth); - boxHeight = Math.round((float) (vpranges.getEndSeq() - - vpranges.getStartSeq() + 1) - * od.getSequencesHeight() / alheight); + boxWidth = Math.round( + (float) (vpranges.getEndRes() - vpranges.getStartRes() + 1) + * od.getWidth() / alwidth); + boxHeight = Math.round( + (float) (vpranges.getEndSeq() - vpranges.getStartSeq() + 1) + * od.getSequencesHeight() / alheight); } @AfterClass(alwaysRun = true) @@ -212,7 +217,7 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxX(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(vpranges.getStartSeq(), + assertEquals(vpranges.getStartSeq() + vpranges.getViewportHeight() / 2, Math.round((float) 10 * alheight / od.getSequencesHeight())); assertEquals(vpranges.getStartRes(), 0); @@ -221,26 +226,23 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); - assertEquals(vpranges.getStartRes(), - Math.round((float) 6 * alwidth / od.getWidth())); + 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(vpranges.getStartRes(), Math.round((float) od.getBoxX() * alwidth / od.getWidth())); - assertEquals( - vpranges.getStartSeq(), - Math.round((float) od.getBoxY() * alheight - / od.getSequencesHeight())); + 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); @@ -250,10 +252,8 @@ public class OverviewDimensionsHideHiddenTest // 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( - vpranges.getStartSeq(), - Math.round((float) od.getBoxY() * alheight - / od.getSequencesHeight()) - 1); + assertEquals(vpranges.getStartSeq(), Math.round( + (float) od.getBoxY() * alheight / od.getSequencesHeight()) - 1); // click past end of alignment, as above mouseClick(od, 3000, 5); @@ -262,28 +262,25 @@ public class OverviewDimensionsHideHiddenTest assertEquals(od.getBoxHeight(), boxHeight); assertEquals(vpranges.getStartRes(), Math.round((float) od.getBoxX() * alwidth / od.getWidth())); - assertEquals( - vpranges.getStartSeq(), - Math.round((float) od.getBoxY() * alheight - / od.getSequencesHeight())); + 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(vpranges.getStartRes(), Math.round((float) od.getBoxX() * alwidth / od.getWidth())); - assertEquals(od.getBoxY(), oldboxy + 2); - assertEquals( - vpranges.getStartSeq(), - Math.round((float) od.getBoxY() * alheight - / od.getSequencesHeight())); + assertEquals(od.getBoxY(), oldboxy + 3); + assertEquals(vpranges.getStartSeq(), Math.round( + (float) od.getBoxY() * alheight / od.getSequencesHeight())); // click at top corner mouseClick(od, 0, 0); @@ -313,20 +310,20 @@ public class OverviewDimensionsHideHiddenTest 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); + testBoxIsAtClickPoint(41 + boxWidth / 2, boxHeight / 2); assertEquals(vpranges.getStartSeq(), 0); assertEquals(vpranges.getStartRes(), - Math.round((float) 40 * alwidth / od.getWidth())); + 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); @@ -344,20 +341,20 @@ 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(vpranges.getStartRes(), 0); assertEquals(vpranges.getStartSeq(), 0); - + // hide columns 63-73, no change to box position or dimensions int firstHidden = 63; int lastHidden = 73; 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); @@ -366,45 +363,50 @@ public class OverviewDimensionsHideHiddenTest // 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 - // between cols 60 and 70 - mouseClick(od, xpos, 0); - testBoxIsAtClickPoint(xpos, 0); - assertEquals(vpranges.getStartRes(), - Math.round(xpos * alwidth / od.getWidth())); + int xpos = 54 - boxWidth / 2; // 54 is position in overview approx halfway + // between cols 60 and 70 + 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(vpranges.getStartRes(), - Math.round((float) xpos * alwidth / od.getWidth())); + 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(vpranges.getStartRes(), - Math.round((float) xpos * alwidth / od.getWidth())); + 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); + 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(), - Math.round(xpos * alwidth / od.getWidth())); - + 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); @@ -442,19 +444,21 @@ public class OverviewDimensionsHideHiddenTest // click to left of hidden cols, without overlapping // boxX, scrollCol and width as normal - int xpos = 5; - testBoxIsAtClickPoint(xpos, 0); - assertEquals(vpranges.getStartSeq(), 0); - assertEquals(vpranges.getStartRes(), - 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(vpranges.getStartRes(), - Math.round((float) xpos * alwidth / od.getWidth())); + 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 @@ -532,9 +536,8 @@ public class OverviewDimensionsHideHiddenTest // move viewport to end of alignment - need to make startRes by removing // hidden cols because of how viewport/overview are implemented moveViewport(98 - lastHidden - 1, 0); - assertEquals(od.getBoxX(), - Math.round((float) (98 - lastHidden - 1) * od.getWidth() - / alwidth)); + assertEquals(od.getBoxX(), Math.round( + (float) (98 - lastHidden - 1) * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -610,9 +613,8 @@ public class OverviewDimensionsHideHiddenTest // viewport can't actually extend into hidden cols, // so move to the far right edge of the viewport moveViewport(firstHidden - viewWidth, 0); - assertEquals(od.getBoxX(), - Math.round((float) (firstHidden - viewWidth) - * od.getWidth() / alwidth)); + assertEquals(od.getBoxX(), Math.round( + (float) (firstHidden - viewWidth) * od.getWidth() / alwidth)); assertEquals(od.getBoxY(), 0); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); @@ -633,12 +635,12 @@ public class OverviewDimensionsHideHiddenTest alheight = vpranges.getVisibleAlignmentHeight(); alwidth = vpranges.getVisibleAlignmentWidth(); - boxWidth = Math.round((float) (vpranges.getEndRes() - - vpranges.getStartRes() + 1) - * od.getWidth() / alwidth); - boxHeight = Math.round((float) (vpranges.getEndSeq() - - vpranges.getStartSeq() + 1) - * od.getSequencesHeight() / alheight); + boxWidth = Math.round( + (float) (vpranges.getEndRes() - vpranges.getStartRes() + 1) + * od.getWidth() / alwidth); + boxHeight = Math.round( + (float) (vpranges.getEndSeq() - vpranges.getStartSeq() + 1) + * od.getSequencesHeight() / alheight); // move viewport to start of alignment: // box moves to below hidden rows, height remains same @@ -651,11 +653,9 @@ public class OverviewDimensionsHideHiddenTest // move viewport to end of alignment moveViewport(0, 525 - viewHeight - lastHidden - 1); assertEquals(od.getBoxX(), 0); - assertEquals( - od.getBoxY(), + assertEquals(od.getBoxY(), Math.round((float) (525 - viewHeight - lastHidden - 1) - * od.getSequencesHeight() - / alheight)); + * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); } @@ -675,12 +675,12 @@ public class OverviewDimensionsHideHiddenTest alheight = vpranges.getVisibleAlignmentHeight(); alwidth = vpranges.getVisibleAlignmentWidth(); - boxWidth = Math.round((float) (vpranges.getEndRes() - - vpranges.getStartRes() + 1) - * od.getWidth() / alwidth); - boxHeight = Math.round((float) (vpranges.getEndSeq() - - vpranges.getStartSeq() + 1) - * od.getSequencesHeight() / alheight); + boxWidth = Math.round( + (float) (vpranges.getEndRes() - vpranges.getStartRes() + 1) + * od.getWidth() / alwidth); + boxHeight = Math.round( + (float) (vpranges.getEndSeq() - vpranges.getStartSeq() + 1) + * od.getSequencesHeight() / alheight); // move viewport to start of alignment: // box, height etc as in non-hidden case @@ -693,8 +693,8 @@ public class OverviewDimensionsHideHiddenTest // move viewport to straddle hidden rows moveViewport(0, 198); assertEquals(od.getBoxX(), 0); - assertEquals(od.getBoxY(), Math.round ((float)198 * od.getSequencesHeight() - / alheight)); + assertEquals(od.getBoxY(), + Math.round((float) 198 * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); } @@ -714,12 +714,12 @@ public class OverviewDimensionsHideHiddenTest alheight = vpranges.getVisibleAlignmentHeight(); alwidth = vpranges.getVisibleAlignmentWidth(); - boxWidth = Math.round((float) (vpranges.getEndRes() - - vpranges.getStartRes() + 1) - * od.getWidth() / alwidth); - boxHeight = Math.round((float) (vpranges.getEndSeq() - - vpranges.getStartSeq() + 1) - * od.getSequencesHeight() / alheight); + boxWidth = Math.round( + (float) (vpranges.getEndRes() - vpranges.getStartRes() + 1) + * od.getWidth() / alwidth); + boxHeight = Math.round( + (float) (vpranges.getEndSeq() - vpranges.getStartSeq() + 1) + * od.getSequencesHeight() / alheight); // move viewport to start of alignment: // box, height etc as in non-hidden case @@ -733,8 +733,7 @@ public class OverviewDimensionsHideHiddenTest // viewport sits above hidden rows and does not include them moveViewport(0, firstHidden - viewHeight - 1); assertEquals(od.getBoxX(), 0); - assertEquals( - od.getBoxY(), + assertEquals(od.getBoxY(), Math.round((float) (firstHidden - viewHeight - 1) * od.getSequencesHeight() / alheight)); assertEquals(od.getBoxWidth(), boxWidth); @@ -765,12 +764,12 @@ public class OverviewDimensionsHideHiddenTest alheight = vpranges.getVisibleAlignmentHeight(); alwidth = vpranges.getVisibleAlignmentWidth(); - boxWidth = Math.round((float) (vpranges.getEndRes() - - vpranges.getStartRes() + 1) - * od.getWidth() / alwidth); - boxHeight = Math.round((float) (vpranges.getEndSeq() - - vpranges.getStartSeq() + 1) - * od.getSequencesHeight() / alheight); + boxWidth = Math.round( + (float) (vpranges.getEndRes() - vpranges.getStartRes() + 1) + * od.getWidth() / alwidth); + boxHeight = Math.round( + (float) (vpranges.getEndSeq() - vpranges.getStartSeq() + 1) + * od.getSequencesHeight() / alheight); od.setBoxPosition(al.getHiddenSequences(), hiddenCols); assertEquals(od.getBoxX(), 0); @@ -779,9 +778,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); } @@ -812,12 +811,12 @@ public class OverviewDimensionsHideHiddenTest alheight = vpranges.getVisibleAlignmentHeight(); alwidth = vpranges.getVisibleAlignmentWidth(); - boxWidth = Math.round((float) (vpranges.getEndRes() - - vpranges.getStartRes() + 1) - * od.getWidth() / alwidth); - boxHeight = Math.round((float) (vpranges.getEndSeq() - - vpranges.getStartSeq() + 1) - * od.getSequencesHeight() / alheight); + boxWidth = Math.round( + (float) (vpranges.getEndRes() - vpranges.getStartRes() + 1) + * od.getWidth() / alwidth); + boxHeight = Math.round( + (float) (vpranges.getEndSeq() - vpranges.getStartSeq() + 1) + * od.getSequencesHeight() / alheight); od.setBoxPosition(al.getHiddenSequences(), hiddenCols); @@ -827,22 +826,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); } @@ -872,12 +871,12 @@ public class OverviewDimensionsHideHiddenTest alheight = vpranges.getVisibleAlignmentHeight(); alwidth = vpranges.getVisibleAlignmentWidth(); - boxWidth = Math.round((float) (vpranges.getEndRes() - - vpranges.getStartRes() + 1) - * od.getWidth() / alwidth); - boxHeight = Math.round((float) (vpranges.getEndSeq() - - vpranges.getStartSeq() + 1) - * od.getSequencesHeight() / alheight); + boxWidth = Math.round( + (float) (vpranges.getEndRes() - vpranges.getStartRes() + 1) + * od.getWidth() / alwidth); + boxHeight = Math.round( + (float) (vpranges.getEndSeq() - vpranges.getStartSeq() + 1) + * od.getSequencesHeight() / alheight); od.setBoxPosition(al.getHiddenSequences(), hiddenCols); assertEquals(od.getBoxX(), 0); @@ -886,26 +885,24 @@ 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); - assertEquals( - od.getBoxY(), - Math.round((float) firstHidden * od.getSequencesHeight() - / alheight) - - boxHeight); + assertEquals(od.getBoxY(), Math + .round((float) firstHidden * od.getSequencesHeight() / alheight) + - boxHeight); assertEquals(od.getBoxWidth(), boxWidth); assertEquals(od.getBoxHeight(), boxHeight); } @@ -945,6 +942,49 @@ public class OverviewDimensionsHideHiddenTest 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. */ @@ -985,7 +1025,7 @@ public class OverviewDimensionsHideHiddenTest // normally od.setBoxPosition(al.getHiddenSequences(), hiddenCols); } - + /* * Test that the box is positioned with the top left corner at xpos, ypos * and with the original width and height @@ -993,8 +1033,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); @@ -1007,7 +1047,7 @@ public class OverviewDimensionsHideHiddenTest { SequenceI[] allseqs = al.getSequencesArray(); SequenceGroup theseSeqs = new SequenceGroup(); - + for (int i = start; i <= end; i++) { theseSeqs.addSequence(allseqs[i], false);