JAL-2388 Initial removal of hidden cols/seqs out of overview
[jalview.git] / test / jalview / viewmodel / OverviewDimensionsTest.java
index 94fb83f..cc808d6 100644 (file)
@@ -78,6 +78,12 @@ public class OverviewDimensionsTest {
 
   int viewHeight;
 
+  int viewWidth;
+
+  int alheight;
+
+  int alwidth;
+
   @BeforeClass(alwaysRun = true)
   public void setUpJvOptionPane()
   {
@@ -135,11 +141,6 @@ public class OverviewDimensionsTest {
     
     av = af.getViewport();
 
-    if (av.isCalcInProgress())
-    {
-
-    }
-
     od = new OverviewDimensions(av);
 
     while (av.isCalcInProgress())
@@ -149,24 +150,13 @@ public class OverviewDimensionsTest {
         Thread.sleep(50);
       } catch (InterruptedException e)
       {
-        System.out.println("Hiding cols interruption");
+
       }
     }
 
     // Initial box sizing - default path through code
     od.setBoxPosition();
 
-    scalew = (float) od.getWidth()
-            / (av.getAlignment().getWidth() * av.getCharWidth());
-    scaleh = (float) od.getSequencesHeight()
-            / (av.getAlignment().getHeight() * av.getCharHeight());
-    boxWidth = Math.round((av.getEndRes() - av.getStartRes() + 1)
-            * av.getCharWidth() * scalew);
-    boxHeight = Math.round((av.getEndSeq() - av.getStartSeq())
-            * av.getCharHeight() * scaleh);
-
-    viewHeight = av.getEndSeq() - av.getStartSeq();
-
     init();
   }
 
@@ -192,6 +182,34 @@ public class OverviewDimensionsTest {
 
     mouseClick(od, 0, 0);
     moveViewport(0, 0);
+
+    viewHeight = av.getEndSeq() - av.getStartSeq();
+    viewWidth = av.getEndRes() - av.getStartRes();
+
+    // wait for gui to get set up
+    while (viewHeight != 17 || viewWidth != 59)
+    {
+      try
+      {
+        Thread.sleep(50);
+        viewHeight = av.getEndSeq() - av.getStartSeq();
+        viewWidth = av.getEndRes() - av.getStartRes();
+      } catch (InterruptedException e)
+      {
+
+      }
+    }
+
+    // calculate before hidden columns so we get absolute values
+    alheight = av.getAlignment().getHeight();
+    alwidth = av.getAlignment().getWidth();
+
+    boxWidth = Math.round((float) (av.getEndRes() - av.getStartRes() + 1)
+            / alwidth * od.getWidth());
+    boxHeight = Math.round((float) (av.getEndSeq() - av.getStartSeq())
+            / alheight * od.getHeight());
+    System.out.println(boxHeight);
+
   }
 
   @AfterMethod(alwaysRun = true)
@@ -318,7 +336,7 @@ public class OverviewDimensionsTest {
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollRow(),
-            Math.round(10 / scaleh / av.getCharHeight()));
+            Math.round((float) 10 * alheight / od.getSequencesHeight()));
     assertEquals(od.getScrollCol(), 0);
 
     // negative boxY value reset to 0
@@ -327,41 +345,43 @@ public class OverviewDimensionsTest {
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            Math.round(6 / scalew / av.getCharWidth()));
+            Math.round((float) 6 * alwidth / od.getWidth()));
     assertEquals(od.getScrollRow(), 0);
 
     // overly large boxX value reset to width-boxWidth
     mouseClick(od, 100, 6);
-    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth(), 1.5);
-    assertEquals(od.getBoxY(), 6, 1.5);
+    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
+    assertEquals(od.getBoxY(), 6);
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            (od.getBoxX() / scalew / av.getCharWidth()), 1.5);
+            Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
     assertEquals(od.getScrollRow(),
-            (od.getBoxY() / scaleh / av.getCharHeight()), 1.5);
+            Math.round((float) od.getBoxY() * alheight
+                    / od.getSequencesHeight()));
 
     // overly large boxY value reset to sequenceHeight - boxHeight
     mouseClick(od, 10, 520);
