JAL-2388 Corrected overview panel behaviour, updated tests
[jalview.git] / test / jalview / viewmodel / OverviewDimensionsTest.java
index a9770bd..d470c35 100644 (file)
@@ -22,9 +22,11 @@ package jalview.viewmodel;
 
 import static org.testng.Assert.assertEquals;
 
+import jalview.analysis.AlignmentGenerator;
 import jalview.bin.Cache;
 import jalview.bin.Jalview;
 import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
@@ -38,14 +40,14 @@ import jalview.io.FileLoader;
 import java.util.List;
 
 import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+@Test(singleThreaded = true)
 public class OverviewDimensionsTest {
 
-  boolean showConservationSetting;
-
   SequenceI seq1 = new Sequence(
           "Seq1",
           "ABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBACABCABCABCABCABCABCABCABCBACBACBACBAC");
@@ -68,23 +70,29 @@ public class OverviewDimensionsTest {
 
   AlignFrame af;
   AlignViewport av;
+
+  AlignmentI al;
   OverviewDimensions od;
 
-  float scalew;
-  float scaleh;
   int boxWidth;
   int boxHeight;
-
   int viewHeight;
+  int viewWidth;
+  int alheight;
+  int alwidth;
 
   @BeforeClass(alwaysRun = true)
   public void setUpJvOptionPane()
   {
     JvOptionPane.setInteractiveMode(false);
     JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+
+    // create random alignment
+    AlignmentGenerator gen = new AlignmentGenerator(false);
+    al = gen.generate(157, 525, 123, 5, 5);
   }
 
-  @BeforeClass(alwaysRun = true)
+  @BeforeMethod(alwaysRun = true)
   public void setUp()
   {
     Jalview.main(new String[] { "-nonews", "-props",
@@ -92,16 +100,15 @@ public class OverviewDimensionsTest {
 
     Cache.applicationProperties.setProperty("SHOW_IDENTITY",
             Boolean.TRUE.toString());
-    af = new FileLoader().LoadFileWaitTillLoaded(
-            "examples/testdata/bigal.fa",
-            DataSourceType.FILE);
+    af = new FileLoader().LoadFileWaitTillLoaded(al.toString(),
+            DataSourceType.PASTE);
 
     /*
-     * Wait for viewport to initialise
+     * wait for Consensus thread to complete
      */
     synchronized (this)
     {
-      while (af.getViewport().getEndRes() == 0)
+      while (af.getViewport().getConsensusSeq() == null)
       {
         try
         {
@@ -111,30 +118,29 @@ public class OverviewDimensionsTest {
         }
       }
     }
-
-    // get cached setting for showConservation
-    // reset it in AfterClass!
-    showConservationSetting = Cache.getDefault("SHOW_CONSERVATION", true);
     
     av = af.getViewport();
-    od = new OverviewDimensions(av);
+
+    od = new OverviewDimensions(av, true);
+
+    while (av.isCalcInProgress())
+    {
+      try
+      {
+        Thread.sleep(50);
+      } catch (InterruptedException e)
+      {
+
+      }
+    }
 
     // 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 = (int) ((av.getEndRes() - av.getStartRes() + 1)
-            * av.getCharWidth() * scalew);
-    boxHeight = (int) ((av.getEndSeq() - av.getStartSeq())
-            * av.getCharHeight() * scaleh);
 
-    viewHeight = av.getEndSeq() - av.getStartSeq();
+    init();
   }
 
-  @BeforeMethod(alwaysRun = true)
-  public void init()
+  private void init()
   {
     av.showAllHiddenColumns();
     av.showAllHiddenSeqs();
@@ -142,18 +148,64 @@ public class OverviewDimensionsTest {
     // o/w hidden seqs retain selection group, causes problems later when hiding
     // sequences
 
+    // wait for conservation calc to complete again
+    while (av.isCalcInProgress())
+    {
+      try
+      {
+        Thread.sleep(50);
+      } catch (InterruptedException e)
+      {
+
+      }
+    }
+
     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 != 62)
+    {
+      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);
+
   }
 
-  @AfterClass(alwaysRun = true)
+  @AfterMethod(alwaysRun = true)
   public void tearDown()
   {
-    Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
-            Boolean.toString(showConservationSetting));
+    af = null;
+    av = null;
     Desktop.instance.closeAll_actionPerformed(null);
   }
 
+  @AfterClass(alwaysRun = true)
+  public void cleanUp()
+  {
+    al = null;
+  }
+
   /**
    * Test that the OverviewDimensions constructor sets width and height
    * correctly
@@ -174,16 +226,13 @@ public class OverviewDimensionsTest {
     int maxSeqHeight = 300;
     int minSeqHeight = 40;
 
-    Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
-            Boolean.toString(true));
-
     // test for alignment with width > height
     SequenceI[] seqs1 = new SequenceI[] { seqa, seqb };
     Alignment al1 = new Alignment(seqs1);
     al1.setDataset(null);
     AlignViewport av1 = new AlignViewport(al1);
 
-    OverviewDimensions od = new OverviewDimensions(av1);
+    OverviewDimensions od = new OverviewDimensions(av1, true);
     int scaledHeight = 266;
     assertEquals(od.getGraphHeight(), defaultGraphHeight);
     assertEquals(od.getSequencesHeight(), scaledHeight);
@@ -196,7 +245,7 @@ public class OverviewDimensionsTest {
     al2.setDataset(null);
     AlignViewport av2 = new AlignViewport(al2);
 
-    od = new OverviewDimensions(av2);
+    od = new OverviewDimensions(av2, true);
     int scaledWidth = 300;
     assertEquals(od.getGraphHeight(), defaultGraphHeight);
     assertEquals(od.getSequencesHeight(), maxSeqHeight);
@@ -210,7 +259,7 @@ public class OverviewDimensionsTest {
     al3.setDataset(null);
     AlignViewport av3 = new AlignViewport(al3);
 
-    od = new OverviewDimensions(av3);
+    od = new OverviewDimensions(av3, true);
     assertEquals(od.getGraphHeight(), defaultGraphHeight);
     assertEquals(od.getSequencesHeight(), minSeqHeight);
     assertEquals(od.getWidth(), maxWidth);
@@ -223,21 +272,17 @@ public class OverviewDimensionsTest {
     al4.setDataset(null);
     AlignViewport av4 = new AlignViewport(al4);
 
-    od = new OverviewDimensions(av4);
+    od = new OverviewDimensions(av4, true);
     assertEquals(od.getGraphHeight(), defaultGraphHeight);
     assertEquals(od.getSequencesHeight(), maxSeqHeight);
     assertEquals(od.getWidth(), minWidth);
     assertEquals(od.getHeight(), maxSeqHeight + defaultGraphHeight);
 
-    // test for alignment where no conservation annotation is shown
-    Cache.applicationProperties.setProperty("SHOW_CONSERVATION",
-            Boolean.toString(false));
-
     Alignment al5 = new Alignment(seqs4);
     al5.setDataset(null);
     AlignViewport av5 = new AlignViewport(al5);
 
-    od = new OverviewDimensions(av5);
+    od = new OverviewDimensions(av5, false);
     assertEquals(od.getGraphHeight(), 0);
     assertEquals(od.getSequencesHeight(), maxSeqHeight);
     assertEquals(od.getWidth(), minWidth);
@@ -257,7 +302,7 @@ public class OverviewDimensionsTest {
   @Test(groups = { "Functional" })
   public void testSetBoxFromMouseClick()
   {
-    od.checkValid();
+    od.updateViewportFromMouse(0, 0);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -270,7 +315,7 @@ public class OverviewDimensionsTest {
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollRow(),
-            (int) (10 / scaleh / av.getCharHeight()));
+            Math.round((float) 10 * alheight / od.getSequencesHeight()));
     assertEquals(od.getScrollCol(), 0);
 
     // negative boxY value reset to 0
@@ -278,41 +323,44 @@ public class OverviewDimensionsTest {
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
-    assertEquals(od.getScrollCol(), (int) (6 / scalew / av.getCharWidth()));
+    assertEquals(od.getScrollCol(),
+            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);
@@ -321,14 +369,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);
@@ -337,7 +386,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);
   }
 
   /**
@@ -347,7 +396,7 @@ public class OverviewDimensionsTest {
   @Test(groups = { "Functional" })
   public void testFromMouseWithHiddenColsAtStart()
   {
-    od.checkValid();
+    od.updateViewportFromMouse(0, 0);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -357,32 +406,34 @@ public class OverviewDimensionsTest {
     // hide cols at start and check updated box position is correct
     // changes boxX but not boxwidth
     int lastHiddenCol = 30;
-    av.hideColumns(0, lastHiddenCol);
+    hideColumns(0, lastHiddenCol);
+
     od.setBoxPosition();
     assertEquals(od.getBoxX(),
-            (int) ((lastHiddenCol + 1) * scalew * av.getCharWidth()));
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+            Math.round((float) (lastHiddenCol + 1) * od.getWidth()
+                    / alwidth));
+    assertEquals(od.getBoxWidth(), boxWidth);
+    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(od.getBoxX(),
-                (int) ((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(),
-                (int) (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(),
- (int) (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
@@ -390,16 +441,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.getBoxY(), 5, 1.5);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
+    assertEquals(od.getBoxY(), 5);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            (int) (od.getBoxX() / scalew / av.getCharWidth())
-                    - lastHiddenCol, 1.5);
+            Math.round((float) od.getBoxX() * alwidth / od.getWidth())
+                    - (lastHiddenCol + 1));
     assertEquals(od.getScrollRow(),
-            (int) (od.getBoxY() / scaleh / av.getCharHeight()), 1.5);
-
+            Math.round((float) od.getBoxY() * alheight
+                    / od.getSequencesHeight()));
   }
 
   /**
@@ -409,7 +460,7 @@ public class OverviewDimensionsTest {
   @Test(groups = { "Functional" })
   public void testFromMouseWithHiddenColsInMiddle()
   {
-    od.checkValid();
+    od.updateViewportFromMouse(0, 0);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -417,42 +468,46 @@ public class OverviewDimensionsTest {
     assertEquals(od.getScrollRow(), 0);
     
     // hide columns 60-68, no change to box position or dimensions
-    int firstHidden = 60;
-    int lastHidden = 68;
-    av.hideColumns(firstHidden, lastHidden);
+    int firstHidden = 63;
+    int lastHidden = 73;
+    hideColumns(firstHidden, lastHidden);
+
     od.setBoxPosition();
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     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
-                              // 60 and 70
+    int xpos = 55 - boxWidth; // 55 is position in overview approx halfway
+                              // between cols 60 and 70
     mouseClick(od, xpos, 0);
-    assertEquals(od.getBoxX(), xpos, 1.5);
+    assertEquals(od.getBoxX(), xpos);
     assertEquals(od.getBoxY(), 0);
-    assertEquals(od.getBoxWidth(), boxWidth
-            + (lastHidden - firstHidden + 1) * scalew * av.getCharWidth(),
-            1.5);
+    assertEquals(
+            od.getBoxWidth(),
+            Math.round(boxWidth + (float) (lastHidden - firstHidden + 1)
+                    * od.getWidth() / alwidth));
     assertEquals(od.getBoxHeight(), boxHeight);
-    assertEquals(od.getScrollCol(), (int) (xpos / scalew / av.getCharWidth()), 1.5);
+    assertEquals(od.getScrollCol(),
+            Math.round(xpos * alwidth / od.getWidth()));
     assertEquals(od.getScrollRow(), 0);
 
     // move box so that it completely covers hidden cols
     // box width changes, boxX and scrollCol as for hidden case
-    xpos = 30;
+    xpos = 33;
     mouseClick(od, xpos, 0);
-    assertEquals(od.getBoxX(), xpos, 1.5);
+    assertEquals(od.getBoxX(), xpos);
     assertEquals(od.getBoxY(), 0);
-    assertEquals(od.getBoxWidth(), boxWidth
-            + (lastHidden - firstHidden + 1) * scalew * av.getCharWidth(),
-            1.5);
+    assertEquals(
+            od.getBoxWidth(),
+            Math.round(boxWidth + (float) (lastHidden - firstHidden + 1)
+                    * od.getWidth() / alwidth));
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            (int) (xpos / scalew / av.getCharWidth()), 1.5);
+            Math.round((float) xpos * alwidth / od.getWidth()));
     assertEquals(od.getScrollRow(), 0);
 
     // move box so boxX is in hidden cols, box overhangs at right
@@ -462,12 +517,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(),
-                (int) (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
@@ -483,23 +538,23 @@ public class OverviewDimensionsTest {
        testBoxIsAtClickPoint(xpos, 0);
        assertEquals(od.getScrollRow(), 0);
        assertEquals(od.getScrollCol(),
-               (int) (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.getBoxY(), 5, 1.5);
+    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
+    assertEquals(od.getBoxY(), 5);
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            (od.getBoxX() / scalew / av.getCharWidth())
-                    - (lastHidden - firstHidden + 1),
-            1.5);
+            Math.round(((float) od.getBoxX() * alwidth / od.getWidth())
+                    - (lastHidden - firstHidden + 1)));
     assertEquals(od.getScrollRow(),
-            (int) (od.getBoxY() / scaleh / av.getCharHeight()), 1.5);
+            Math.round((float) od.getBoxY() * alheight
+                    / od.getSequencesHeight()));
 
   }
 
@@ -510,7 +565,7 @@ public class OverviewDimensionsTest {
   @Test(groups = { "Functional" })
   public void testFromMouseWithHiddenColsAtEnd()
   {
-    od.checkValid();
+    od.updateViewportFromMouse(0, 0);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -520,7 +575,7 @@ public class OverviewDimensionsTest {
     // hide columns 140-157, no change to box position or dimensions
     int firstHidden = 140;
     int lastHidden = 157;
-    av.hideColumns(firstHidden, lastHidden);
+    hideColumns(firstHidden, lastHidden);
     od.setBoxPosition();
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
@@ -534,7 +589,7 @@ public class OverviewDimensionsTest {
     testBoxIsAtClickPoint(xpos, 0);
     assertEquals(od.getScrollRow(), 0);
     assertEquals(od.getScrollCol(),
-            (int) (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
@@ -544,13 +599,13 @@ public class OverviewDimensionsTest {
     mouseClick(od, xpos, 0);
     assertEquals(
             od.getBoxX(),
-            (int) ((firstHidden - 1) * scalew * av.getCharWidth())
-                    - od.getBoxWidth(), 1.5);
+            Math.round((firstHidden - 1) * scalew * av.getCharWidth())
+                    - od.getBoxWidth());
     assertEquals(od.getBoxY(), 0);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+    assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            (int) (od.getBoxX() / scalew / av.getCharWidth()), 1.5);
+            Math.round(od.getBoxX() * alwidth / od.getWidth()));
     assertEquals(od.getScrollRow(), 0);*/
 
     // click in hidden cols
@@ -559,13 +614,13 @@ public class OverviewDimensionsTest {
     /*xpos = 115;
     assertEquals(
             od.getBoxX(),
-            (int) ((firstHidden - 1) * scalew * av.getCharWidth())
-                    - od.getBoxWidth(), 1.5);
+            Math.round((firstHidden - 1) * scalew * av.getCharWidth())
+                    - od.getBoxWidth());
     assertEquals(od.getBoxY(), 0);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+    assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(),
-            (int) (od.getBoxX() / scalew / av.getCharWidth()), 1.5);
+            Math.round(od.getBoxX() * alwidth / od.getWidth()));
     assertEquals(od.getScrollRow(), 0);*/
 
     // click off end of alignment
@@ -574,13 +629,13 @@ public class OverviewDimensionsTest {
     /*    xpos = 3000;
         assertEquals(
                 od.getBoxX(),
-                (int) ((firstHidden - 1) * scalew * av.getCharWidth())
-                        - od.getBoxWidth(), 1.5);
+                Math.round((firstHidden - 1) * scalew * av.getCharWidth())
+                        - od.getBoxWidth());
         assertEquals(od.getBoxY(), 0);
-        assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+        assertEquals(od.getBoxWidth(), boxWidth);
         assertEquals(od.getBoxHeight(), boxHeight);
         assertEquals(od.getScrollCol(),
-                (int) (od.getBoxX() / scalew / av.getCharWidth()), 1.5);
+                Math.round(od.getBoxX() * alwidth / od.getWidth()));
         assertEquals(od.getScrollRow(), 0);*/
   }
 
@@ -595,29 +650,34 @@ 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 right
     moveViewportH(70);
-    assertEquals(od.getBoxX(), (int) (70 * scalew * av.getCharWidth()));
+    assertEquals(od.getBoxX(),
+            Math.round((float) 70 * od.getWidth() / alwidth));
     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 down
     moveViewportV(100);
-    assertEquals(od.getBoxX(), (int) (70 * scalew * av.getCharWidth()));
-    assertEquals(od.getBoxY(), (int) (100 * scaleh * av.getCharHeight()));
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+    assertEquals(od.getBoxX(),
+            Math.round((float) 70 * od.getWidth() / alwidth));
+    assertEquals(od.getBoxY(),
+            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(), (int) (98 * scalew * av.getCharWidth()));
-    assertEquals(od.getBoxY(), (int) (508 * scaleh * av.getCharHeight()));
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+    assertEquals(od.getBoxX(),
+            Math.round((float) 98 * od.getWidth() / alwidth));
+    assertEquals(od.getBoxY(),
+            Math.round((float) 508 * od.getSequencesHeight() / alheight));
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
   }
 
   /**
@@ -629,23 +689,24 @@ public class OverviewDimensionsTest {
   {
     int firstHidden = 0;
     int lastHidden = 20;
-    av.hideColumns(firstHidden, lastHidden);
+    hideColumns(firstHidden, lastHidden);
 
     // move viewport to start of alignment
     moveViewport(0, 0);
     assertEquals(od.getBoxX(),
-            (int) ((lastHidden + 1) * scalew * av.getCharWidth()));
+            Math.round((float) (lastHidden + 1) * od.getWidth() / alwidth));
     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 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(), 98 * scalew * av.getCharWidth(), 1.5);
+    assertEquals(od.getBoxX(),
+            Math.round((float) 98 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
   }
 
   /**
@@ -655,45 +716,52 @@ public class OverviewDimensionsTest {
   @Test(groups = { "Functional" })
   public void testSetBoxFromViewportHiddenColsInMiddle()
   {
-    int firstHidden = 65;
-    int lastHidden = 75;
-    av.hideColumns(firstHidden, lastHidden);
+    int firstHidden = 68;
+    int lastHidden = 78;
+    hideColumns(firstHidden, lastHidden);
 
     // move viewport before hidden columns
     moveViewport(3, 0);
-    assertEquals(od.getBoxX(), (int) (3 * scalew * av.getCharWidth()));
+
+    assertEquals(od.getBoxX(),
+            Math.round((float) 3 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+    System.out.println(od.getBoxWidth());
+    assertEquals(od.getBoxWidth(), boxWidth);
+    System.out.println(od.getBoxWidth());
+    assertEquals(od.getBoxHeight(), boxHeight);
 
     // move viewport to left of hidden columns with overlap
     moveViewport(10, 0);
-    assertEquals(od.getBoxX(), (int) (10 * scalew * av.getCharWidth()));
+    assertEquals(od.getBoxX(),
+            Math.round((float) 10 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
     assertEquals(
             od.getBoxWidth(),
             boxWidth
-                    + (int) ((lastHidden - firstHidden + 1) * scalew * av
-                            .getCharWidth()), 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+                    + 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(), (int) (60 * scalew * av.getCharWidth()));
+    moveViewport(63, 0);
+    assertEquals(od.getBoxX(),
+            Math.round((float) 63 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
     assertEquals(
             od.getBoxWidth(),
             boxWidth
-                    + (int) ((lastHidden - firstHidden + 1) * scalew * av
-                            .getCharWidth()), 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+                    + 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(), (int) (80 * scalew * av.getCharWidth()), 1.5);
+    assertEquals(od.getBoxX(),
+            Math.round((float) 80 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
 
   }
 
@@ -704,28 +772,28 @@ public class OverviewDimensionsTest {
   @Test(groups = { "Functional" })
   public void testSetBoxFromViewportHiddenColsAtEnd()
   {
-    int firstHidden = 145;
-    int lastHidden = 157;
-    av.hideColumns(firstHidden, lastHidden);
+    int firstHidden = 152;
+    int lastHidden = 164;
+    hideColumns(firstHidden, lastHidden);
 
     // move viewport before hidden columns
     moveViewport(3, 0);
-    assertEquals(od.getBoxX(), (int) (3 * scalew * av.getCharWidth()), 1.5);
+    assertEquals(od.getBoxX(),
+            Math.round((float) 3 * od.getWidth() / alwidth));
     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 hidden columns
     // TODO boxwidth includes hidden in overview panel (why?)
-    moveViewport(98, 0);
-    assertEquals(od.getBoxX(), (int) (98 * scalew * av.getCharWidth()), 1.5);
+    moveViewport(102, 0);
+    assertEquals(od.getBoxX(),
+            Math.round((float) 102 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
-    assertEquals(
-            od.getBoxWidth(),
-            boxWidth
-                    + (int) ((lastHidden - firstHidden + 1) * scalew * av
-                            .getCharWidth()), 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+    assertEquals(od.getBoxWidth(), boxWidth
+                    + Math.round((float) (lastHidden - firstHidden)
+                            * od.getWidth() / alwidth));
+    assertEquals(od.getBoxHeight(), boxHeight);
   }
 
   /**
@@ -744,9 +812,10 @@ public class OverviewDimensionsTest {
     moveViewport(0, 0);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(),
-            (lastHidden + 1) * scaleh * av.getCharHeight(), 1.5);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+            Math.round((float) (lastHidden + 1) * od.getSequencesHeight()
+                    / alheight));
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
 
     // move viewport to end of alignment, need to account for hidden rows
     // because of how alignment panel/overview panel are implemented
@@ -761,9 +830,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);*/
   }
 
   /**
@@ -783,16 +852,16 @@ 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
     /*moveViewport(0, 198);
     assertEquals(od.getBoxX(), 0);
-    assertEquals(od.getBoxY(), (int) (198 * scaleh * av.getCharHeight()),
+    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);*/
@@ -814,22 +883,22 @@ 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 end of alignment
     // TODO fails with wrong boxHeight who knows why
     /*moveViewport(0, firstHidden - viewHeight - 1);
         assertEquals(od.getBoxX(), 0);
         assertEquals(od.getBoxY(),
-     (int) ((firstHidden - viewHeight - 1)
-                * scaleh * av.getCharHeight()), 1.5);
-        assertEquals(od.getBoxWidth(), boxWidth, 1.5);
+     Math.round ((firstHidden - viewHeight - 1)
+                * scaleh * av.getCharHeight()));
+        assertEquals(od.getBoxWidth(), boxWidth);
         assertEquals(
                 od.getBoxHeight(),
                 boxHeight
-                        + (int) ((lastHidden - firstHidden + 1) * scaleh * av
-                                .getCharHeight()), 1.5);*/
+                        + Math.round ((lastHidden - firstHidden + 1) * scaleh * av
+                                .getCharHeight()));*/
 
   }
 
@@ -840,9 +909,10 @@ public class OverviewDimensionsTest {
   @Test(groups = { "Functional" })
   public void testFromMouseWithHiddenRowsAtStart()
   {
-    od.checkValid();
+    od.updateViewportFromMouse(0, 0);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getBoxWidth(), boxWidth);
     assertEquals(od.getScrollCol(), 0);
     assertEquals(od.getScrollRow(), 0);
@@ -855,26 +925,27 @@ public class OverviewDimensionsTest {
     od.setBoxPosition();
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(),
-            (int) ((lastHiddenRow + 1) * scaleh * av.getCharHeight()));
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+            Math.round((float) (lastHiddenRow + 1)
+                    * od.getSequencesHeight() / alheight));
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
 
     // click in hidden rows
     // TODO fails because boxHeight is 27 not 25 (possible rounding issue)
     /*    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
-                + (int) ((lastHiddenRow + 1) * scaleh * av.getCharHeight()),
+                + Math.round ((lastHiddenRow + 1) * scaleh * av.getCharHeight()),
                 1.5);*/
 
     // click below hidden rows
     mouseClick(od, 0, 150);
     assertEquals(od.getBoxX(), 0);
-    assertEquals(od.getBoxY(), 150, 1.5);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+    assertEquals(od.getBoxY(), 150);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
   }
 
   /**
@@ -884,10 +955,12 @@ public class OverviewDimensionsTest {
   @Test(groups = { "Functional" })
   public void testFromMouseWithHiddenRowsInMiddle()
   {
-    od.checkValid();
+    od.updateViewportFromMouse(0, 0);
+
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(), 0);
     assertEquals(od.getScrollRow(), 0);
 
@@ -898,40 +971,41 @@ public class OverviewDimensionsTest {
     hideSequences(firstHiddenRow, lastHiddenRow + 1, lastHiddenRow + 1);
 
     od.setBoxPosition();
+
     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);
 
     // 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, (int) (ypos / scaleh / av.getCharHeight()));
+    /*    mouseClick(od, 0, Math.round (ypos * alheight / od.getSequencesHeight()));
         assertEquals(od.getBoxX(), 0);
-        assertEquals(od.getBoxY(), (int) (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
-                        + (int) ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av
-                                .getCharHeight()), 1.5);
+                        + Math.round ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av
+                                .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, (int) (ypos / scaleh / av.getCharHeight()));
+    /*mouseClick(od, 0, Math.round (ypos * alheight / od.getSequencesHeight()));
     assertEquals(od.getBoxX(), 0);
-    assertEquals(od.getBoxY(), (int) (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
-                    + (int) ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av
-                            .getCharHeight()), 1.5);*/
+                    + Math.round ((lastHiddenRow - firstHiddenRow + 1) / scaleh / av
+                            .getCharHeight()));*/
   }
 
   /**
@@ -941,10 +1015,11 @@ public class OverviewDimensionsTest {
   @Test(groups = { "Functional" })
   public void testFromMouseWithHiddenRowsAtEnd()
   {
-    od.checkValid();
+    od.updateViewportFromMouse(0, 0);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
     assertEquals(od.getScrollCol(), 0);
     assertEquals(od.getScrollRow(), 0);
 
@@ -957,43 +1032,44 @@ public class OverviewDimensionsTest {
     od.setBoxPosition();
     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);
 
     // click above hidden rows
     int ypos = 40; // row 40
-    mouseClick(od, 0, (int) (ypos * scaleh * av.getCharHeight()));
+    mouseClick(od, 0,
+            Math.round((float) ypos * od.getSequencesHeight() / alheight));
     assertEquals(od.getBoxX(), 0);
-    assertEquals(od.getBoxY(), (int) (ypos * scaleh * av.getCharHeight()),
-            1.5);
-    assertEquals(od.getBoxWidth(), boxWidth, 1.5);
-    assertEquals(od.getBoxHeight(), boxHeight, 1.5);
+    assertEquals(od.getBoxY(),
+            Math.round((float) ypos * od.getSequencesHeight() / alheight));
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
 
     // 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, (int) (ypos * scaleh * av.getCharHeight()));
+       mouseClick(od, 0, Math.round (ypos * scaleh * av.getCharHeight()));
        assertEquals(od.getBoxX(), 0);
        assertEquals(
                od.getBoxY(),
-               (int) ((firstHidden - viewHeight) * scaleh * av.getCharHeight()),
+               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;
     // TODO: fails with wrong boxHeight - correction done by setScrollValues(?)
-    /*mouseClick(od, 0, (int) (ypos * scaleh * av.getCharHeight()));
+    /*mouseClick(od, 0, Math.round (ypos * scaleh * av.getCharHeight()));
     assertEquals(od.getBoxX(), 0);
     assertEquals(
             od.getBoxY(),
-            (int) ((firstHidden - viewHeight) * scaleh * av.getCharHeight()),
+            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);*/
   }
 
   /*
@@ -1001,9 +1077,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();
   }
 
@@ -1022,10 +1097,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();
@@ -1036,28 +1109,26 @@ public class OverviewDimensionsTest {
    */
   private void mouseClick(OverviewDimensions od, int x, int y)
   {
-    od.setBoxX(x);
-    od.setBoxY(y);
-    od.checkValid();
+    od.updateViewportFromMouse(x, y);
     // 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);
 
   }
 
@@ -1079,5 +1150,32 @@ public class OverviewDimensionsTest {
      * hide group
      */
     av.hideSequences(allseqs.get(hideseq), true);
+
+    while (av.isCalcInProgress())
+    {
+      try
+      {
+        Thread.sleep(50);
+      } catch (InterruptedException e)
+      {
+        System.out.println("Hiding seqs interruption");
+      }
+    }
+  }
+
+  private void hideColumns(int firstHidden, int lastHidden)
+  {
+    av.hideColumns(firstHidden, lastHidden);
+
+    while (av.isCalcInProgress())
+    {
+      try
+      {
+        Thread.sleep(50);
+      } catch (InterruptedException e)
+      {
+        System.out.println("Hiding cols interruption");
+      }
+    }
   }
 }