JAL-2778 Reduced calculation load for overview box
[jalview.git] / src / jalview / viewmodel / OverviewDimensions.java
index ee3b511..d7f2e61 100644 (file)
@@ -58,6 +58,10 @@ public abstract class OverviewDimensions
 
   protected int alheight;
 
+  protected float widthRatio;
+
+  protected float heightRatio;
+
   /**
    * Create an OverviewDimensions object
    * 
@@ -272,7 +276,8 @@ public abstract class OverviewDimensions
     resetAlignmentDims();
 
     // boxX, boxY is the x,y location equivalent to startRes, startSeq
-    boxX = Math.round((float) startRes * width / alwidth);
+    int xPos = Math.min(startRes, alwidth - vpwidth + 1);
+    boxX = Math.round((float) xPos * width / alwidth);
     boxY = Math.round((float) startSeq * sequencesHeight / alheight);
 
     // boxWidth is the width in residues translated to pixels
@@ -300,7 +305,8 @@ public abstract class OverviewDimensions
   /*
    * Given the centre x position, calculate the box's left x position
    */
-  protected abstract int getLeftXFromCentreX(int mousex, HiddenColumns hidden);
+  protected abstract int getLeftXFromCentreX(int mousex,
+          HiddenColumns hidden);
 
   /*
    * Given the centre y position, calculate the box's top y position