-    assertEquals(od.getBoxX(), 10, 1.5);
-    assertEquals(od.getBoxY(), od.getSequencesHeight() - od.getBoxHeight(),
-            1.5);
+    assertEquals(od.getBoxX(), 10);
+    assertEquals(od.getBoxY(), od.getSequencesHeight() - od.getBoxHeight());
     assertEquals(od.getBoxWidth(), boxWidth);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+    assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            (od.getBoxX() / scalew / av.getCharWidth()), 1.5);
+            Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
     assertEquals(od.getScrollRow(),
-            (od.getBoxY() / scaleh / av.getCharHeight()), 1.5);
+            Math.round((float) od.getBoxY() * alheight
+                    / od.getSequencesHeight()));
 
     // click past end of alignment, as above
     mouseClick(od, 3000, 5);
-    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth(), 1.5);
+    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
     assertEquals(od.getBoxWidth(), boxWidth);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+    assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            (od.getBoxX() / scalew / av.getCharWidth()), 1.5);
+            Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
     assertEquals(od.getScrollRow(),
-            (od.getBoxY() / scaleh / av.getCharHeight()), 1.5);
+            Math.round((float) od.getBoxY() * alheight
+                    / od.getSequencesHeight()));
 
     // move viewport so startRes non-zero and then mouseclick
     moveViewportH(50);
@@ -370,14 +390,15 @@ public class OverviewDimensionsTest {
     int oldboxx = od.getBoxX();
     int oldboxy = od.getBoxY();
     mouseClick(od, od.getBoxX() + 5, od.getBoxY() + 2);
-    assertEquals(od.getBoxX(), oldboxx + 5, 1.5);
+    assertEquals(od.getBoxX(), oldboxx + 5);
     assertEquals(od.getBoxWidth(), boxWidth);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+    assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            (od.getBoxX() / scalew / av.getCharWidth()), 1.5);
-    assertEquals(od.getBoxY(), oldboxy + 2, 1.5);
+            Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
+    assertEquals(od.getBoxY(), oldboxy + 2);
     assertEquals(od.getScrollRow(),
-            (od.getBoxY() / scaleh / av.getCharHeight()), 1.5);
+            Math.round((float) od.getBoxY() * alheight
+                    / od.getSequencesHeight()));
 
     // click at top corner
     mouseClick(od, 0, 0);
@@ -386,7 +407,7 @@ public class OverviewDimensionsTest {
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getScrollRow(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+    assertEquals(od.getBoxHeight(), boxHeight);
   }
 
   /**
@@ -410,7 +431,8 @@ public class OverviewDimensionsTest {
 
     od.setBoxPosition();
     assertEquals(od.getBoxX(),
-            Math.round((lastHiddenCol + 1) * scalew * av.getCharWidth()));
+            Math.round((float) (lastHiddenCol + 1) * od.getWidth()
+                    / alwidth));
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
 
@@ -419,21 +441,20 @@ public class OverviewDimensionsTest {
     /*    int xpos = 10;
         mouseClick(od, xpos, 0);
         assertEquals(od.getBoxX(),
-                Math.round ((lastHiddenCol + 1) * scalew * av.getCharWidth()));
+                Math.round ((lastHiddenCol + 1) * od.getWidth() / alwidth));
         assertEquals(od.getBoxY(), 0);
         assertEquals(od.getBoxWidth(), boxWidth);
         assertEquals(od.getBoxHeight(), boxHeight);
         assertEquals(od.getScrollRow(), 0);
         assertEquals(od.getScrollCol(),
-                Math.round (xpos / scalew / av.getCharWidth()));
+                Math.round (xpos * alwidth / od.getWidth()));
     */
     // click to right of hidden columns, box moves to click point
     testBoxIsAtClickPoint(40, 0);
     assertEquals(od.getScrollRow(), 0);
     assertEquals(od.getScrollCol(),
-            Math.round(40 / scalew / av.getCharWidth())
- - lastHiddenCol,
-            1.5);
+            Math.round((float) 40 * alwidth / od.getWidth())
+                    - (lastHiddenCol + 1));
 
     // click to right of hidden columns such that box runs over right hand side
     // of alignment
