Merge branch 'documentation/JAL-2418_release2102' into develop
[jalview.git] / src / jalview / viewmodel / OverviewDimensions.java
index eb4a6e6..7ac07ac 100644 (file)
@@ -31,24 +31,41 @@ import java.awt.Graphics;
 public abstract class OverviewDimensions
 {
   protected static final int MAX_WIDTH = 400;
+
   protected static final int MIN_WIDTH = 120;
+
   protected static final int MIN_SEQ_HEIGHT = 40;
+
   protected static final int MAX_SEQ_HEIGHT = 300;
 
   private static final int DEFAULT_GRAPH_HEIGHT = 20;
 
   protected int width;
+
   protected int sequencesHeight;
+
   protected int graphHeight = DEFAULT_GRAPH_HEIGHT;
+
   protected int boxX = -1;
+
   protected int boxY = -1;
+
   protected int boxWidth = -1;
+
   protected int boxHeight = -1;
-  protected int scrollCol = -1;
-  protected int scrollRow = -1;
+
   protected int alwidth;
+
   protected int alheight;
 
+  /**
+   * Create an OverviewDimensions object
+   * 
+   * @param ranges
+   *          positional properties of the viewport
+   * @param showAnnotationPanel
+   *          true if the annotation panel is to be shown, false otherwise
+   */
   public OverviewDimensions(ViewportRanges ranges,
           boolean showAnnotationPanel)
   {
@@ -97,16 +114,6 @@ public abstract class OverviewDimensions
     g.drawRect(boxX + 1, boxY + 1, boxWidth - 2, boxHeight - 2);
   }
 
-  public int getScrollCol()
-  {
-    return scrollCol;
-  }
-
-  public int getScrollRow()
-  {
-    return scrollRow;
-  }
-
   public int getBoxX()
   {
     return boxX;
@@ -202,8 +209,7 @@ public abstract class OverviewDimensions
    *          the alignment's hidden columns
    * @return a column collection
    */
-  public abstract AlignmentColsCollectionI getColumns(
-          HiddenColumns hiddenCols);
+  public abstract AlignmentColsCollectionI getColumns(AlignmentI al);
 
   /**
    * Get the collection of rows used by this overview dimensions object
@@ -218,4 +224,21 @@ public abstract class OverviewDimensions
    * Updates overview dimensions to account for current alignment dimensions
    */
   protected abstract void resetAlignmentDims();
+
+  protected void setBoxPosition(int startRes, int startSeq, int vpwidth,
+          int vpheight)
+  {
+    resetAlignmentDims();
+
+    // boxX, boxY is the x,y location equivalent to startRes, startSeq
+    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
+    boxWidth = Math.round((float) vpwidth * width / alwidth);
+
+    // boxHeight is the height in sequences translated to pixels
+    boxHeight = Math.round((float) vpheight * sequencesHeight / alheight);
+  }
 }
\ No newline at end of file