JAL-2388 Hidden cols separated from column selection (almost complete)
[jalview.git] / test / jalview / viewmodel / OverviewDimensionsTest.java
index e86f41b..57aa60b 100644 (file)
@@ -26,6 +26,7 @@ import jalview.analysis.AlignmentGenerator;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceGroup;
@@ -39,28 +40,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;
 
@@ -72,11 +53,11 @@ public class OverviewDimensionsTest {
   int alheight;
   int alwidth;
 
-  ViewportPositionProps posProps;
+  ViewportRanges vpranges;
 
   Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences = new Hashtable<SequenceI, SequenceCollectionI>();
 
-  ColumnSelection hiddenCols = new ColumnSelection();
+  HiddenColumns hiddenCols = new HiddenColumns();
 
   @BeforeClass(alwaysRun = true)
   public void setUpJvOptionPane()
@@ -93,35 +74,36 @@ public class OverviewDimensionsTest {
     {
       al.getHiddenSequences().showAll(hiddenRepSequences);
     }
-    hiddenCols.revealAllHiddenColumns();
+    ColumnSelection colsel = new ColumnSelection();
+    hiddenCols.revealAllHiddenColumns(colsel);
     
-    posProps = new ViewportPositionProps(al);
-    posProps.setStartRes(0);
-    posProps.setEndRes(62);
-    posProps.setStartSeq(0);
-    posProps.setEndSeq(17);
+    vpranges = new ViewportRanges(al);
+    vpranges.setStartRes(0);
+    vpranges.setEndRes(62);
+    vpranges.setStartSeq(0);
+    vpranges.setEndSeq(17);
 
-    viewHeight = posProps.getEndSeq() - posProps.getStartSeq() + 1;
-    viewWidth = posProps.getEndRes() - posProps.getStartRes() + 1;
+    viewHeight = vpranges.getEndSeq() - vpranges.getStartSeq() + 1;
+    viewWidth = vpranges.getEndRes() - vpranges.getStartRes() + 1;
 
-    ColumnSelection hiddenCols = new ColumnSelection();
+    HiddenColumns hiddenCols = new HiddenColumns();
 
-    od = new OverviewDimensions(posProps, true);
+    od = new OverviewDimensions(vpranges, true);
     // Initial box sizing - default path through code
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
 
     mouseClick(od, 0, 0);
     moveViewport(0, 0);
 
     // calculate before hidden columns so we get absolute values
-    alheight = posProps.getAbsoluteAlignmentHeight();
-    alwidth = posProps.getAbsoluteAlignmentWidth();
+    alheight = vpranges.getAbsoluteAlignmentHeight();
+    alwidth = vpranges.getAbsoluteAlignmentWidth();
 
-    boxWidth = Math.round((float) (posProps.getEndRes()
-            - posProps.getStartRes() + 1)
+    boxWidth = Math.round((float) (vpranges.getEndRes()
+            - vpranges.getStartRes() + 1)
             * od.getWidth() / alwidth);
-    boxHeight = Math.round((float) (posProps.getEndSeq()
-            - posProps.getStartSeq() + 1)
+    boxHeight = Math.round((float) (vpranges.getEndSeq()
+            - vpranges.getStartSeq() + 1)
             * od.getSequencesHeight() / alheight);
   }
 
@@ -154,10 +136,10 @@ public class OverviewDimensionsTest {
     // test for alignment with width > height
     SequenceI[] seqs1 = new SequenceI[] { seqa, seqb };
     Alignment al1 = new Alignment(seqs1);
-    ViewportPositionProps props = new ViewportPositionProps(al1);
+    ViewportRanges props = new ViewportRanges(al1);
 
     OverviewDimensions od = new OverviewDimensions(props, true);
-    int scaledHeight = 266;
+    int scaledHeight = 267;
     assertEquals(od.getGraphHeight(), defaultGraphHeight);
     assertEquals(od.getSequencesHeight(), scaledHeight);
     assertEquals(od.getWidth(), maxWidth);
@@ -166,7 +148,7 @@ public class OverviewDimensionsTest {
     // test for alignment with width < height
     SequenceI[] seqs2 = new SequenceI[] { seqa, seqb, seqc, seqd };
     Alignment al2 = new Alignment(seqs2);
-    props = new ViewportPositionProps(al2);
+    props = new ViewportRanges(al2);
 
     od = new OverviewDimensions(props, true);
     int scaledWidth = 300;
@@ -179,7 +161,7 @@ public class OverviewDimensionsTest {
     // min value
     SequenceI[] seqs3 = new SequenceI[] { seqe };
     Alignment al3 = new Alignment(seqs3);
-    props = new ViewportPositionProps(al3);
+    props = new ViewportRanges(al3);
 
     od = new OverviewDimensions(props, true);
     assertEquals(od.getGraphHeight(), defaultGraphHeight);
@@ -191,7 +173,7 @@ public class OverviewDimensionsTest {
     SequenceI[] seqs4 = new SequenceI[] { seqa, seqb, seqc, seqd, seqa,
         seqb, seqc, seqd, seqa, seqb, seqc, seqd, seqa, seqb, seqc, seqd };
     Alignment al4 = new Alignment(seqs4);
-    props = new ViewportPositionProps(al4);
+    props = new ViewportRanges(al4);
 
     od = new OverviewDimensions(props, true);
     assertEquals(od.getGraphHeight(), defaultGraphHeight);
@@ -200,7 +182,7 @@ public class OverviewDimensionsTest {
     assertEquals(od.getHeight(), maxSeqHeight + defaultGraphHeight);
 
     Alignment al5 = new Alignment(seqs4);
-    props = new ViewportPositionProps(al5);
+    props = new ViewportRanges(al5);
 
     od = new OverviewDimensions(props, false);
     assertEquals(od.getGraphHeight(), 0);
@@ -218,7 +200,7 @@ public class OverviewDimensionsTest {
   public void testSetBoxFromMouseClick()
   {
     od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
-            posProps);
+            vpranges);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -245,7 +227,7 @@ public class OverviewDimensionsTest {
 
     // overly large boxX value reset to width-boxWidth
     mouseClick(od, 100, 6);
-    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1);
+    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
     assertEquals(od.getBoxY(), 6);
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
@@ -263,13 +245,17 @@ public class OverviewDimensionsTest {
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
             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(),
             Math.round((float) od.getBoxY() * alheight
-                    / od.getSequencesHeight()));
+                    / od.getSequencesHeight()) - 1);
 
     // click past end of alignment, as above
     mouseClick(od, 3000, 5);
-    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1);
+    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
@@ -313,7 +299,7 @@ public class OverviewDimensionsTest {
   public void testFromMouseWithHiddenColsAtStart()
   {
     od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
-            posProps);
+            vpranges);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -325,7 +311,7 @@ public class OverviewDimensionsTest {
     int lastHiddenCol = 30;
     hiddenCols.hideColumns(0, lastHiddenCol);
 
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
     assertEquals(od.getBoxX(),
             Math.round((float) (lastHiddenCol + 1) * od.getWidth()
                     / alwidth));
@@ -333,7 +319,6 @@ public class OverviewDimensionsTest {
     assertEquals(od.getBoxHeight(), boxHeight);
 
     // try to click in hidden cols, check box does not move
-    // this test currently fails as the overview box does not behave like this!
     int xpos = 10;
     mouseClick(od, xpos, 0);
     assertEquals(
@@ -359,7 +344,7 @@ public class OverviewDimensionsTest {
     // overly large boxX value reset to width-boxWidth
     xpos = 100;
     mouseClick(od, xpos, 5);
-    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1);
+    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
     assertEquals(od.getBoxY(), 5);
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
@@ -379,7 +364,7 @@ public class OverviewDimensionsTest {
   public void testFromMouseWithHiddenColsInMiddle()
   {
     od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
-            posProps);
+            vpranges);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -391,7 +376,7 @@ public class OverviewDimensionsTest {
     int lastHidden = 73;
     hiddenCols.hideColumns(firstHidden, lastHidden);
 
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -460,7 +445,7 @@ public class OverviewDimensionsTest {
     // boxX, scrollCol adjusted back, box width normal
     xpos = 3000;
     mouseClick(od, xpos, 5);
-    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth() + 1);
+    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
     assertEquals(od.getBoxY(), 5);
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
@@ -481,7 +466,7 @@ public class OverviewDimensionsTest {
   public void testFromMouseWithHiddenColsAtEnd()
   {
     od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
-            posProps);
+            vpranges);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -492,7 +477,7 @@ public class OverviewDimensionsTest {
     int firstHidden = 140;
     int lastHidden = 164;
     hiddenCols.hideColumns(firstHidden, lastHidden);
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -509,48 +494,43 @@ 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((float) (firstHidden - 1) * od.getWidth() / alwidth)
+                    - boxWidth + 1);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+    assertEquals(od.getScrollCol(),
+            Math.round((float) 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
-    /*xpos = 115;
-    assertEquals(
-            od.getBoxX(),
-            Math.round((firstHidden - 1) * scalew * av.getCharWidth())
-                    - od.getBoxWidth());
+    xpos = 115;
+    assertEquals(od.getBoxX(),
+            Math.round((float) (firstHidden - 1) * od.getWidth() / alwidth)
+                    - boxWidth + 1);
     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);*/
+            Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
+    assertEquals(od.getScrollRow(), 0);
 
     // click off end of alignment
     // boxX and scrollCol adjusted for hidden cols, width normal
-    // TODO breaks as above test
-    /*    xpos = 3000;
-        assertEquals(
-                od.getBoxX(),
-                Math.round((firstHidden - 1) * scalew * av.getCharWidth())
-                        - od.getBoxWidth());
-        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 = 3000;
+    assertEquals(od.getBoxX(),
+            Math.round((float) (firstHidden - 1) * od.getWidth() / alwidth)
+                    - boxWidth + 1);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+    assertEquals(od.getScrollCol(),
+            Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
+    assertEquals(od.getScrollRow(), 0);
   }
 
   /**
@@ -699,13 +679,14 @@ public class OverviewDimensionsTest {
     assertEquals(od.getBoxHeight(), boxHeight);
 
     // move viewport to hidden columns
-    moveViewport(102, 0);
+    // 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) 102 * od.getWidth() / alwidth));
+            Math.round((float) (firstHidden - viewWidth)
+                    * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
-    assertEquals(od.getBoxWidth(), boxWidth
-                    + Math.round((float) (lastHidden - firstHidden)
-                            * od.getWidth() / alwidth));
+    assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
   }
 
@@ -812,7 +793,7 @@ public class OverviewDimensionsTest {
   public void testFromMouseWithHiddenRowsAtStart()
   {
     od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
-            posProps);
+            vpranges);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxHeight(), boxHeight);
@@ -825,7 +806,7 @@ public class OverviewDimensionsTest {
     int lastHiddenRow = 30;
     hideSequences(0, lastHiddenRow);
 
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(),
             Math.round((float) (lastHiddenRow + 1)
@@ -859,7 +840,7 @@ public class OverviewDimensionsTest {
   public void testFromMouseWithHiddenRowsInMiddle()
   {
     od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
-            posProps);
+            vpranges);
 
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
@@ -871,10 +852,10 @@ public class OverviewDimensionsTest {
     // hide rows in middle and check updated box position is correct
     // no changes
     int firstHiddenRow = 50;
-    int lastHiddenRow = 60;
+    int lastHiddenRow = 54;
     hideSequences(firstHiddenRow, lastHiddenRow);
 
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
 
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
@@ -882,34 +863,32 @@ public class OverviewDimensionsTest {
     assertEquals(od.getBoxHeight(), boxHeight);
 
     // click above hidden rows, so that box overlaps
-    int ypos = 40;
-    // TODO test fails because box does not change height - dealt with by scroll
-    // values
-    /*    mouseClick(od, 0, Math.round (ypos * alheight / od.getSequencesHeight()));
-        assertEquals(od.getBoxX(), 0);
-        assertEquals(od.getBoxY(), Math.round (ypos * alheight / od.getSequencesHeight()),
-                1.5);
-        assertEquals(od.getBoxWidth(), boxWidth);
-        assertEquals(
-                od.getBoxHeight(),
-                boxHeight
-                        + Math.round ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av
-                                .getCharHeight()));
-    */
+    int ypos = 35; // column 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));
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(
+            od.getBoxHeight(),
+            boxHeight
+                    + Math.round((float) (lastHiddenRow - firstHiddenRow + 1)
+                            * od.getSequencesHeight() / alheight));
+
     // click so that box straddles hidden rows
-    ypos = 48;
-    // TODO test fails because box does not change height - dealt with by scroll
-    // values
-    /*mouseClick(od, 0, Math.round (ypos * alheight / od.getSequencesHeight()));
+    ypos = 44; // column value in residues
+    mouseClick(od, 0,
+            Math.round((float) ypos * od.getSequencesHeight() / alheight));
     assertEquals(od.getBoxX(), 0);
-    assertEquals(od.getBoxY(), Math.round (ypos * alheight / od.getSequencesHeight()),
-            1.5);
+    assertEquals(od.getBoxY(),
+            Math.round((float) ypos * od.getSequencesHeight() / alheight));
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(
             od.getBoxHeight(),
             boxHeight
-                    + Math.round ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av
-                            .getCharHeight()));*/
+                    + Math.round((float) (lastHiddenRow - firstHiddenRow + 1)
+                            * od.getSequencesHeight() / alheight));
   }
 
   /**
@@ -920,7 +899,7 @@ public class OverviewDimensionsTest {
   public void testFromMouseWithHiddenRowsAtEnd()
   {
     od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
-            posProps);
+            vpranges);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -934,7 +913,7 @@ public class OverviewDimensionsTest {
     int lastHidden = 524;
     hideSequences(firstHidden, lastHidden);
 
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -952,29 +931,28 @@ public class OverviewDimensionsTest {
 
     // click above hidden rows so box overlaps
     // boxY moved upwards, boxHeight remains same
-    // TODO fails with boxY located at row 497 - correction done by
-    // setScrollValues
-    /*   ypos = 497; // row 497
-       mouseClick(od, 0, Math.round (ypos * scaleh * av.getCharHeight()));
-       assertEquals(od.getBoxX(), 0);
-       assertEquals(
-               od.getBoxY(),
-               Math.round ((firstHidden - viewHeight) * scaleh * av.getCharHeight()),
-               1.5);
-       assertEquals(od.getBoxWidth(), boxWidth);
-       assertEquals(od.getBoxHeight(), boxHeight);*/
+    ypos = 497; // row 497
+    mouseClick(od, 0,
+            Math.round((float) ypos * od.getSequencesHeight() / alheight));
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(
+            od.getBoxY(),
+            Math.round((float) (firstHidden - viewHeight)
+                    * od.getSequencesHeight() / alheight));
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
 
     // click within hidden rows
     ypos = 505;
-    // TODO: fails with wrong boxHeight - correction done by setScrollValues(?)
-    /*mouseClick(od, 0, Math.round (ypos * scaleh * av.getCharHeight()));
+    mouseClick(od, 0,
+            Math.round((float) ypos * od.getSequencesHeight() / alheight));
     assertEquals(od.getBoxX(), 0);
     assertEquals(
             od.getBoxY(),
-            Math.round ((firstHidden - viewHeight) * scaleh * av.getCharHeight()),
-            1.5);
+            Math.round((firstHidden - viewHeight) * od.getSequencesHeight()
+                    / alheight));
     assertEquals(od.getBoxWidth(), boxWidth);
-    assertEquals(od.getBoxHeight(), boxHeight);*/
+    assertEquals(od.getBoxHeight(), boxHeight);
   }
 
   /*
@@ -982,9 +960,9 @@ public class OverviewDimensionsTest {
    */
   private void moveViewportH(int startRes)
   {
-    posProps.setStartRes(startRes);
-    posProps.setEndRes(startRes + viewWidth - 1);
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+    vpranges.setStartRes(startRes);
+    vpranges.setEndRes(startRes + viewWidth - 1);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
   }
 
   /*
@@ -992,9 +970,9 @@ public class OverviewDimensionsTest {
    */
   private void moveViewportV(int startSeq)
   {
-    posProps.setStartSeq(startSeq);
-    posProps.setEndSeq(startSeq + viewHeight - 1);
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+    vpranges.setStartSeq(startSeq);
+    vpranges.setEndSeq(startSeq + viewHeight - 1);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
   }
 
   /*
@@ -1002,11 +980,11 @@ public class OverviewDimensionsTest {
    */
   private void moveViewport(int startRes, int startSeq)
   {
-    posProps.setStartRes(startRes);
-    posProps.setEndRes(startRes + viewWidth - 1);
-    posProps.setStartSeq(startSeq);
-    posProps.setEndSeq(startSeq + viewHeight - 1);
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+    vpranges.setStartRes(startRes);
+    vpranges.setEndRes(startRes + viewWidth - 1);
+    vpranges.setStartSeq(startSeq);
+    vpranges.setEndSeq(startSeq + viewHeight - 1);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
   }
 
   /*
@@ -1015,17 +993,17 @@ public class OverviewDimensionsTest {
   private void mouseClick(OverviewDimensions od, int x, int y)
   {
     od.updateViewportFromMouse(x, y, al.getHiddenSequences(), hiddenCols,
-            posProps);
+            vpranges);
 
     // updates require an OverviewPanel to exist which it doesn't here
     // so call setBoxPosition() as it would be called by the AlignmentPanel
     // normally
 
-    posProps.setStartRes(od.getScrollCol());
-    posProps.setEndRes(od.getScrollCol() + viewWidth - 1);
-    posProps.setStartSeq(od.getScrollRow());
-    posProps.setEndSeq(od.getScrollRow() + viewHeight - 1);
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, posProps);
+    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, vpranges);
   }
   
   /*