JAL-2611 First pass, not thrilled with hidden column behaviour
[jalview.git] / src / jalview / viewmodel / OverviewDimensions.java
index dd7eb1e..c63fb3c 100644 (file)
@@ -58,6 +58,10 @@ public abstract class OverviewDimensions
 
   protected int alheight;
 
+  protected int transX;
+
+  protected int transY;
+
   /**
    * Create an OverviewDimensions object
    * 
@@ -191,6 +195,15 @@ public abstract class OverviewDimensions
   public abstract void updateViewportFromMouse(int mousex, int mousey,
           HiddenSequences hiddenSeqs, HiddenColumns hiddenCols);
 
+  public abstract void adjustViewportFromMouse(int mousex, int mousey,
+          HiddenSequences hiddenSeqs, HiddenColumns hiddenCols);
+
+  public abstract void setDragPoint(int x, int y,
+          HiddenSequences hiddenSeqs, HiddenColumns hiddenCols);
+
+  protected abstract void updateViewportFromTopLeft(int mousex, int mousey,
+          HiddenSequences hiddenSeqs, HiddenColumns hiddenCols);
+
   /**
    * Set the overview panel's box position to match the viewport
    * 
@@ -225,8 +238,8 @@ public abstract class OverviewDimensions
    */
   protected abstract void resetAlignmentDims();
 
-  protected void setBoxPosition(int startRes, int endRes, int startSeq,
-          int endSeq)
+  protected void setBoxPosition(int startRes, int startSeq, int vpwidth,
+          int vpheight)
   {
     resetAlignmentDims();
 
@@ -235,12 +248,32 @@ public abstract class OverviewDimensions
     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);
+    boxWidth = Math.round((float) vpwidth * width / alwidth);
+
     // boxHeight is the height in sequences translated to pixels
-    boxHeight = Math.round((float) (endSeq - startSeq + 1)
-            * sequencesHeight / alheight);
+    boxHeight = Math.round((float) vpheight * sequencesHeight / alheight);
+
+    System.out.println("Update box: x: " + boxX);
   }
+
+  /**
+   * Answers if a mouse position is in the overview's red box
+   * 
+   * @param x
+   *          mouse x position
+   * @param y
+   *          mouse y position
+   * @return true if (x,y) is inside the box
+   */
+  public boolean isPositionInBox(int x, int y)
+  {
+    return (x > boxX && y > boxY && x < boxX + boxWidth
+            && y < boxY + boxHeight);
+  }
+
+  protected abstract int getLeftXFromCentreX(int mousex, HiddenColumns hidden);
+
+  protected abstract int getTopYFromCentreY(int mousey,
+          HiddenSequences hidden);
+
 }
\ No newline at end of file