JAL-2388 Tidies and unit tests
[jalview.git] / src / jalview / viewmodel / OverviewDimensionsHideHidden.java
@@ -8,15 +8,15 @@ import jalview.datamodel.HiddenSequences;
 import jalview.datamodel.VisibleColsCollection;
 import jalview.datamodel.VisibleRowsCollection;
 
-public class OverviewDimensionsAllVisible extends OverviewDimensions
+public class OverviewDimensionsHideHidden extends OverviewDimensions
 {
-  private ViewportRanges alRanges;
+  private ViewportRanges ranges;
 
-  public OverviewDimensionsAllVisible(ViewportRanges ranges,
+  public OverviewDimensionsHideHidden(ViewportRanges vpranges,
           boolean showAnnotationPanel)
   {
-    super(ranges, showAnnotationPanel);
-    alRanges = ranges;
+    super(vpranges, showAnnotationPanel);
+    ranges = vpranges;
     resetAlignmentDims();
   }
 
@@ -51,7 +51,7 @@ public class OverviewDimensionsAllVisible extends OverviewDimensions
     int xAsRes = Math.round((float) x * alwidth / width);
 
     // get viewport width in residues
-    int vpwidth = alRanges.getEndRes() - alRanges.getStartRes() + 1;
+    int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1;
 
     if (xAsRes + vpwidth > alwidth)
     {
@@ -78,7 +78,7 @@ public class OverviewDimensionsAllVisible extends OverviewDimensions
 
     // get viewport height in sequences
     // add 1 because height includes both endSeq and startSeq
-    int vpheight = alRanges.getEndSeq() - alRanges.getStartSeq() + 1;
+    int vpheight = ranges.getEndSeq() - ranges.getStartSeq() + 1;
 
     if (yAsSeq + vpheight > alheight)
     {
@@ -103,49 +103,35 @@ public class OverviewDimensionsAllVisible extends OverviewDimensions
   public void setBoxPosition(HiddenSequences hiddenSeqs,
           HiddenColumns hiddenCols)
   {
-    resetAlignmentDims();
-
     // work with visible values of startRes and endRes
-    int startRes = alRanges.getStartRes();
-    int endRes = alRanges.getEndRes();
+    int startRes = ranges.getStartRes();
+    int endRes = ranges.getEndRes();
 
     // work with visible values of startSeq and endSeq
-    int startSeq = alRanges.getStartSeq();
-    int endSeq = alRanges.getEndSeq();
-
-    // boxX, boxY is the x,y location equivalent to startRes, startSeq
-    boxX = Math.round((float) startRes * width / alwidth);
-    boxY = Math.round((float) startSeq * sequencesHeight / alheight);
-
-    // boxWidth is the width in residues translated to pixels
-    // since the box includes both the start and end residues, add 1 to the
-    // difference
-    boxWidth = Math
-            .round((float) (endRes - startRes + 1) * width / alwidth);
-    // boxHeight is the height in sequences translated to pixels
-    boxHeight = Math.round((float) (endSeq - startSeq + 1)
-            * sequencesHeight / alheight);
+    int startSeq = ranges.getStartSeq();
+    int endSeq = ranges.getEndSeq();
 
+    setBoxPosition(startRes, endRes, startSeq, endSeq);
   }
 
   @Override
-  public AlignmentColsCollectionI getColumns(HiddenColumns hiddenCols)
+  public AlignmentColsCollectionI getColumns(AlignmentI al)
   {
     return new VisibleColsCollection(0,
-            alRanges.getAbsoluteAlignmentWidth() - 1, hiddenCols);
+            ranges.getAbsoluteAlignmentWidth() - 1, al);
   }
 
   @Override
   public AlignmentRowsCollectionI getRows(AlignmentI al)
   {
     return new VisibleRowsCollection(0,
-            alRanges.getAbsoluteAlignmentHeight() - 1, al);
+            ranges.getAbsoluteAlignmentHeight() - 1, al);
   }
 
   @Override
   protected void resetAlignmentDims()
   {
-    alwidth = alRanges.getVisibleAlignmentWidth();
-    alheight = alRanges.getVisibleAlignmentHeight();
+    alwidth = ranges.getVisibleAlignmentWidth();
+    alheight = ranges.getVisibleAlignmentHeight();
   }
 }