@@ -441,16 +462,16 @@ public class OverviewDimensionsTest {
     // overly large boxX value reset to width-boxWidth
     int xpos = 100;
     mouseClick(od, xpos, 5);
-    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth(), 1.5);
+    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
     assertEquals(od.getBoxY(), 5);
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            Math.round(od.getBoxX() / scalew / av.getCharWidth())
-                    - lastHiddenCol, 1.5);
+            Math.round((float) od.getBoxX() * alwidth / od.getWidth())
+                    - (lastHiddenCol + 1));
     assertEquals(od.getScrollRow(),
-            Math.round(od.getBoxY() / scaleh / av.getCharHeight()));
-
+            Math.round((float) od.getBoxY() * alheight
+                    / od.getSequencesHeight()));
   }
 
   /**
@@ -478,7 +499,7 @@ public class OverviewDimensionsTest {
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getScrollCol(), 0);
     assertEquals(od.getScrollRow(), 0);
-    
+
     // move box so that it overlaps with hidden cols on one side
     // box width changes, boxX and scrollCol as for unhidden case
     int xpos = 50 - boxWidth; // 50 is position in overview halfway between cols
@@ -488,11 +509,11 @@ public class OverviewDimensionsTest {
     assertEquals(od.getBoxY(), 0);
     assertEquals(
             od.getBoxWidth(),
-            Math.round(boxWidth + (lastHidden - firstHidden + 1) * scalew
-                    * av.getCharWidth()));
+            Math.round(boxWidth + (float) (lastHidden - firstHidden + 1)
+                    * od.getWidth() / alwidth));
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            Math.round(xpos / scalew / av.getCharWidth()));
+            Math.round(xpos * alwidth / od.getWidth()));
     assertEquals(od.getScrollRow(), 0);
 
     // move box so that it completely covers hidden cols
@@ -503,11 +524,11 @@ public class OverviewDimensionsTest {
     assertEquals(od.getBoxY(), 0);
     assertEquals(
             od.getBoxWidth(),
-            Math.round(boxWidth + (lastHidden - firstHidden + 1) * scalew
-                    * av.getCharWidth()));
+            Math.round(boxWidth + (float) (lastHidden - firstHidden + 1)
+                    * od.getWidth() / alwidth));
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            Math.round(xpos / scalew / av.getCharWidth()), 1.5);
+            Math.round(xpos * alwidth / od.getWidth()));
     assertEquals(od.getScrollRow(), 0);
 
     // move box so boxX is in hidden cols, box overhangs at right
@@ -517,12 +538,12 @@ public class OverviewDimensionsTest {
     /*    xpos = 50;
         mouseClick(od, xpos, 0);
         assertEquals(od.getBoxX(),
-                (lastHidden + 1) * scalew * av.getCharWidth(), 1.5);
+                (lastHidden + 1) * scalew * av.getCharWidth());
         assertEquals(od.getBoxY(), 0);
-        assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+        assertEquals(od.getBoxWidth(), boxWidth);
         assertEquals(od.getBoxHeight(), boxHeight);
         assertEquals(od.getScrollCol(),
-                Math.round(xpos / scalew / av.getCharWidth()), 1.5);
+                Math.round(xpos * alwidth / od.getWidth()));
         assertEquals(od.getScrollRow(), 0);*/
 
     // move box so boxX is to right of hidden cols, but does not go beyond full
@@ -538,22 +559,23 @@ public class OverviewDimensionsTest {
        testBoxIsAtClickPoint(xpos, 0);
        assertEquals(od.getScrollRow(), 0);
        assertEquals(od.getScrollCol(),
-               Math.round(xpos / scalew / av.getCharWidth())
-               - lastHidden, 1.5);*/
+               Math.round(xpos * alwidth / od.getWidth())
+               - lastHidden);*/
     
     // move box so it goes beyond full width of alignment
     // boxX, scrollCol adjusted back, box width normal
     xpos = 3000;
     mouseClick(od, xpos, 5);
