X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fviewmodel%2FOverviewDimensionsHideHiddenTest.java;fp=test%2Fjalview%2Fviewmodel%2FOverviewDimensionsHideHiddenTest.java;h=4640674fd665a060c4fa55b351bdd9d5950d3155;hb=3459a8a691cb22508d7067f240b7254e588e77d3;hp=f6a9d32c71bd017ca50400329499116ab28204fc;hpb=5b27f1062b2203c4c31702e205f4c78e1992063e;p=jalview.git diff --git a/test/jalview/viewmodel/OverviewDimensionsHideHiddenTest.java b/test/jalview/viewmodel/OverviewDimensionsHideHiddenTest.java index f6a9d32..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) @@ -232,10 +237,8 @@ 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())); // overly large boxY value reset to sequenceHeight - boxHeight mouseClick(od, 10, 520); @@ -249,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); @@ -261,10 +262,8 @@ 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(20); @@ -280,10 +279,8 @@ public class OverviewDimensionsHideHiddenTest assertEquals(vpranges.getStartRes(), Math.round((float) od.getBoxX() * alwidth / od.getWidth())); assertEquals(od.getBoxY(), oldboxy + 3); - assertEquals( - vpranges.getStartSeq(), - Math.round((float) od.getBoxY() * alheight - / od.getSequencesHeight())); + assertEquals(vpranges.getStartSeq(), Math.round( + (float) od.getBoxY() * alheight / od.getSequencesHeight())); // click at top corner mouseClick(od, 0, 0); @@ -350,7 +347,7 @@ public class OverviewDimensionsHideHiddenTest 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; @@ -367,7 +364,7 @@ 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 = 54 - boxWidth / 2; // 54 is position in overview approx halfway - // between cols 60 and 70 + // between cols 60 and 70 mouseClick(od, xpos, boxHeight / 2); testBoxIsAtClickPoint(xpos, boxHeight / 2); assertEquals(vpranges.getStartRes(), 1 + // rounding @@ -379,9 +376,8 @@ public class OverviewDimensionsHideHiddenTest xpos = 33; mouseClick(od, xpos, boxHeight / 2); testBoxIsAtClickPoint(xpos, boxHeight / 2); - assertEquals(vpranges.getStartRes(), - Math.round((float) (xpos - boxWidth / 2) * alwidth - / od.getWidth())); + 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 @@ -406,7 +402,7 @@ public class OverviewDimensionsHideHiddenTest 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; @@ -461,9 +457,8 @@ public class OverviewDimensionsHideHiddenTest 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.getStartRes(), Math.round( + (float) (xpos - boxWidth / 2) * alwidth / od.getWidth())); assertEquals(vpranges.getStartSeq(), 0); // click off end of alignment @@ -541,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); @@ -619,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); @@ -642,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 @@ -660,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); } @@ -684,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 @@ -702,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); } @@ -723,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 @@ -742,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); @@ -774,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); @@ -821,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); @@ -881,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); @@ -910,11 +900,9 @@ public class OverviewDimensionsHideHiddenTest 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); } @@ -961,10 +949,8 @@ public class OverviewDimensionsHideHiddenTest public void testDragging() { od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols); - od.setDragPoint(4, 16, al.getHiddenSequences(), - hiddenCols); - od.adjustViewportFromMouse(20, 22, - 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 @@ -1039,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 @@ -1061,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);