-    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth(), 1.5);
+    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
     assertEquals(od.getBoxY(), 5);
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            Math.round((od.getBoxX() / scalew / av.getCharWidth())
+            Math.round(((float) od.getBoxX() * alwidth / od.getWidth())
                     - (lastHidden - firstHidden + 1)));
     assertEquals(od.getScrollRow(),
-            Math.round(od.getBoxY() / scaleh / av.getCharHeight()));
+            Math.round((float) od.getBoxY() * alheight
+                    / od.getSequencesHeight()));
 
   }
 
@@ -588,7 +610,7 @@ public class OverviewDimensionsTest {
     testBoxIsAtClickPoint(xpos, 0);
     assertEquals(od.getScrollRow(), 0);
     assertEquals(od.getScrollCol(),
-            Math.round(xpos / scalew / av.getCharWidth()), 1.5);
+            Math.round((float) xpos * alwidth / od.getWidth()));
 
     // click to left of hidden cols, with overlap
     // boxX and scrollCol adjusted for hidden cols, width normal
@@ -599,12 +621,12 @@ public class OverviewDimensionsTest {
     assertEquals(
             od.getBoxX(),
             Math.round((firstHidden - 1) * scalew * av.getCharWidth())
-                    - od.getBoxWidth(), 1.5);
+                    - od.getBoxWidth());
     assertEquals(od.getBoxY(), 0);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+    assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            Math.round(od.getBoxX() / scalew / av.getCharWidth()), 1.5);
+            Math.round(od.getBoxX() * alwidth / od.getWidth()));
     assertEquals(od.getScrollRow(), 0);*/
 
     // click in hidden cols
@@ -614,12 +636,12 @@ public class OverviewDimensionsTest {
     assertEquals(
             od.getBoxX(),
             Math.round((firstHidden - 1) * scalew * av.getCharWidth())
-                    - od.getBoxWidth(), 1.5);
+                    - od.getBoxWidth());
     assertEquals(od.getBoxY(), 0);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+    assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            Math.round(od.getBoxX() / scalew / av.getCharWidth()), 1.5);
+            Math.round(od.getBoxX() * alwidth / od.getWidth()));
     assertEquals(od.getScrollRow(), 0);*/
 
     // click off end of alignment
@@ -629,12 +651,12 @@ public class OverviewDimensionsTest {
         assertEquals(
                 od.getBoxX(),
                 Math.round((firstHidden - 1) * scalew * av.getCharWidth())
-                        - od.getBoxWidth(), 1.5);
+                        - od.getBoxWidth());
         assertEquals(od.getBoxY(), 0);
-        assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+        assertEquals(od.getBoxWidth(), boxWidth);
         assertEquals(od.getBoxHeight(), boxHeight);
         assertEquals(od.getScrollCol(),
-                Math.round(od.getBoxX() / scalew / av.getCharWidth()), 1.5);
+                Math.round(od.getBoxX() * alwidth / od.getWidth()));
         assertEquals(od.getScrollRow(), 0);*/
   }
 
@@ -654,25 +676,28 @@ public class OverviewDimensionsTest {
 
     // move viewport to right
     moveViewportH(70);
-    assertEquals(od.getBoxX(), Math.round(70 * scalew * av.getCharWidth()));
+    assertEquals(od.getBoxX(),
+            Math.round((float) 70 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
 
     // move viewport down
     moveViewportV(100);
-    assertEquals(od.getBoxX(), Math.round(70 * scalew * av.getCharWidth()));
+    assertEquals(od.getBoxX(),
+            Math.round((float) 70 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(),
-            Math.round(100 * scaleh * av.getCharHeight()));
+            Math.round(100 * od.getSequencesHeight() / alheight));
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
 
     // move viewport to bottom right
     moveViewport(98, 508);
-    assertEquals(od.getBoxX(), Math.round(98 * scalew * av.getCharWidth()));
+    assertEquals(od.getBoxX(),
+            Math.round((float) 98 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(),
-            Math.round(508 * scaleh * av.getCharHeight()));
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+            Math.round((float) 508 * od.getSequencesHeight() / alheight));
+    assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
   }
 
@@ -690,7 +715,7 @@ public class OverviewDimensionsTest {
     // move viewport to start of alignment
     moveViewport(0, 0);
     assertEquals(od.getBoxX(),
-            Math.round((lastHidden + 1) * scalew * av.getCharWidth()));
+            Math.round((float) (lastHidden + 1) * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
@@ -698,7 +723,8 @@ public class OverviewDimensionsTest {
     // 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(98 * scalew * av.getCharWidth()));
+    assertEquals(od.getBoxX(),
+            Math.round((float) 98 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
@@ -718,7 +744,8 @@ public class OverviewDimensionsTest {
     // move viewport before hidden columns
     moveViewport(3, 0);
 
-    assertEquals(od.getBoxX(), Math.round(3 * scalew * av.getCharWidth()));
+    assertEquals(od.getBoxX(),
+            Math.round((float) 3 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
     System.out.println(od.getBoxWidth());
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -727,30 +754,32 @@ public class OverviewDimensionsTest {
 
     // move viewport to left of hidden columns with overlap
     moveViewport(10, 0);
-    assertEquals(od.getBoxX(), Math.round(10 * scalew * av.getCharWidth()));
+    assertEquals(od.getBoxX(),
+            Math.round((float) 10 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
     assertEquals(
             od.getBoxWidth(),
             boxWidth
-                    + Math.round((lastHidden - firstHidden + 1) * scalew
-                            * av.getCharWidth()));
+                    + Math.round((float) (lastHidden - firstHidden + 1)
+                            * od.getWidth() / alwidth));
     assertEquals(od.getBoxHeight(), boxHeight);
 
     // move viewport to straddle hidden columns
     moveViewport(60, 0);
-    assertEquals(od.getBoxX(), Math.round(60 * scalew * av.getCharWidth()));
+    assertEquals(od.getBoxX(),
+            Math.round((float) 60 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
     assertEquals(
             od.getBoxWidth(),
             boxWidth
-                    + Math.round((lastHidden - firstHidden + 1) * scalew
-                            * av
-.getCharWidth()));
+                    + Math.round((lastHidden - firstHidden + 1)
+                            * od.getWidth() / alwidth));
     assertEquals(od.getBoxHeight(), boxHeight);
 
     // move viewport to right of hidden columns, no overlap
     moveViewport(80 - (lastHidden - firstHidden + 1), 0);
-    assertEquals(od.getBoxX(), Math.round(80 * scalew * av.getCharWidth()));
+    assertEquals(od.getBoxX(),
+            Math.round((float) 80 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
@@ -770,8 +799,8 @@ public class OverviewDimensionsTest {
 
     // move viewport before hidden columns
     moveViewport(3, 0);
-    assertEquals(od.getBoxX(), Math.round(3 * scalew * av.getCharWidth()),
-            1.5);
+    assertEquals(od.getBoxX(),
+            Math.round((float) 3 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
@@ -779,14 +808,14 @@ public class OverviewDimensionsTest {
     // move viewport to hidden columns
     // TODO boxwidth includes hidden in overview panel (why?)
     moveViewport(98, 0);
-    assertEquals(od.getBoxX(), Math.round(98 * scalew * av.getCharWidth()),
-            1.5);
+    assertEquals(od.getBoxX(),
+            Math.round((float) 98 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
     assertEquals(
             od.getBoxWidth(),
             boxWidth
-                    + Math.round((lastHidden - firstHidden + 1) * scalew
-                            * av.getCharWidth()), 1.5);
+                    + Math.round((float) (lastHidden - firstHidden + 1)
+                            * od.getWidth() / alwidth));
     assertEquals(od.getBoxHeight(), boxHeight);
   }
 
@@ -806,7 +835,8 @@ public class OverviewDimensionsTest {
     moveViewport(0, 0);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(),
-            Math.round((lastHidden + 1) * scaleh * av.getCharHeight()));
+            Math.round((float) (lastHidden + 1) * od.getSequencesHeight()
+                    / alheight));
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
 
@@ -823,9 +853,9 @@ public class OverviewDimensionsTest {
         assertEquals(od.getBoxX(), 0);
         assertEquals(od.getBoxY(),
                 (525 - viewHeight) * scaleh
-                * av.getCharHeight(), 1.5);
-        assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-        assertEquals(od.getBoxHeight(), boxHeight, 1.5);*/
+                * av.getCharHeight());
+        assertEquals(od.getBoxWidth(), boxWidth);
+        assertEquals(od.getBoxHeight(), boxHeight);*/
   }
 
   /**
@@ -845,8 +875,8 @@ public class OverviewDimensionsTest {
     /*moveViewport(0, 0);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);*/
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);*/
 
     // move viewport to straddle hidden rows
     // TODO also fails with boxY out by 12
@@ -854,7 +884,7 @@ public class OverviewDimensionsTest {
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), Math.round (198 * scaleh * av.getCharHeight()),
             1.5);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+    assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight
             + ((lastHidden - firstHidden) * scaleh * av.getCharHeight()),
             1.5);*/
@@ -885,13 +915,13 @@ public class OverviewDimensionsTest {
         assertEquals(od.getBoxX(), 0);
         assertEquals(od.getBoxY(),
      Math.round ((firstHidden - viewHeight - 1)
-                * scaleh * av.getCharHeight()), 1.5);
-        assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+                * scaleh * av.getCharHeight()));
+        assertEquals(od.getBoxWidth(), boxWidth);
         assertEquals(
                 od.getBoxHeight(),
                 boxHeight
                         + Math.round ((lastHidden - firstHidden + 1) * scaleh * av
-                                .getCharHeight()), 1.5);*/
+                                .getCharHeight()));*/
 
   }
 
@@ -918,7 +948,8 @@ public class OverviewDimensionsTest {
     od.setBoxPosition();
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(),
-            Math.round((lastHiddenRow + 1) * scaleh * av.getCharHeight()));
+            Math.round((float) (lastHiddenRow + 1)
+                    * od.getSequencesHeight() / alheight));
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
 
@@ -927,7 +958,7 @@ public class OverviewDimensionsTest {
     /*    mouseClick(od, 0, 0);
         assertEquals(od.getBoxX(), 0);
         assertEquals(od.getBoxY(), 0);
-        assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+        assertEquals(od.getBoxWidth(), boxWidth);
         assertEquals(od.getBoxHeight(), boxHeight
                 + Math.round ((lastHiddenRow + 1) * scaleh * av.getCharHeight()),
                 1.5);*/
@@ -935,7 +966,7 @@ public class OverviewDimensionsTest {
     // click below hidden rows
     mouseClick(od, 0, 150);
     assertEquals(od.getBoxX(), 0);
-    assertEquals(od.getBoxY(), 150, 1.5);
+    assertEquals(od.getBoxY(), 150);
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
   }
@@ -947,12 +978,8 @@ public class OverviewDimensionsTest {
   @Test(groups = { "Functional" })
   public void testFromMouseWithHiddenRowsInMiddle()
   {
-    assertEquals(od.getBoxHeight(), 10);
-
     od.setBoxPositionByMouse(0, 0);
 
-    assertEquals(od.getBoxHeight(), 10);
-
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -964,12 +991,9 @@ public class OverviewDimensionsTest {
     // no changes
     int firstHiddenRow = 50;
     int lastHiddenRow = 60;
-    assertEquals(od.getBoxHeight(), 10);
     hideSequences(firstHiddenRow, lastHiddenRow + 1, lastHiddenRow + 1);
-    assertEquals(od.getBoxHeight(), 10);
 
     od.setBoxPosition();
-    assertEquals(od.getBoxHeight(), 10);
 
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
@@ -980,31 +1004,31 @@ public class OverviewDimensionsTest {
     int ypos = 40;
     // TODO test fails because box does not change height - dealt with by scroll
     // values
-    /*    mouseClick(od, 0, Math.round (ypos / scaleh / av.getCharHeight()));
+    /*    mouseClick(od, 0, Math.round (ypos * alheight / od.getSequencesHeight()));
         assertEquals(od.getBoxX(), 0);
-        assertEquals(od.getBoxY(), Math.round (ypos / scaleh / av.getCharHeight()),
+        assertEquals(od.getBoxY(), Math.round (ypos * alheight / od.getSequencesHeight()),
                 1.5);
-        assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+        assertEquals(od.getBoxWidth(), boxWidth);
         assertEquals(
                 od.getBoxHeight(),
                 boxHeight
                         + Math.round ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av
-                                .getCharHeight()), 1.5);
+                                .getCharHeight()));
     */
     // 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 / scaleh / av.getCharHeight()));
+    /*mouseClick(od, 0, Math.round (ypos * alheight / od.getSequencesHeight()));
     assertEquals(od.getBoxX(), 0);
-    assertEquals(od.getBoxY(), Math.round (ypos / scaleh / av.getCharHeight()),
+    assertEquals(od.getBoxY(), Math.round (ypos * alheight / od.getSequencesHeight()),
             1.5);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+    assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(
             od.getBoxHeight(),
             boxHeight
                     + Math.round ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av
-                            .getCharHeight()), 1.5);*/
+                            .getCharHeight()));*/
   }
 
   /**
@@ -1036,10 +1060,11 @@ public class OverviewDimensionsTest {
 
     // click above hidden rows
     int ypos = 40; // row 40
-    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(ypos * scaleh * av.getCharHeight()));
+            Math.round((float) ypos * od.getSequencesHeight() / alheight));
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
 
@@ -1054,8 +1079,8 @@ public class OverviewDimensionsTest {
                od.getBoxY(),
                Math.round ((firstHidden - viewHeight) * scaleh * av.getCharHeight()),
                1.5);
-       assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-       assertEquals(od.getBoxHeight(), boxHeight, 1.5);*/
+       assertEquals(od.getBoxWidth(), boxWidth);
+       assertEquals(od.getBoxHeight(), boxHeight);*/
 
     // click within hidden rows
     ypos = 505;
@@ -1066,8 +1091,8 @@ public class OverviewDimensionsTest {
             od.getBoxY(),
             Math.round ((firstHidden - viewHeight) * scaleh * av.getCharHeight()),
             1.5);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);*/
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);*/
   }
 
   /*
@@ -1075,9 +1100,8 @@ public class OverviewDimensionsTest {
    */
   private void moveViewportH(int startRes)
   {
-    int width = av.getEndRes() - av.getStartRes();
     av.setStartRes(startRes);
-    av.setEndRes(startRes + width);
+    av.setEndRes(startRes + viewWidth);
     od.setBoxPosition();
   }
 
@@ -1096,10 +1120,8 @@ public class OverviewDimensionsTest {
    */
   private void moveViewport(int startRes, int startSeq)
   {
-    int width = av.getEndRes() - av.getStartRes();
-
     av.setStartRes(startRes);
-    av.setEndRes(startRes + width);
+    av.setEndRes(startRes + viewWidth);
     av.setStartSeq(startSeq);
     av.setEndSeq(startSeq + viewHeight);
     od.setBoxPosition();
@@ -1114,22 +1136,22 @@ public class OverviewDimensionsTest {
     // updates require an OverviewPanel to exist which it doesn't here
     // so call setBoxPosition() as it would be called by the AlignmentPanel
     // normally
-    int width = av.getEndRes() - av.getStartRes();
-    int height = av.getEndSeq() - av.getStartSeq();
+    // int width = av.getEndRes() - av.getStartRes();
+    // int height = av.getEndSeq() - av.getStartSeq();
     av.setStartRes(od.getScrollCol());
-    av.setEndRes(od.getScrollCol() + width);
+    av.setEndRes(od.getScrollCol() + viewWidth);
     av.setStartSeq(od.getScrollRow());
-    av.setEndSeq(od.getScrollRow() + height);
+    av.setEndSeq(od.getScrollRow() + viewHeight);
     od.setBoxPosition();
   }
   
   private void testBoxIsAtClickPoint(int xpos, int ypos)
   {
     mouseClick(od, xpos, ypos);
-    assertEquals(od.getBoxX(), xpos, 1.5);
-    assertEquals(od.getBoxY(), ypos, 1.5);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+    assertEquals(od.getBoxX(), xpos);
+    assertEquals(od.getBoxY(), ypos);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
 
   }