Merge remote-tracking branch
authorkiramt <k.mourao@dundee.ac.uk>
Fri, 5 May 2017 11:05:50 +0000 (12:05 +0100)
committerkiramt <k.mourao@dundee.ac.uk>
Fri, 5 May 2017 11:05:50 +0000 (12:05 +0100)
'origin/features/JAL-2388hiddencolumnschanges' into
features/JAL-2388OverviewWindow

Conflicts:
resources/lang/Messages.properties

55 files changed:
resources/lang/Messages.properties
resources/lang/Messages_es.properties
src/jalview/api/AlignmentColsCollectionI.java [new file with mode: 0644]
src/jalview/api/AlignmentRowsCollectionI.java [new file with mode: 0644]
src/jalview/appletgui/AlignFrame.java
src/jalview/appletgui/AlignViewport.java
src/jalview/appletgui/AnnotationColumnChooser.java
src/jalview/appletgui/AnnotationLabels.java
src/jalview/appletgui/OverviewCanvas.java [new file with mode: 0644]
src/jalview/appletgui/OverviewPanel.java
src/jalview/appletgui/ScalePanel.java
src/jalview/appletgui/SeqCanvas.java
src/jalview/appletgui/SeqPanel.java
src/jalview/datamodel/AllColsCollection.java [new file with mode: 0644]
src/jalview/datamodel/AllColsIterator.java [new file with mode: 0644]
src/jalview/datamodel/AllRowsCollection.java [new file with mode: 0644]
src/jalview/datamodel/AllRowsIterator.java [new file with mode: 0644]
src/jalview/datamodel/CigarArray.java
src/jalview/datamodel/HiddenColumns.java
src/jalview/datamodel/HiddenSequences.java
src/jalview/datamodel/VisibleColsCollection.java [new file with mode: 0644]
src/jalview/datamodel/VisibleColsIterator.java [new file with mode: 0644]
src/jalview/datamodel/VisibleRowsCollection.java [new file with mode: 0644]
src/jalview/datamodel/VisibleRowsIterator.java [new file with mode: 0644]
src/jalview/gui/AlignFrame.java
src/jalview/gui/AlignViewport.java
src/jalview/gui/AnnotationColumnChooser.java
src/jalview/gui/AnnotationLabels.java
src/jalview/gui/Jalview2XML.java
src/jalview/gui/OverviewCanvas.java [new file with mode: 0644]
src/jalview/gui/OverviewPanel.java
src/jalview/gui/ScalePanel.java
src/jalview/gui/SeqCanvas.java
src/jalview/gui/SeqPanel.java
src/jalview/gui/SequenceRenderer.java
src/jalview/io/AnnotationFile.java
src/jalview/io/JSONFile.java
src/jalview/renderer/OverviewRenderer.java [new file with mode: 0644]
src/jalview/util/MappingUtils.java
src/jalview/viewmodel/AlignmentViewport.java
src/jalview/viewmodel/OverviewDimensions.java
src/jalview/viewmodel/OverviewDimensionsHideHidden.java [new file with mode: 0644]
src/jalview/viewmodel/OverviewDimensionsShowHidden.java [new file with mode: 0644]
src/jalview/viewmodel/ViewportRanges.java
test/jalview/datamodel/AllColsIteratorTest.java [new file with mode: 0644]
test/jalview/datamodel/AllRowsIteratorTest.java [new file with mode: 0644]
test/jalview/datamodel/ColumnSelectionTest.java
test/jalview/datamodel/HiddenColumnsTest.java
test/jalview/datamodel/VisibleColsIteratorTest.java [new file with mode: 0644]
test/jalview/datamodel/VisibleRowsIteratorTest.java [new file with mode: 0644]
test/jalview/gui/AlignFrameTest.java
test/jalview/io/JSONFileTest.java
test/jalview/util/MappingUtilsTest.java
test/jalview/viewmodel/OverviewDimensionsHideHiddenTest.java [new file with mode: 0644]
test/jalview/viewmodel/OverviewDimensionsShowHiddenTest.java [moved from test/jalview/viewmodel/OverviewDimensionsTest.java with 95% similarity]

index e63752d..91295e8 100644 (file)
@@ -1302,9 +1302,10 @@ warn.name_cannot_be_duplicate = User-defined URL names must be unique and cannot
 label.invalid_name = Invalid Name !
 label.output_seq_details = Output Sequence Details to list all database references
 label.urllinks = Links
+label.togglehidden = Toggle hidden regions on/off
 label.quality_descr = Alignment Quality based on Blosum62 scores
 label.conservation_descr = Conservation of total alignment less than {0}% gaps
 label.consensus_descr = PID
 label.complement_consensus_descr = PID for cDNA
 label.strucconsensus_descr = PID for base pairs
-label.occupancy_descr = Number of aligned positions 
\ No newline at end of file
+label.occupancy_descr = Number of aligned positions 
index 6ddbb44..02bfbe7 100644 (file)
@@ -1301,3 +1301,4 @@ warn.name_cannot_be_duplicate = Los nombres URL definidos por el usuario deben s
 label.invalid_name = Nombre inválido !
 label.output_seq_details = Seleccionar Detalles de la secuencia para ver todas
 label.urllinks = Enlaces
+label.togglehidden = Toggle hidden regions on/off
\ No newline at end of file
diff --git a/src/jalview/api/AlignmentColsCollectionI.java b/src/jalview/api/AlignmentColsCollectionI.java
new file mode 100644 (file)
index 0000000..603da98
--- /dev/null
@@ -0,0 +1,13 @@
+package jalview.api;
+
+public interface AlignmentColsCollectionI extends Iterable<Integer>
+{
+  /**
+   * Answers if the column at the given position is hidden.
+   * 
+   * @param c
+   *          the column index to check
+   * @return true if the column at the position is hidden
+   */
+  public boolean isHidden(int c);
+}
diff --git a/src/jalview/api/AlignmentRowsCollectionI.java b/src/jalview/api/AlignmentRowsCollectionI.java
new file mode 100644 (file)
index 0000000..09b039d
--- /dev/null
@@ -0,0 +1,24 @@
+package jalview.api;
+
+import jalview.datamodel.SequenceI;
+
+public interface AlignmentRowsCollectionI extends Iterable<Integer>
+{
+  /**
+   * Answers if the sequence at the given position is hidden.
+   * 
+   * @param r
+   *          the row index to check
+   * @return true if the sequence at r is hidden
+   */
+  public boolean isHidden(int r);
+
+  /**
+   * Answers the sequence at the given position in the alignment
+   * 
+   * @param r
+   *          the row index to locate
+   * @return the sequence
+   */
+  public SequenceI getSequence(int r);
+}
index 23b8843..f914108 100644 (file)
@@ -1929,7 +1929,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
       copiedHiddenColumns = new Vector();
       int hiddenOffset = viewport.getSelectionGroup().getStartRes();
       for (int[] region : viewport.getAlignment().getHiddenColumns()
-              .getListOfCols())
+              .getHiddenRegions())
       {
         copiedHiddenColumns.addElement(new int[] {
             region[0] - hiddenOffset, region[1] - hiddenOffset });
index c156c36..5435d81 100644 (file)
@@ -40,7 +40,6 @@ import jalview.structure.SelectionSource;
 import jalview.structure.StructureSelectionManager;
 import jalview.structure.VamsasSource;
 import jalview.viewmodel.AlignmentViewport;
-import jalview.viewmodel.ViewportRanges;
 
 import java.awt.Font;
 
@@ -72,11 +71,10 @@ public class AlignViewport extends AlignmentViewport implements
 
   public AlignViewport(AlignmentI al, JalviewLite applet)
   {
-    super();
+    super(al);
     calculator = new jalview.workers.AlignCalcManager();
     this.applet = applet;
-    alignment = al;
-    ranges = new ViewportRanges(this.alignment);
+
     // we always pad gaps
     this.setPadGaps(true);
 
index cc16275..60775d3 100644 (file)
@@ -298,10 +298,10 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
         HiddenColumns oldHidden = av
                 .getAnnotationColumnSelectionState()
                 .getOldHiddenColumns();
-        if (oldHidden != null && oldHidden.getListOfCols() != null
-                && !oldHidden.getListOfCols().isEmpty())
+        if (oldHidden != null && oldHidden.getHiddenRegions() != null
+                && !oldHidden.getHiddenRegions().isEmpty())
         {
-          for (Iterator<int[]> itr = oldHidden.getListOfCols()
+          for (Iterator<int[]> itr = oldHidden.getHiddenRegions()
                   .iterator(); itr.hasNext();)
           {
             int positions[] = itr.next();
index 9444a76..307301d 100755 (executable)
@@ -840,7 +840,7 @@ public class AnnotationLabels extends Panel implements ActionListener,
     {
       jalview.appletgui.AlignFrame.copiedHiddenColumns = new Vector();
       for (int[] region : av.getAlignment().getHiddenColumns()
-              .getListOfCols())
+              .getHiddenRegions())
       {
         jalview.appletgui.AlignFrame.copiedHiddenColumns
                 .addElement(new int[] { region[0], region[1] });
diff --git a/src/jalview/appletgui/OverviewCanvas.java b/src/jalview/appletgui/OverviewCanvas.java
new file mode 100644 (file)
index 0000000..23e82df
--- /dev/null
@@ -0,0 +1,167 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.appletgui;
+
+import jalview.renderer.OverviewRenderer;
+import jalview.viewmodel.OverviewDimensions;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Image;
+
+public class OverviewCanvas extends Component
+{
+  // This is set true if the alignment view changes whilst
+  // the overview is being calculated
+  private volatile boolean restart = false;
+
+  private volatile boolean updaterunning = false;
+
+  private OverviewDimensions od;
+
+  private Image miniMe;
+
+  private Image offscreen;
+
+  private AlignViewport av;
+
+  // Can set different properties in this seqCanvas than
+  // main visible SeqCanvas
+  private SequenceRenderer sr;
+
+  private jalview.renderer.seqfeatures.FeatureRenderer fr;
+
+  private Frame nullFrame;
+
+  public OverviewCanvas(OverviewDimensions overviewDims,
+          AlignViewport alignvp)
+  {
+    od = overviewDims;
+    av = alignvp;
+
+    nullFrame = new Frame();
+    nullFrame.addNotify();
+
+    sr = new SequenceRenderer(av);
+    sr.graphics = nullFrame.getGraphics();
+    sr.renderGaps = false;
+    sr.forOverview = true;
+    fr = new jalview.renderer.seqfeatures.FeatureRenderer(av);
+  }
+
+  /**
+   * Update the overview dimensions object used by the canvas (e.g. if we change
+   * from showing hidden columns to hiding them or vice versa)
+   * 
+   * @param overviewDims
+   */
+  public void resetOviewDims(OverviewDimensions overviewDims)
+  {
+    od = overviewDims;
+  }
+
+  /**
+   * Signals to drawing code that the associated alignment viewport has changed
+   * and a redraw will be required
+   */
+  public boolean restartDraw()
+  {
+    synchronized (this)
+    {
+      if (updaterunning)
+      {
+        restart = true;
+      }
+      else
+      {
+        updaterunning = true;
+      }
+      return restart;
+    }
+  }
+
+  public void draw(boolean showSequenceFeatures, boolean showAnnotation,
+          FeatureRenderer transferRenderer)
+  {
+    miniMe = null;
+
+    if (showSequenceFeatures)
+    {
+      fr.transferSettings(transferRenderer);
+    }
+
+    setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
+
+    OverviewRenderer or = new OverviewRenderer(sr, fr, od);
+    miniMe = nullFrame.createImage(od.getWidth(), od.getHeight());
+    offscreen = nullFrame.createImage(od.getWidth(), od.getHeight());
+
+    miniMe = or.draw(od.getRows(av.getAlignment()),
+            od.getColumns(av.getAlignment()));
+
+    Graphics mg = miniMe.getGraphics();
+
+    // checks for conservation annotation to make sure overview works for DNA
+    // too
+    if (showAnnotation)
+    {
+      mg.translate(0, od.getSequencesHeight());
+      or.drawGraph(mg, av.getAlignmentConservationAnnotation(),
+              av.getCharWidth(), od.getGraphHeight(),
+              od.getColumns(av.getAlignment()));
+      mg.translate(0, -od.getSequencesHeight());
+    }
+    System.gc();
+
+    if (restart)
+    {
+      restart = false;
+      draw(showSequenceFeatures, showAnnotation, transferRenderer);
+    }
+    else
+    {
+      updaterunning = false;
+    }
+  }
+
+  @Override
+  public void update(Graphics g)
+  {
+    paint(g);
+  }
+
+  @Override
+  public void paint(Graphics g)
+  {
+    Graphics og = offscreen.getGraphics();
+    if (miniMe != null)
+    {
+      og.drawImage(miniMe, 0, 0, this);
+      og.setColor(Color.red);
+      od.drawBox(og);
+      g.drawImage(offscreen, 0, 0, this);
+    }
+  }
+
+}
index eaeafef..8c2b54b 100755 (executable)
  */
 package jalview.appletgui;
 
-import jalview.datamodel.SequenceI;
-import jalview.renderer.seqfeatures.FeatureColourFinder;
+import jalview.util.MessageManager;
+import jalview.util.Platform;
 import jalview.viewmodel.OverviewDimensions;
+import jalview.viewmodel.OverviewDimensionsHideHidden;
+import jalview.viewmodel.OverviewDimensionsShowHidden;
 
-import java.awt.Color;
+import java.awt.BorderLayout;
 import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.Graphics;
-import java.awt.Image;
+import java.awt.MenuItem;
 import java.awt.Panel;
+import java.awt.PopupMenu;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.awt.event.ComponentAdapter;
 import java.awt.event.ComponentEvent;
+import java.awt.event.InputEvent;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
 import java.awt.event.MouseMotionListener;
@@ -41,45 +45,29 @@ public class OverviewPanel extends Panel implements Runnable,
 {
   private OverviewDimensions od;
 
-  private Image miniMe;
-
-  private Image offscreen;
+  private OverviewCanvas oviewCanvas;
 
   private AlignViewport av;
 
   private AlignmentPanel ap;
 
-  private boolean resizing = false;
-
-  // This is set true if the user resizes whilst
-  // the overview is being calculated
-  private boolean resizeAgain = false;
-
-  // Can set different properties in this seqCanvas than
-  // main visible SeqCanvas
-  private SequenceRenderer sr;
+  private boolean showHidden = true;
 
-  private FeatureRenderer fr;
-
-  private Frame nullFrame;
+  private boolean updateRunning = false;
 
   public OverviewPanel(AlignmentPanel alPanel)
   {
     this.av = alPanel.av;
     this.ap = alPanel;
     setLayout(null);
-    nullFrame = new Frame();
-    nullFrame.addNotify();
-
-    sr = new SequenceRenderer(av);
-    sr.graphics = nullFrame.getGraphics();
-    sr.renderGaps = false;
-    sr.forOverview = true;
-    fr = new FeatureRenderer(av);
 
-    od = new OverviewDimensions(av.getRanges(),
+    od = new OverviewDimensionsShowHidden(av.getRanges(),
             (av.isShowAnnotation() && av.getSequenceConsensusHash() != null));
 
+    oviewCanvas = new OverviewCanvas(od, av);
+    setLayout(new BorderLayout());
+    add(oviewCanvas, BorderLayout.CENTER);
+
     setSize(new Dimension(od.getWidth(), od.getHeight()));
     addComponentListener(new ComponentAdapter()
     {
@@ -116,6 +104,10 @@ public class OverviewPanel extends Panel implements Runnable,
   @Override
   public void mouseClicked(MouseEvent evt)
   {
+    if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
+    {
+      showPopupMenu(evt);
+    }
   }
 
   @Override
@@ -143,11 +135,20 @@ public class OverviewPanel extends Panel implements Runnable,
 
   private void mouseAction(MouseEvent evt)
   {
-    od.updateViewportFromMouse(evt.getX(), evt.getY(), av.getAlignment()
-            .getHiddenSequences(), av.getAlignment().getHiddenColumns(), av
-            .getRanges());
-    ap.setScrollValues(od.getScrollCol(), od.getScrollRow());
-    ap.paintAlignment(false);
+    if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
+    {
+      if (!Platform.isAMac())
+      {
+        showPopupMenu(evt);
+      }
+    }
+    else
+    {
+      od.updateViewportFromMouse(evt.getX(), evt.getY(), av.getAlignment()
+              .getHiddenSequences(), av.getAlignment().getHiddenColumns());
+      ap.setScrollValues(od.getScrollCol(), od.getScrollRow());
+      ap.paintAlignment(false);
+    }
   }
 
   /**
@@ -155,19 +156,6 @@ public class OverviewPanel extends Panel implements Runnable,
    */
   public void updateOverviewImage()
   {
-    if (resizing)
-    {
-      resizeAgain = true;
-      return;
-    }
-
-    if (av.isShowSequenceFeatures())
-    {
-      fr.transferSettings(ap.seqPanel.seqCanvas.fr);
-    }
-
-    resizing = true;
-
     if ((getSize().width > 0) && (getSize().height > 0))
     {
       od.setWidth(getSize().width);
@@ -175,156 +163,30 @@ public class OverviewPanel extends Panel implements Runnable,
     }
     setSize(new Dimension(od.getWidth(), od.getHeight()));
 
+    synchronized (this)
+    {
+      if (updateRunning)
+      {
+        oviewCanvas.restartDraw();
+        return;
+      }
+
+      updateRunning = true;
+    }
     Thread thread = new Thread(this);
     thread.start();
     repaint();
+    updateRunning = false;
   }
 
   @Override
   public void run()
   {
-    miniMe = null;
-
-    if (av.isShowSequenceFeatures())
-    {
-      fr.transferSettings(ap.seqPanel.seqCanvas.getFeatureRenderer());
-    }
-
-    if (getSize().width > 0 && getSize().height > 0)
-    {
-      od.setWidth(getSize().width);
-      od.setHeight(getSize().height);
-    }
-
-    setSize(new Dimension(od.getWidth(), od.getHeight()));
-
-    miniMe = nullFrame.createImage(od.getWidth(), od.getHeight());
-    offscreen = nullFrame.createImage(od.getWidth(), od.getHeight());
-
-    Graphics mg = miniMe.getGraphics();
-
-    int alwidth = av.getAlignment().getWidth();
-    int alheight = av.getAlignment().getAbsoluteHeight();
-    float sampleCol = alwidth / (float) od.getWidth();
-    float sampleRow = alheight / (float) od.getSequencesHeight();
-
-    buildImage(sampleRow, sampleCol, mg);
-
-    // check for conservation annotation to make sure overview works for DNA too
-    if (av.isShowAnnotation()
-            && (av.getAlignmentConservationAnnotation() != null))
-    {
-      for (int col = 0; col < od.getWidth() && !resizeAgain; col++)
-      {
-        mg.translate(col, od.getSequencesHeight());
-        ap.annotationPanel.renderer.drawGraph(mg,
-                av.getAlignmentConservationAnnotation(),
-                av.getAlignmentConservationAnnotation().annotations,
-                (int) (sampleCol) + 1, od.getGraphHeight(),
-                (int) (col * sampleCol), (int) (col * sampleCol) + 1);
-        mg.translate(-col, -od.getSequencesHeight());
-      }
-    }
-    System.gc();
-
-    resizing = false;
-
+    oviewCanvas.draw(av.isShowSequenceFeatures(),
+            (av.isShowAnnotation() && av
+                    .getAlignmentConservationAnnotation() != null),
+            ap.seqPanel.seqCanvas.getFeatureRenderer());
     setBoxPosition();
-
-    if (resizeAgain)
-    {
-      resizeAgain = false;
-      updateOverviewImage();
-    }
-  }
-
-  /*
-   * Build the overview panel image
-   */
-  private void buildImage(float sampleRow, float sampleCol, Graphics mg)
-  {
-    int lastcol = 0;
-    int lastrow = 0;
-    int xstart = 0;
-    int ystart = 0;
-    Color color = Color.yellow;
-    int sameRow = 0;
-    int sameCol = 0;
-
-    SequenceI seq = null;
-    FeatureColourFinder finder = new FeatureColourFinder(fr);
-
-    final boolean hasHiddenCols = av.hasHiddenColumns();
-    boolean hiddenRow = false;
-
-    for (int row = 0; row <= od.getSequencesHeight() && !resizeAgain; row++)
-    {
-      if ((int) (row * sampleRow) == lastrow)
-      {
-        sameRow++;
-      }
-      else
-      {
-        // get the sequence which would be at alignment index 'lastrow' if no
-        // columns were hidden, and determine whether it is hidden or not
-        hiddenRow = av.getAlignment().isHidden(lastrow);
-        seq = av.getAlignment().getSequenceAtAbsoluteIndex(lastrow);
-
-        for (int col = 0; col < od.getWidth(); col++)
-        {
-          if ((int) (col * sampleCol) == lastcol
-                  && (int) (row * sampleRow) == lastrow)
-          {
-            sameCol++;
-          }
-          else
-          {
-            lastcol = (int) (col * sampleCol);
-
-            color = getColumnColourFromSequence(seq, hiddenRow,
-                    hasHiddenCols, lastcol, finder);
-
-            mg.setColor(color);
-            if (sameCol == 1 && sameRow == 1)
-            {
-              mg.drawLine(xstart, ystart, xstart, ystart);
-            }
-            else
-            {
-              mg.fillRect(xstart, ystart, sameCol, sameRow);
-            }
-
-            xstart = col;
-            sameCol = 1;
-          }
-        }
-        lastrow = (int) (row * sampleRow);
-        ystart = row;
-        sameRow = 1;
-      }
-    }
-  }
-
-  /*
-   * Find the colour of a sequence at a specified column position
-   */
-  private Color getColumnColourFromSequence(
-          jalview.datamodel.SequenceI seq, boolean hiddenRow,
-          boolean hasHiddenCols, int lastcol, FeatureColourFinder finder)
-  {
-    Color color = Color.white;
-    if (seq.getLength() > lastcol)
-    {
-      color = sr.getResidueColour(seq, lastcol, finder);
-    }
-
-    if (hiddenRow
-            || (hasHiddenCols && !av.getAlignment().getHiddenColumns()
-                    .isVisible(lastcol)))
-    {
-      color = color.darker().darker();
-    }
-    return color;
   }
 
   /**
@@ -336,27 +198,53 @@ public class OverviewPanel extends Panel implements Runnable,
   {
     od.setBoxPosition(av.getAlignment()
 .getHiddenSequences(), av
-            .getAlignment().getHiddenColumns(), av.getRanges());
+            .getAlignment().getHiddenColumns());
     repaint();
   }
 
-  @Override
-  public void update(Graphics g)
+  /*
+   * Displays the popup menu and acts on user input
+   */
+  private void showPopupMenu(MouseEvent e)
   {
-    paint(g);
+    PopupMenu popup = new PopupMenu();
+    ActionListener menuListener = new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent event)
+      {
+        // switch on/off the hidden columns view
+        toggleHiddenColumns();
+      }
+    };
+    MenuItem item = new MenuItem(
+            MessageManager.getString("label.togglehidden"));
+    popup.add(item);
+    item.addActionListener(menuListener);
+    this.add(popup);
+    popup.show(this, e.getX(), e.getY());
   }
 
-  @Override
-  public void paint(Graphics g)
+  /*
+   * Toggle overview display between showing hidden columns and hiding hidden columns
+   */
+  private void toggleHiddenColumns()
   {
-    Graphics og = offscreen.getGraphics();
-    if (miniMe != null)
+    if (showHidden)
+    {
+      showHidden = false;
+      od = new OverviewDimensionsHideHidden(av.getRanges(),
+              (av.isShowAnnotation() && av
+                      .getAlignmentConservationAnnotation() != null));
+    }
+    else
     {
-      og.drawImage(miniMe, 0, 0, this);
-      og.setColor(Color.red);
-      od.drawBox(og);
-      g.drawImage(offscreen, 0, 0, this);
+      showHidden = true;
+      od = new OverviewDimensionsShowHidden(av.getRanges(),
+              (av.isShowAnnotation() && av
+                      .getAlignmentConservationAnnotation() != null));
     }
+    oviewCanvas.resetOviewDims(od);
+    updateOverviewImage();
   }
-
 }
index e0ec011..22b4e3a 100755 (executable)
@@ -335,7 +335,7 @@ public class ScalePanel extends Panel implements MouseMotionListener,
 
     reveal = null;
     for (int[] region : av.getAlignment().getHiddenColumns()
-            .getListOfCols())
+            .getHiddenRegions())
     {
       if (res + 1 == region[0] || res - 1 == region[1])
       {
@@ -447,7 +447,7 @@ public class ScalePanel extends Panel implements MouseMotionListener,
       if (av.getShowHiddenMarkers())
       {
         int widthx = 1 + endx - startx;
-        for (int i = 0; i < hidden.getListOfCols().size(); i++)
+        for (int i = 0; i < hidden.getHiddenRegions().size(); i++)
         {
 
           res = hidden.findHiddenRegionPosition(i) - startx;
index ae879b5..39382c5 100755 (executable)
@@ -483,7 +483,7 @@ public class SeqCanvas extends Panel
         HiddenColumns hidden = av.getAlignment().getHiddenColumns();
         g.setColor(Color.blue);
         int res;
-        for (int i = 0; i < hidden.getListOfCols()
+        for (int i = 0; i < hidden.getHiddenRegions()
                 .size(); i++)
         {
           res = hidden.findHiddenRegionPosition(i)
@@ -566,7 +566,7 @@ public class SeqCanvas extends Panel
       if (av.hasHiddenColumns())
       {
         HiddenColumns hidden = av.getAlignment().getHiddenColumns();
-        for (int[] region : hidden.getListOfCols())
+        for (int[] region : hidden.getHiddenRegions())
         {
           int hideStart = region[0];
           int hideEnd = region[1];
index a40e73c..c413a06 100644 (file)
@@ -1887,7 +1887,7 @@ public class SeqPanel extends Panel implements MouseMotionListener,
     if (copycolsel
             && av.hasHiddenColumns()
             && (av.getColumnSelection() == null || av.getAlignment()
-                    .getHiddenColumns().getListOfCols() == null))
+                    .getHiddenColumns().getHiddenRegions() == null))
     {
       System.err.println("Bad things");
     }
diff --git a/src/jalview/datamodel/AllColsCollection.java b/src/jalview/datamodel/AllColsCollection.java
new file mode 100644 (file)
index 0000000..f84ba95
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.datamodel;
+
+import jalview.api.AlignmentColsCollectionI;
+
+import java.util.Iterator;
+
+public class AllColsCollection implements AlignmentColsCollectionI
+{
+  int start;
+  int end;
+
+  HiddenColumns hidden;
+  
+  public AllColsCollection(int s, int e, AlignmentI al)
+  {
+    start = s;
+    end = e;
+    hidden = al.getHiddenColumns();
+  }
+  
+  @Override
+  public Iterator<Integer> iterator()
+  {
+    return new AllColsIterator(start,end,hidden);
+  }
+
+  @Override
+  public boolean isHidden(int c)
+  {
+    return !hidden.isVisible(c);
+  }
+}
diff --git a/src/jalview/datamodel/AllColsIterator.java b/src/jalview/datamodel/AllColsIterator.java
new file mode 100644 (file)
index 0000000..c7a0bb1
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.datamodel;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * An iterator which iterates over all columns or rows in an alignment, whether
+ * hidden or visible.
+ * 
+ * @author kmourao
+ *
+ */
+public class AllColsIterator implements Iterator<Integer>
+{
+  private int last;
+
+  private int next;
+
+  private int current;
+
+  public AllColsIterator(int firstcol, int lastcol, HiddenColumns hiddenCols)
+  {
+    last = lastcol;
+    next = firstcol;
+    current = firstcol;
+  }
+
+  @Override
+  public boolean hasNext()
+  {
+    return current + 1 <= last;
+  }
+
+  @Override
+  public Integer next()
+  {
+    if (current + 1 > last)
+    {
+      throw new NoSuchElementException();
+    }
+    current = next;
+    next++;
+
+    return current;
+  }
+
+  @Override
+  public void remove()
+  {
+    throw new UnsupportedOperationException();
+  }
+}
+
diff --git a/src/jalview/datamodel/AllRowsCollection.java b/src/jalview/datamodel/AllRowsCollection.java
new file mode 100644 (file)
index 0000000..502ace4
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.datamodel;
+
+import jalview.api.AlignmentRowsCollectionI;
+
+import java.util.Iterator;
+
+public class AllRowsCollection implements AlignmentRowsCollectionI
+{
+  int start;
+
+  int end;
+
+  AlignmentI alignment;
+
+  HiddenSequences hidden;
+
+  public AllRowsCollection(int s, int e, AlignmentI al)
+  {
+    start = s;
+    end = e;
+    alignment = al;
+    hidden = al.getHiddenSequences();
+  }
+
+  @Override
+  public Iterator<Integer> iterator()
+  {
+    return new AllRowsIterator(start, end, alignment);
+  }
+
+  @Override
+  public boolean isHidden(int seq)
+  {
+    return hidden.isHidden(seq);
+  }
+
+  @Override
+  public SequenceI getSequence(int seq)
+  {
+    return alignment.getSequenceAtAbsoluteIndex(seq);
+  }
+}
+
diff --git a/src/jalview/datamodel/AllRowsIterator.java b/src/jalview/datamodel/AllRowsIterator.java
new file mode 100644 (file)
index 0000000..aefed60
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.datamodel;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * An iterator which iterates over all columns or rows in an alignment, whether
+ * hidden or visible.
+ * 
+ * @author kmourao
+ *
+ */
+public class AllRowsIterator implements Iterator<Integer>
+{
+  private int last;
+
+  private int next;
+
+  private int current;
+
+  private AlignmentI al;
+
+  public AllRowsIterator(int firstrow, int lastrow, AlignmentI alignment)
+  {
+    last = lastrow;
+    current = firstrow;
+    next = firstrow;
+    al = alignment;
+  }
+
+  @Override
+  public boolean hasNext()
+  {
+    return current + 1 <= last;
+  }
+
+  @Override
+  public Integer next()
+  {
+    if (current + 1 > last)
+    {
+      throw new NoSuchElementException();
+    }
+    current = next;
+    next++;
+
+    return current;
+  }
+
+  @Override
+  public void remove()
+  {
+    throw new UnsupportedOperationException();
+  }
+}
+
+
index a48a178..aab82a1 100644 (file)
@@ -92,7 +92,7 @@ public class CigarArray extends CigarBase
   {
     this(constructSeqCigarArray(alignment, selectionGroup));
     constructFromAlignment(alignment,
-            hidden != null ? hidden.getListOfCols()
+            hidden != null ? hidden.getHiddenRegions()
                     : null, selectionGroup);
   }
 
index 1abd04b..2edb3f1 100644 (file)
@@ -21,12 +21,35 @@ public class HiddenColumns
    * 
    * @return empty list or List of hidden column intervals
    */
-  public List<int[]> getListOfCols()
+  public List<int[]> getHiddenRegions()
   {
     return hiddenColumns == null ? Collections.<int[]> emptyList()
             : hiddenColumns;
   }
 
+  /**
+   * Find the number of hidden columns
+   * 
+   * @return number of hidden columns
+   */
+  public int getSize()
+  {
+    int size = 0;
+    if (hasHidden())
+    {
+      for (int[] range : hiddenColumns)
+      {
+        size += range[1] - range[0] + 1;
+      }
+    }
+    return size;
+  }
+
+  /**
+   * Answers if there are any hidden columns
+   * 
+   * @return true if there are hidden columns
+   */
   public boolean hasHidden()
   {
     return (hiddenColumns != null) && (!hiddenColumns.isEmpty());
@@ -544,7 +567,7 @@ public class HiddenColumns
     if (hiddenColumns != null && hiddenColumns.size() > 0)
     {
       List<int[]> visiblecontigs = new ArrayList<int[]>();
-      List<int[]> regions = getListOfCols();
+      List<int[]> regions = getHiddenRegions();
 
       int vstart = start;
       int[] region;
@@ -598,7 +621,7 @@ public class HiddenColumns
       for (i = 0; i < iSize; i++)
       {
         StringBuffer visibleSeq = new StringBuffer();
-        List<int[]> regions = getListOfCols();
+        List<int[]> regions = getHiddenRegions();
 
         int blockStart = start, blockEnd = end;
         int[] region;
@@ -671,7 +694,7 @@ public class HiddenColumns
 
     // Simply walk along the sequence whilst watching for hidden column
     // boundaries
-    List<int[]> regions = getListOfCols();
+    List<int[]> regions = getHiddenRegions();
     int spos = fpos, lastvispos = -1, rcount = 0, hideStart = seq
             .getLength(), hideEnd = -1;
     int visPrev = 0, visNext = 0, firstP = -1, lastP = -1;
@@ -765,7 +788,7 @@ public class HiddenColumns
       // then mangle the alignmentAnnotation annotation array
       Vector<Annotation[]> annels = new Vector<Annotation[]>();
       Annotation[] els = null;
-      List<int[]> regions = getListOfCols();
+      List<int[]> regions = getHiddenRegions();
       int blockStart = start, blockEnd = end;
       int[] region;
       int hideStart, hideEnd, w = 0;
index 6950c28..1daaf43 100755 (executable)
@@ -403,4 +403,20 @@ public class HiddenSequences
 
     return false;
   }
+
+  /**
+   * Answers if a sequence is hidden
+   * 
+   * @param seq
+   *          (absolute) index to test
+   * @return true if sequence at index seq is hidden
+   */
+  public boolean isHidden(int seq)
+  {
+    if (hiddenSequences != null)
+    {
+      return (hiddenSequences[seq] != null);
+    }
+    return false;
+  }
 }
diff --git a/src/jalview/datamodel/VisibleColsCollection.java b/src/jalview/datamodel/VisibleColsCollection.java
new file mode 100644 (file)
index 0000000..86233ab
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.datamodel;
+
+import jalview.api.AlignmentColsCollectionI;
+
+import java.util.Iterator;
+
+public class VisibleColsCollection implements AlignmentColsCollectionI
+{
+  int start;
+  int end;
+
+  HiddenColumns hidden;
+
+  public VisibleColsCollection(int s, int e, AlignmentI al)
+  {
+    start = s;
+    end = e;
+    hidden = al.getHiddenColumns();
+  }
+
+  @Override
+  public Iterator<Integer> iterator()
+  {
+    return new VisibleColsIterator(start, end, hidden);
+  }
+
+  @Override
+  public boolean isHidden(int c)
+  {
+    return false;
+  }
+
+}
diff --git a/src/jalview/datamodel/VisibleColsIterator.java b/src/jalview/datamodel/VisibleColsIterator.java
new file mode 100644 (file)
index 0000000..70de1e3
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.datamodel;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+/**
+ * An iterator which iterates over all visible columns in an alignment
+ * 
+ * @author kmourao
+ *
+ */
+public class VisibleColsIterator implements Iterator<Integer>
+{
+  private int last;
+
+  private int current;
+
+  private int next;
+
+  private List<int[]> hidden;
+
+  private int lasthiddenregion;
+
+  public VisibleColsIterator(int firstcol, int lastcol,
+          HiddenColumns hiddenCols)
+  {
+    last = lastcol;
+    current = firstcol;
+    next = firstcol;
+    hidden = hiddenCols.getHiddenRegions();
+    lasthiddenregion = -1;
+
+    if (hidden != null)
+    {
+      int i = 0;
+      for (i = 0; i < hidden.size(); ++i)
+      {
+        if (current >= hidden.get(i)[0] && current <= hidden.get(i)[1])
+        {
+          // current is hidden, move to right
+          current = hidden.get(i)[1] + 1;
+          next = current;
+        }
+        if (current < hidden.get(i)[0])
+        {
+          break;
+        }
+      }
+      lasthiddenregion = i - 1;
+
+      for (i = hidden.size() - 1; i >= 0; --i)
+      {
+        if (last >= hidden.get(i)[0] && last <= hidden.get(i)[1])
+        {
+          // last is hidden, move to left
+          last = hidden.get(i)[0] - 1;
+        }
+        if (last > hidden.get(i)[1])
+        {
+          break;
+        }
+      }
+    }
+  }
+
+  @Override
+  public boolean hasNext()
+  {
+    return next <= last;
+  }
+
+  @Override
+  public Integer next()
+  {
+    if (next > last)
+    {
+      throw new NoSuchElementException();
+    }
+    current = next;
+    if ((hidden != null) && (lasthiddenregion + 1 < hidden.size()))
+    {
+      // still some more hidden regions
+      if (next + 1 < hidden.get(lasthiddenregion + 1)[0])
+      {
+        // next+1 is still before the next hidden region
+        next++;
+      }
+      else if ((next + 1 >= hidden.get(lasthiddenregion + 1)[0])
+              && (next + 1 <= hidden.get(lasthiddenregion + 1)[1]))
+      {
+        // next + 1 is in the next hidden region
+        next = hidden.get(lasthiddenregion + 1)[1] + 1;
+        lasthiddenregion++;
+      }
+    }
+    else
+    {
+      // finished with hidden regions, just increment normally
+      next++;
+    }
+    return current;
+  }
+
+  @Override
+  public void remove()
+  {
+    throw new UnsupportedOperationException();
+  }
+}
+
diff --git a/src/jalview/datamodel/VisibleRowsCollection.java b/src/jalview/datamodel/VisibleRowsCollection.java
new file mode 100644 (file)
index 0000000..ce8e8da
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.datamodel;
+
+import jalview.api.AlignmentRowsCollectionI;
+
+import java.util.Iterator;
+
+public class VisibleRowsCollection implements AlignmentRowsCollectionI
+{
+  int start;
+
+  int end;
+
+  AlignmentI alignment;
+
+  public VisibleRowsCollection(int s, int e, AlignmentI al)
+  {
+    start = s;
+    end = e;
+    alignment = al;
+  }
+
+  @Override
+  public Iterator<Integer> iterator()
+  {
+    return new VisibleRowsIterator(start, end, alignment);
+  }
+
+  @Override
+  public boolean isHidden(int seq)
+  {
+    return false;
+  }
+
+  @Override
+  public SequenceI getSequence(int seq)
+  {
+    return alignment.getSequenceAtAbsoluteIndex(seq);
+  }
+}
+
diff --git a/src/jalview/datamodel/VisibleRowsIterator.java b/src/jalview/datamodel/VisibleRowsIterator.java
new file mode 100644 (file)
index 0000000..a9c782d
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.datamodel;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * An iterator which iterates over all visible rows in an alignment
+ * 
+ * @author kmourao
+ *
+ */
+public class VisibleRowsIterator implements Iterator<Integer>
+{
+  private int last;
+
+  private int current;
+
+  private int next;
+
+  private HiddenSequences hidden;
+
+  private AlignmentI al;
+
+  /**
+   * Create an iterator for all visible rows in the alignment
+   * 
+   * @param firstrow
+   *          absolute row index to start from
+   * @param lastrow
+   *          absolute row index to end at
+   * @param alignment
+   *          alignment to work with
+   */
+  public VisibleRowsIterator(int firstrow, int lastrow, AlignmentI alignment)
+  {
+    al = alignment;
+    current = firstrow;
+    last = lastrow;
+    hidden = al.getHiddenSequences();
+    while (last > current && hidden.isHidden(last))
+    {
+      last--;
+    }
+    current = firstrow;
+    while (current < last && hidden.isHidden(current))
+    {
+      current++;
+    }
+    next = current;
+  }
+
+  @Override
+  public boolean hasNext()
+  {
+    return next <= last;
+  }
+
+  @Override
+  public Integer next()
+  {
+    if (next > last)
+    {
+      throw new NoSuchElementException();
+    }
+    current = next;
+    do
+    {
+      next++;
+    } while (next <= last && hidden.isHidden(next));
+    return current;
+  }
+
+  @Override
+  public void remove()
+  {
+    throw new UnsupportedOperationException();
+  }
+}
+
index ca37196..2becfea 100644 (file)
@@ -1325,7 +1325,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     alignmentStartEnd = alignmentToExport
             .getVisibleStartAndEndIndex(viewport.getAlignment()
                     .getHiddenColumns()
-                    .getListOfCols());
+                    .getHiddenRegions());
     AlignmentExportData ed = new AlignmentExportData(alignmentToExport,
             omitHidden, alignmentStartEnd, settings);
     return ed;
@@ -1890,7 +1890,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
       int hiddenOffset = viewport.getSelectionGroup().getStartRes(), hiddenCutoff = viewport
               .getSelectionGroup().getEndRes();
       for (int[] region : viewport.getAlignment().getHiddenColumns()
-              .getListOfCols())
+              .getHiddenRegions())
       {
         if (region[0] >= hiddenOffset && region[1] <= hiddenCutoff)
         {
index 1c53b61..ad6731a 100644 (file)
@@ -52,7 +52,6 @@ import jalview.structure.StructureSelectionManager;
 import jalview.structure.VamsasSource;
 import jalview.util.MessageManager;
 import jalview.viewmodel.AlignmentViewport;
-import jalview.viewmodel.ViewportRanges;
 import jalview.ws.params.AutoCalcSetting;
 
 import java.awt.Container;
@@ -106,7 +105,7 @@ public class AlignViewport extends AlignmentViewport implements
    */
   public AlignViewport(AlignmentI al)
   {
-    setAlignment(al);
+    super(al);
     init();
   }
 
@@ -124,6 +123,7 @@ public class AlignViewport extends AlignmentViewport implements
 
   public AlignViewport(AlignmentI al, String seqsetid, String viewid)
   {
+    super(al);
     sequenceSetID = seqsetid;
     viewId = viewid;
     // TODO remove these once 2.4.VAMSAS release finished
@@ -136,8 +136,8 @@ public class AlignViewport extends AlignmentViewport implements
     {
       Cache.log.debug("Setting viewport's view id : " + viewId);
     }
-    setAlignment(al);
     init();
+
   }
 
   /**
@@ -150,7 +150,7 @@ public class AlignViewport extends AlignmentViewport implements
    */
   public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns)
   {
-    setAlignment(al);
+    super(al);
     if (hiddenColumns != null)
     {
       al.setHiddenColumns(hiddenColumns);
@@ -185,6 +185,7 @@ public class AlignViewport extends AlignmentViewport implements
   public AlignViewport(AlignmentI al, HiddenColumns hiddenColumns,
           String seqsetid, String viewid)
   {
+    super(al);
     sequenceSetID = seqsetid;
     viewId = viewid;
     // TODO remove these once 2.4.VAMSAS release finished
@@ -197,7 +198,7 @@ public class AlignViewport extends AlignmentViewport implements
     {
       Cache.log.debug("Setting viewport's view id : " + viewId);
     }
-    setAlignment(al);
+
     if (hiddenColumns != null)
     {
       al.setHiddenColumns(hiddenColumns);
@@ -239,7 +240,6 @@ public class AlignViewport extends AlignmentViewport implements
 
   void init()
   {
-    ranges = new ViewportRanges(this.alignment);
     applyViewProperties();
 
     String fontName = Cache.getDefault("FONT_NAME", "SansSerif");
index dedb8b8..96299e7 100644 (file)
@@ -245,10 +245,10 @@ public class AnnotationColumnChooser extends AnnotationRowFilter implements
         HiddenColumns oldHidden = av
                 .getAnnotationColumnSelectionState()
                 .getOldHiddenColumns();
-        if (oldHidden != null && oldHidden.getListOfCols() != null
-                && !oldHidden.getListOfCols().isEmpty())
+        if (oldHidden != null && oldHidden.getHiddenRegions() != null
+                && !oldHidden.getHiddenRegions().isEmpty())
         {
-          for (Iterator<int[]> itr = oldHidden.getListOfCols()
+          for (Iterator<int[]> itr = oldHidden.getHiddenRegions()
                   .iterator(); itr.hasNext();)
           {
             int positions[] = itr.next();
index 3e4ec98..8ca1a4e 100755 (executable)
@@ -954,7 +954,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
 
     int[] alignmentStartEnd = new int[] { 0, ds.getWidth() - 1 };
     List<int[]> hiddenCols = av.getAlignment().getHiddenColumns()
-            .getListOfCols();
+            .getHiddenRegions();
     if (hiddenCols != null)
     {
       alignmentStartEnd = av.getAlignment().getVisibleStartAndEndIndex(
@@ -971,7 +971,7 @@ public class AnnotationLabels extends JPanel implements MouseListener,
     {
       hiddenColumns = new ArrayList<int[]>();
       for (int[] region : av.getAlignment().getHiddenColumns()
-              .getListOfCols())
+              .getHiddenRegions())
       {
         hiddenColumns.add(new int[] { region[0], region[1] });
       }
index 5f1fe73..6361caf 100644 (file)
@@ -1415,16 +1415,16 @@ public class Jalview2XML
       {
         jalview.datamodel.HiddenColumns hidden = av.getAlignment()
                 .getHiddenColumns();
-        if (hidden == null || hidden.getListOfCols() == null)
+        if (hidden == null || hidden.getHiddenRegions() == null)
         {
           warn("REPORT BUG: avoided null columnselection bug (DMAM reported). Please contact Jim about this.");
         }
         else
         {
-          for (int c = 0; c < hidden.getListOfCols()
+          for (int c = 0; c < hidden.getHiddenRegions()
                   .size(); c++)
           {
-            int[] region = hidden.getListOfCols()
+            int[] region = hidden.getHiddenRegions()
                     .get(c);
             HiddenColumns hc = new HiddenColumns();
             hc.setStart(region[0]);
diff --git a/src/jalview/gui/OverviewCanvas.java b/src/jalview/gui/OverviewCanvas.java
new file mode 100644 (file)
index 0000000..6f9fbbf
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.gui;
+
+import jalview.api.AlignViewportI;
+import jalview.renderer.OverviewRenderer;
+import jalview.viewmodel.OverviewDimensions;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+
+import javax.swing.JComponent;
+
+public class OverviewCanvas extends JComponent
+{
+  private static final Color TRANS_GREY = new Color(100, 100, 100, 25);
+
+  // This is set true if the alignment view changes whilst
+  // the overview is being calculated
+  private volatile boolean restart = false;
+
+  private volatile boolean updaterunning = false;
+
+  private BufferedImage miniMe;
+
+  private BufferedImage lastMiniMe = null;
+
+  // Can set different properties in this seqCanvas than
+  // main visible SeqCanvas
+  private SequenceRenderer sr;
+
+  private jalview.renderer.seqfeatures.FeatureRenderer fr;
+
+  private OverviewDimensions od;
+
+  private AlignViewportI av;
+
+  public OverviewCanvas(OverviewDimensions overviewDims,
+          AlignViewportI alignvp)
+  {
+    od = overviewDims;
+    av = alignvp;
+
+    sr = new SequenceRenderer(av);
+    sr.renderGaps = false;
+    sr.forOverview = true;
+    fr = new jalview.renderer.seqfeatures.FeatureRenderer(av);
+  }
+
+  /**
+   * Update the overview dimensions object used by the canvas (e.g. if we change
+   * from showing hidden columns to hiding them or vice versa)
+   * 
+   * @param overviewDims
+   */
+  public void resetOviewDims(OverviewDimensions overviewDims)
+  {
+    od = overviewDims;
+  }
+
+  /**
+   * Signals to drawing code that the associated alignment viewport has changed
+   * and a redraw will be required
+   */
+  public boolean restartDraw()
+  {
+    synchronized (this)
+    {
+      if (updaterunning)
+      {
+        restart = true;
+      }
+      else
+      {
+        updaterunning = true;
+      }
+      return restart;
+    }
+  }
+
+  /**
+   * Draw the overview sequences
+   * 
+   * @param showSequenceFeatures
+   *          true if sequence features are to be shown
+   * @param showAnnotation
+   *          true if the annotation is to be shown
+   * @param transferRenderer
+   *          the renderer to transfer feature colouring from
+   */
+  public void draw(boolean showSequenceFeatures, boolean showAnnotation,
+          FeatureRenderer transferRenderer)
+  {
+    miniMe = null;
+
+    if (showSequenceFeatures)
+    {
+      fr.transferSettings(transferRenderer);
+    }
+
+    setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
+
+    OverviewRenderer or = new OverviewRenderer(sr, fr, od);
+    miniMe = or.draw(od.getRows(av.getAlignment()),
+            od.getColumns(av.getAlignment()));
+
+    Graphics mg = miniMe.getGraphics();
+
+    if (showAnnotation)
+    {
+      mg.translate(0, od.getSequencesHeight());
+      or.drawGraph(mg, av.getAlignmentConservationAnnotation(),
+              av.getCharWidth(), od.getGraphHeight(),
+              od.getColumns(av.getAlignment()));
+      mg.translate(0, -od.getSequencesHeight());
+    }
+    System.gc();
+
+    if (restart)
+    {
+      restart = false;
+      draw(showSequenceFeatures, showAnnotation, transferRenderer);
+    }
+    else
+    {
+      updaterunning = false;
+      lastMiniMe = miniMe;
+    }
+  }
+
+  @Override
+  public void paintComponent(Graphics g)
+  {
+    if (restart)
+    {
+      if (lastMiniMe == null)
+      {
+        g.setColor(Color.white);
+        g.fillRect(0, 0, getWidth(), getHeight());
+      }
+      else
+      {
+        g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this);
+      }
+      g.setColor(TRANS_GREY);
+      g.fillRect(0, 0, getWidth(), getHeight());
+    }
+    else if (lastMiniMe != null)
+    {
+      g.drawImage(lastMiniMe, 0, 0, this);
+      if (lastMiniMe != miniMe)
+      {
+        g.setColor(TRANS_GREY);
+        g.fillRect(0, 0, getWidth(), getHeight());
+      }
+    }
+
+    g.setColor(Color.red);
+    od.drawBox(g);
+  }
+
+}
index e42d25f..7750374 100755 (executable)
  */
 package jalview.gui;
 
-import jalview.datamodel.SequenceI;
-import jalview.renderer.AnnotationRenderer;
-import jalview.renderer.seqfeatures.FeatureColourFinder;
+import jalview.util.MessageManager;
+import jalview.util.Platform;
 import jalview.viewmodel.OverviewDimensions;
+import jalview.viewmodel.OverviewDimensionsHideHidden;
+import jalview.viewmodel.OverviewDimensionsShowHidden;
 
-import java.awt.Color;
+import java.awt.BorderLayout;
 import java.awt.Dimension;
-import java.awt.Graphics;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.awt.event.ComponentAdapter;
 import java.awt.event.ComponentEvent;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseMotionAdapter;
-import java.awt.image.BufferedImage;
 
+import javax.swing.JMenuItem;
 import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.SwingUtilities;
 
 /**
  * Panel displaying an overview of the full alignment, with an interactive box
@@ -46,32 +50,15 @@ import javax.swing.JPanel;
  */
 public class OverviewPanel extends JPanel implements Runnable
 {
-  private static final Color TRANS_GREY = new Color(100, 100, 100, 25);
-
-  private final AnnotationRenderer renderer = new AnnotationRenderer();
-
   private OverviewDimensions od;
 
-  private BufferedImage miniMe;
-
-  private BufferedImage lastMiniMe = null;
+  private OverviewCanvas oviewCanvas;
 
   private AlignViewport av;
 
   private AlignmentPanel ap;
 
-  //
-  private boolean resizing = false;
-
-  // This is set true if the user resizes whilst
-  // the overview is being calculated
-  private boolean resizeAgain = false;
-
-  // Can set different properties in this seqCanvas than
-  // main visible SeqCanvas
-  private SequenceRenderer sr;
-
-  jalview.renderer.seqfeatures.FeatureRenderer fr;
+  private boolean showHidden = true;
 
   /**
    * Creates a new OverviewPanel object.
@@ -83,17 +70,15 @@ public class OverviewPanel extends JPanel implements Runnable
   {
     this.av = alPanel.av;
     this.ap = alPanel;
-    setLayout(null);
 
-    sr = new SequenceRenderer(av);
-    sr.renderGaps = false;
-    sr.forOverview = true;
-    fr = new FeatureRenderer(ap);
-
-    od = new OverviewDimensions(av.getRanges(),
+    od = new OverviewDimensionsShowHidden(av.getRanges(),
             (av.isShowAnnotation() && av
                     .getAlignmentConservationAnnotation() != null));
 
+    oviewCanvas = new OverviewCanvas(od, av);
+    setLayout(new BorderLayout());
+    add(oviewCanvas, BorderLayout.CENTER);
+
     addComponentListener(new ComponentAdapter()
     {
       @Override
@@ -112,11 +97,12 @@ public class OverviewPanel extends JPanel implements Runnable
       @Override
       public void mouseDragged(MouseEvent evt)
       {
-        if (!av.getWrapAlignment())
+        if (!SwingUtilities.isRightMouseButton(evt)
+                && !av.getWrapAlignment())
         {
           od.updateViewportFromMouse(evt.getX(), evt.getY(), av
                   .getAlignment().getHiddenSequences(), av.getAlignment()
-                  .getHiddenColumns(), av.getRanges());
+                  .getHiddenColumns());
           ap.setScrollValues(od.getScrollCol(), od.getScrollRow());
         }
       }
@@ -127,191 +113,113 @@ public class OverviewPanel extends JPanel implements Runnable
       @Override
       public void mousePressed(MouseEvent evt)
       {
-        if (!av.getWrapAlignment())
+        if (SwingUtilities.isRightMouseButton(evt))
+        {
+          if (!Platform.isAMac())
+          {
+            showPopupMenu(evt);
+          }
+        }
+        else if (!av.getWrapAlignment())
         {
           od.updateViewportFromMouse(evt.getX(), evt.getY(), av
                   .getAlignment().getHiddenSequences(), av.getAlignment()
-                  .getHiddenColumns(), av.getRanges());
+                  .getHiddenColumns());
           ap.setScrollValues(od.getScrollCol(), od.getScrollRow());
         }
       }
+
+      @Override
+      public void mouseClicked(MouseEvent evt)
+      {
+        if (SwingUtilities.isRightMouseButton(evt))
+        {
+          showPopupMenu(evt);
+        }
+      }
     });
 
+
     updateOverviewImage();
   }
 
-  /**
-   * Updates the overview image when the related alignment panel is updated
+  /*
+   * Displays the popup menu and acts on user input
    */
-  public void updateOverviewImage()
-  {
-    if (resizing)
-    {
-      resizeAgain = true;
-      return;
-    }
-
-    resizing = true;
-
-    if ((getWidth() > 0) && (getHeight() > 0))
-    {
-      od.setWidth(getWidth());
-      od.setHeight(getHeight());
-    }
-
-    setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
-
-    Thread thread = new Thread(this);
-    thread.start();
-    repaint();
-  }
-
-  @Override
-  public void run()
+  private void showPopupMenu(MouseEvent e)
   {
-    miniMe = null;
-
-    if (av.isShowSequenceFeatures())
-    {
-      fr.transferSettings(ap.getSeqPanel().seqCanvas.getFeatureRenderer());
-    }
-
-    // why do we need to set preferred size again? was set in
-    // updateOverviewImage
-    setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
-
-    miniMe = new BufferedImage(od.getWidth(), od.getHeight(),
-            BufferedImage.TYPE_INT_RGB);
-
-    Graphics mg = miniMe.getGraphics();
-    mg.setColor(Color.orange);
-    mg.fillRect(0, 0, od.getWidth(), miniMe.getHeight());
-
-    // calculate sampleCol and sampleRow
-    // alignment width is max number of residues/bases
-    // alignment height is number of sequences
-    int alwidth = av.getAlignment().getWidth();
-    int alheight = av.getAlignment().getAbsoluteHeight();
-
-    // sampleCol or sampleRow is the width/height allocated to each residue
-    // in particular, sometimes we may need more than one row/col of the
-    // BufferedImage allocated
-    // sampleCol is how much of a residue to assign to each pixel
-    // sampleRow is how many sequences to assign to each pixel
-    float sampleCol = alwidth / (float) od.getWidth();
-    float sampleRow = alheight / (float) od.getSequencesHeight();
-
-    buildImage(sampleRow, sampleCol);
-
-    // check for conservation annotation to make sure overview works for DNA too
-    if (av.isShowAnnotation()
-            && (av.getAlignmentConservationAnnotation() != null))
+    JPopupMenu popup = new JPopupMenu();
+    ActionListener menuListener = new ActionListener()
     {
-      renderer.updateFromAlignViewport(av);
-      for (int col = 0; col < od.getWidth() && !resizeAgain; col++)
+      @Override
+      public void actionPerformed(ActionEvent event)
       {
-        mg.translate(col, od.getSequencesHeight());
-        renderer.drawGraph(mg, av.getAlignmentConservationAnnotation(),
-                av.getAlignmentConservationAnnotation().annotations,
-                (int) (sampleCol) + 1, od.getGraphHeight(),
-                (int) (col * sampleCol), (int) (col * sampleCol) + 1);
-        mg.translate(-col, -od.getSequencesHeight());
-
+        // switch on/off the hidden columns view
+        toggleHiddenColumns();
       }
-    }
-    System.gc();
-
-    resizing = false;
-
-    if (resizeAgain)
-    {
-      resizeAgain = false;
-      updateOverviewImage();
-    }
-    else
-    {
-      lastMiniMe = miniMe;
-    }
-
-    setBoxPosition();
+    };
+    JMenuItem item = new JMenuItem(
+            MessageManager.getString("label.togglehidden"));
+    popup.add(item);
+    item.addActionListener(menuListener);
+    popup.show(this, e.getX(), e.getY());
   }
 
   /*
-   * Build the overview panel image
+   * Toggle overview display between showing hidden columns and hiding hidden columns
    */
-  private void buildImage(float sampleRow, float sampleCol)
+  private void toggleHiddenColumns()
   {
-    int lastcol = -1;
-    int lastrow = -1;
-    int rgbColour = Color.white.getRGB();
-
-    SequenceI seq = null;
-    FeatureColourFinder finder = new FeatureColourFinder(fr);
-
-    final boolean hasHiddenCols = av.hasHiddenColumns();
-    boolean hiddenRow = false;
-    // get hidden row and hidden column map once at beginning.
-    // clone featureRenderer settings to avoid race conditions... if state is
-    // updated just need to refresh again
-    for (int row = 0; row < od.getSequencesHeight() && !resizeAgain; row++)
+    if (showHidden)
     {
-      boolean doCopy = true;
-      int currentrow = (int) (row * sampleRow);
-      if (currentrow != lastrow)
-      {
-        doCopy = false;
-
-        lastrow = currentrow;
-
-        // get the sequence which would be at alignment index 'lastrow' if no
-        // rows were hidden, and determine whether it is hidden or not
-        hiddenRow = av.getAlignment().isHidden(lastrow);
-        seq = av.getAlignment().getSequenceAtAbsoluteIndex(lastrow);
-      }
-
-      for (int col = 0; col < od.getWidth() && !resizeAgain; col++)
-      {
-        if (doCopy)
-        {
-          rgbColour = miniMe.getRGB(col, row - 1);
-        }
-        else if ((int) (col * sampleCol) != lastcol
-                || (int) (row * sampleRow) != lastrow)
-        {
-          lastcol = (int) (col * sampleCol);
-          rgbColour = getColumnColourFromSequence(seq, hiddenRow,
-                  hasHiddenCols, lastcol, finder);
-        }
-        // else we just use the color we already have , so don't need to set it
-
-        miniMe.setRGB(col, row, rgbColour);
-      }
+      showHidden = false;
+      od = new OverviewDimensionsHideHidden(av.getRanges(),
+              (av.isShowAnnotation() && av
+                      .getAlignmentConservationAnnotation() != null));
     }
+    else
+    {
+      showHidden = true;
+      od = new OverviewDimensionsShowHidden(av.getRanges(),
+              (av.isShowAnnotation() && av
+                      .getAlignmentConservationAnnotation() != null));
+    }
+    oviewCanvas.resetOviewDims(od);
+    updateOverviewImage();
   }
 
-  /*
-   * Find the colour of a sequence at a specified column position
+  /**
+   * Updates the overview image when the related alignment panel is updated
    */
-  private int getColumnColourFromSequence(
-          jalview.datamodel.SequenceI seq,
-          boolean hiddenRow, boolean hasHiddenCols, int lastcol,
-          FeatureColourFinder finder)
+  public void updateOverviewImage()
   {
-    Color color = Color.white;
-
-    if ((seq != null) && (seq.getLength() > lastcol))
+    if ((getWidth() > 0) && (getHeight() > 0))
     {
-       color = sr.getResidueColour(seq, lastcol, finder);
+      od.setWidth(getWidth());
+      od.setHeight(getHeight());
     }
+    
+    setPreferredSize(new Dimension(od.getWidth(), od.getHeight()));
 
-    if (hiddenRow
-            || (hasHiddenCols && !av.getAlignment().getHiddenColumns()
-                    .isVisible(lastcol)))
+    if (oviewCanvas.restartDraw())
     {
-      color = color.darker().darker();
+      return;
     }
 
-    return color.getRGB();
+    Thread thread = new Thread(this);
+    thread.start();
+    repaint();
+
+  }
+
+  @Override
+  public void run()
+  {
+    oviewCanvas.draw(av.isShowSequenceFeatures(),
+            (av.isShowAnnotation() && av
+                    .getAlignmentConservationAnnotation() != null), ap
+                    .getSeqPanel().seqCanvas.getFeatureRenderer());
+    setBoxPosition();
   }
 
   /**
@@ -321,41 +229,8 @@ public class OverviewPanel extends JPanel implements Runnable
    */
   public void setBoxPosition()
   {
-    od.setBoxPosition(av.getAlignment()
-.getHiddenSequences(), av
-            .getAlignment().getHiddenColumns(), av.getRanges());
+    od.setBoxPosition(av.getAlignment().getHiddenSequences(), av
+            .getAlignment().getHiddenColumns());
     repaint();
   }
-
-
-  @Override
-  public void paintComponent(Graphics g)
-  {
-    if (resizing || resizeAgain)
-    {
-      if (lastMiniMe == null)
-      {
-        g.setColor(Color.white);
-        g.fillRect(0, 0, getWidth(), getHeight());
-      }
-      else
-      {
-        g.drawImage(lastMiniMe, 0, 0, getWidth(), getHeight(), this);
-      }
-      g.setColor(TRANS_GREY);
-      g.fillRect(0, 0, getWidth(), getHeight());
-    }
-    else if (lastMiniMe != null)
-    {
-      g.drawImage(lastMiniMe, 0, 0, this);
-      if (lastMiniMe != miniMe)
-      {
-        g.setColor(TRANS_GREY);
-        g.fillRect(0, 0, getWidth(), getHeight());
-      }
-    }
-
-    g.setColor(Color.red);
-    od.drawBox(g);
-  }
 }
index bc59f91..90f7cd2 100755 (executable)
@@ -399,10 +399,10 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
 
     res = av.getAlignment().getHiddenColumns().adjustForHiddenColumns(res);
 
-    if (av.getAlignment().getHiddenColumns().getListOfCols() != null)
+    if (av.getAlignment().getHiddenColumns().getHiddenRegions() != null)
     {
       for (int[] region : av.getAlignment().getHiddenColumns()
-              .getListOfCols())
+              .getHiddenRegions())
       {
         if (res + 1 == region[0] || res - 1 == region[1])
         {
@@ -495,9 +495,9 @@ public class ScalePanel extends JPanel implements MouseMotionListener,
       gg.setColor(Color.blue);
       int res;
 
-      if (av.getShowHiddenMarkers() && hidden.getListOfCols() != null)
+      if (av.getShowHiddenMarkers() && hidden.getHiddenRegions() != null)
       {
-        for (int i = 0; i < hidden.getListOfCols()
+        for (int i = 0; i < hidden.getHiddenRegions()
                 .size(); i++)
         {
           res = hidden.findHiddenRegionPosition(i)
index 3725445..c2a2ccb 100755 (executable)
@@ -560,7 +560,7 @@ public class SeqCanvas extends JComponent
         g.setColor(Color.blue);
         int res;
         HiddenColumns hidden = av.getAlignment().getHiddenColumns();
-        for (int i = 0; i < hidden.getListOfCols().size(); i++)
+        for (int i = 0; i < hidden.getHiddenRegions().size(); i++)
         {
           res = hidden.findHiddenRegionPosition(i) - startRes;
 
@@ -660,7 +660,7 @@ public class SeqCanvas extends JComponent
     else
     {
       List<int[]> regions = av.getAlignment().getHiddenColumns()
-              .getListOfCols();
+              .getHiddenRegions();
 
       int screenY = 0;
       int blockStart = startRes;
index 749b390..c2f4c75 100644 (file)
@@ -2075,7 +2075,7 @@ public class SeqPanel extends JPanel implements MouseListener,
     if (copycolsel
             && av.hasHiddenColumns()
             && (av.getAlignment().getHiddenColumns() == null || av
-                    .getAlignment().getHiddenColumns().getListOfCols() == null))
+                    .getAlignment().getHiddenColumns().getHiddenRegions() == null))
     {
       System.err.println("Bad things");
     }
index 1c0420d..2a2a0cf 100755 (executable)
@@ -20,6 +20,7 @@
  */
 package jalview.gui;
 
+import jalview.api.AlignViewportI;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.renderer.ResidueShaderI;
@@ -34,7 +35,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
 {
   final static int CHAR_TO_UPPER = 'A' - 'a';
 
-  AlignViewport av;
+  AlignViewportI av;
 
   FontMetrics fm;
 
@@ -57,7 +58,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
    * 
    * @param viewport
    */
-  public SequenceRenderer(AlignViewport viewport)
+  public SequenceRenderer(AlignViewportI viewport)
   {
     this.av = viewport;
   }
@@ -181,7 +182,7 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
 
     drawBoxes(seq, start, end, y1);
 
-    if (av.validCharWidth)
+    if (av.isValidCharWidth())
     {
       drawText(seq, start, end, y1);
     }
index e685627..c3e71da 100755 (executable)
@@ -171,7 +171,7 @@ public class AnnotationFile
     if (cs != null && cs.hasHiddenColumns())
     {
       text.append("VIEW_HIDECOLS\t");
-      List<int[]> hc = cs.getListOfCols();
+      List<int[]> hc = cs.getHiddenRegions();
       boolean comma = false;
       for (int[] r : hc)
       {
index 93a0167..816346a 100644 (file)
@@ -281,7 +281,7 @@ public class JSONFile extends AlignFile implements ComplexAlignFile
     {
       List<int[]> hiddenCols = getViewport().getAlignment()
               .getHiddenColumns()
-              .getListOfCols();
+              .getHiddenRegions();
       StringBuilder hiddenColsBuilder = new StringBuilder();
       for (int[] range : hiddenCols)
       {
diff --git a/src/jalview/renderer/OverviewRenderer.java b/src/jalview/renderer/OverviewRenderer.java
new file mode 100644 (file)
index 0000000..69676c8
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.renderer;
+
+import jalview.api.AlignmentColsCollectionI;
+import jalview.api.AlignmentRowsCollectionI;
+import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.Annotation;
+import jalview.datamodel.SequenceI;
+import jalview.renderer.seqfeatures.FeatureColourFinder;
+import jalview.renderer.seqfeatures.FeatureRenderer;
+import jalview.viewmodel.OverviewDimensions;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+
+public class OverviewRenderer
+{
+  private FeatureColourFinder finder;
+
+  private jalview.api.SequenceRenderer sr;
+
+  // image to render on
+  private BufferedImage miniMe;
+
+  // raw number of pixels to allocate to each column
+  private float pixelsPerCol;
+
+  // raw number of pixels to allocate to each row
+  private float pixelsPerSeq;
+
+  public OverviewRenderer(jalview.api.SequenceRenderer seqRenderer,
+          FeatureRenderer fr, OverviewDimensions od)
+  // FeatureColourFinder colfinder, OverviewDimensions od)
+  {
+    sr = seqRenderer;
+    finder = new FeatureColourFinder(fr); // colfinder;
+
+    pixelsPerCol = od.getPixelsPerCol();
+    pixelsPerSeq = od.getPixelsPerSeq();
+    miniMe = new BufferedImage(od.getWidth(), od.getHeight(),
+            BufferedImage.TYPE_INT_RGB);
+  }
+
+  /**
+   * Draw alignment rows and columns onto an image
+   * 
+   * @param rit
+   *          Iterator over rows to be drawn
+   * @param cit
+   *          Iterator over columns to be drawn
+   * @return image containing the drawing
+   */
+  public BufferedImage draw(AlignmentRowsCollectionI rows,
+          AlignmentColsCollectionI cols)
+  {
+    int rgbcolor = Color.white.getRGB();
+    int seqIndex = 0;
+    int pixelRow = 0;
+    for (int alignmentRow : rows)
+    {
+      // get details of this alignment row
+      boolean hidden = rows.isHidden(alignmentRow);
+      SequenceI seq = rows.getSequence(alignmentRow);
+
+      // calculate where this row extends to in pixels
+      int endRow = Math.min(Math.round((seqIndex + 1) * pixelsPerSeq) - 1,
+              miniMe.getHeight() - 1);
+
+      int colIndex = 0;
+      int pixelCol = 0;
+      for (int alignmentCol : cols)
+      {
+        // calculate where this column extends to in pixels
+        int endCol = Math.min(
+                Math.round((colIndex + 1) * pixelsPerCol) - 1,
+                miniMe.getWidth() - 1);
+
+        // determine the colour based on the sequence and column position
+        rgbcolor = getColumnColourFromSequence(seq,
+                hidden || cols.isHidden(alignmentCol), alignmentCol, finder);
+
+        // fill in the appropriate number of pixels
+        for (int row = pixelRow; row <= endRow; ++row)
+        {
+          for (int col = pixelCol; col <= endCol; ++col)
+          {
+            miniMe.setRGB(col, row, rgbcolor);
+          }
+        }
+
+        pixelCol = endCol + 1;
+        colIndex++;
+      }
+      pixelRow = endRow + 1;
+      seqIndex++;
+    }
+    return miniMe;
+  }
+
+  /*
+   * Find the colour of a sequence at a specified column position
+   */
+  private int getColumnColourFromSequence(jalview.datamodel.SequenceI seq,
+          boolean isHidden, int lastcol, FeatureColourFinder fcfinder)
+  {
+    Color color = Color.white;
+
+    if ((seq != null) && (seq.getLength() > lastcol))
+    {
+      color = sr.getResidueColour(seq, lastcol, fcfinder);
+    }
+
+    if (isHidden)
+    {
+      color = color.darker().darker();
+    }
+
+    return color.getRGB();
+  }
+
+  /**
+   * Draw the alignment annotation in the overview panel
+   * 
+   * @param g
+   *          the graphics object to draw on
+   * @param anno
+   *          alignment annotation information
+   * @param charWidth
+   *          alignment character width value
+   * @param y
+   *          y-position for the annotation graph
+   * @param cols
+   *          the collection of columns used in the overview panel
+   */
+  public void drawGraph(Graphics g, AlignmentAnnotation anno, int charWidth,
+          int y, AlignmentColsCollectionI cols)
+  {
+    Annotation[] annotations = anno.annotations;
+    g.setColor(Color.white);
+    g.fillRect(0, 0, miniMe.getWidth(), y);
+
+    int height;
+    int colIndex = 0;
+    int pixelCol = 0;
+    for (int alignmentCol : cols)
+    {
+      if (alignmentCol >= annotations.length)
+      {
+        break; // no more annotations to draw here
+      }
+      else
+      {
+        int endCol = Math.min(
+                Math.round((colIndex + 1) * pixelsPerCol) - 1,
+                miniMe.getWidth() - 1);
+
+        if (annotations[alignmentCol] != null)
+        {
+          if (annotations[alignmentCol].colour == null)
+          {
+            g.setColor(Color.black);
+          }
+          else
+          {
+            g.setColor(annotations[alignmentCol].colour);
+          }
+
+          height = (int) ((annotations[alignmentCol].value / anno.graphMax) * y);
+          if (height > y)
+          {
+            height = y;
+          }
+
+          g.fillRect(pixelCol, y - height, endCol - pixelCol + 1, height);
+        }
+        pixelCol = endCol + 1;
+        colIndex++;
+      }
+    }
+  }
+}
index 33c43d3..926ccc7 100644 (file)
@@ -540,7 +540,7 @@ public final class MappingUtils
               toSequences, fromGapChar);
     }
 
-    for (int[] hidden : hiddencols.getListOfCols())
+    for (int[] hidden : hiddencols.getHiddenRegions())
     {
       mapHiddenColumns(hidden, codonFrames, newHidden, fromSequences,
               toSequences, fromGapChar);
index 6a38f21..39621c5 100644 (file)
@@ -80,7 +80,7 @@ import java.util.Map;
 public abstract class AlignmentViewport implements AlignViewportI,
         CommandListener, VamsasSource
 {
-  protected ViewportRanges ranges;
+  final protected ViewportRanges ranges;
 
   protected ViewStyleI viewStyle = new ViewStyle();
 
@@ -97,6 +97,17 @@ public abstract class AlignmentViewport implements AlignViewportI,
   protected Deque<CommandI> redoList = new ArrayDeque<CommandI>();
 
   /**
+   * alignment displayed in the viewport. Please use get/setter
+   */
+  protected AlignmentI alignment;
+
+  public AlignmentViewport(AlignmentI al)
+  {
+    setAlignment(al);
+    ranges = new ViewportRanges(al);
+  }
+
+  /**
    * @param name
    * @see jalview.api.ViewStyleI#setFontName(java.lang.String)
    */
@@ -556,10 +567,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
     viewStyle.setSeqNameItalics(default1);
   }
 
-  /**
-   * alignment displayed in the viewport. Please use get/setter
-   */
-  protected AlignmentI alignment;
+
 
   @Override
   public AlignmentI getAlignment()
index db82aa5..a837d53 100644 (file)
  */
 package jalview.viewmodel;
 
+import jalview.api.AlignmentColsCollectionI;
+import jalview.api.AlignmentRowsCollectionI;
+import jalview.datamodel.AlignmentI;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.HiddenSequences;
 
 import java.awt.Graphics;
 
-public class OverviewDimensions
+public abstract class OverviewDimensions
 {
-  // Default width and height values
-  private static final int DEFAULT_GRAPH_HEIGHT = 20;
-
-  private static final int MAX_WIDTH = 400;
-
-  private static final int MIN_WIDTH = 120;
-
-  private static final int MIN_SEQ_HEIGHT = 40;
-
-  private static final int MAX_SEQ_HEIGHT = 300;
-
-  // width of the overview panel
-  private int width;
-
-  // height of sequences part of the overview panel
-  private int sequencesHeight;
-
-  // height of the graphs part of the overview panel
-  private int graphHeight = DEFAULT_GRAPH_HEIGHT;
-
-  // dimensions of box outlining current extent of view in alignment panel
-  // location of left side of box
-  private int boxX = -1;
-
-  // location of bottom of box
-  private int boxY = -1;
+  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;
 
-  // width of box
-  private int boxWidth = -1;
-
-  // height of box
-  private int boxHeight = -1;
-
-  // scroll position in viewport corresponding to boxX
-  private int scrollCol = -1;
+  private static final int DEFAULT_GRAPH_HEIGHT = 20;
 
-  // scroll position in viewport corresponding to boxY
-  private int scrollRow = -1;
+  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)
   {
@@ -111,159 +86,6 @@ public class OverviewDimensions
   }
 
   /**
-   * Check box dimensions and scroll positions and correct if necessary
-   * 
-   * @param mousex
-   *          x position in overview panel
-   * @param mousey
-   *          y position in overview panel
-   * @param hiddenSeqs
-   *          hidden sequences
-   * @param hiddenCols
-   *          hidden columns
-   * @param ranges
-   *          viewport position properties
-   */
-  public void updateViewportFromMouse(int mousex, int mousey,
-          HiddenSequences hiddenSeqs, HiddenColumns hiddenCols,
-          ViewportRanges ranges)
-  {
-    int x = mousex;
-    int y = mousey;
-
-    int alwidth = ranges.getAbsoluteAlignmentWidth();
-    int alheight = ranges.getAbsoluteAlignmentHeight();
-
-    if (x < 0)
-    {
-      x = 0;
-    }
-
-    if (y < 0)
-    {
-      y = 0;
-    }
-
-    //
-    // Convert x value to residue position
-    //
-
-    // need to determine where scrollCol should be, given x
-    // to do this also need to know width of viewport, and some hidden column
-    // correction
-
-    // convert x to residues - this is an absolute position
-    int xAsRes = Math.round((float) x * alwidth / width);
-
-    // get viewport width in residues
-    int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1;
-
-    // get where x should be when accounting for hidden cols
-    // if x is in a hidden col region, shift to left - but we still need
-    // absolute position
-    // so convert back after getting visible region position
-    int visXAsRes = hiddenCols.findColumnPosition(xAsRes);
-
-    // check in case we went off the edge of the alignment
-    int visAlignWidth = hiddenCols.findColumnPosition(alwidth - 1);
-    if (visXAsRes + vpwidth - 1 > visAlignWidth)
-    {
-      // went past the end of the alignment, adjust backwards
-
-      // if last position was before the end of the alignment, need to update
-      if ((scrollCol + vpwidth - 1) < visAlignWidth)
-      {
-        visXAsRes = hiddenCols.findColumnPosition(hiddenCols
-                .subtractVisibleColumns(vpwidth - 1, alwidth - 1));
-      }
-      else
-      {
-        visXAsRes = scrollCol;
-      }
-    }
-
-    //
-    // Convert y value to sequence position
-    //
-
-    // convert y to residues
-    int yAsSeq = Math.round((float) y * alheight / sequencesHeight);
-
-    // get viewport height in sequences
-    // add 1 because height includes both endSeq and startSeq
-    int vpheight = ranges.getEndSeq() - ranges.getStartSeq() + 1;
-
-    // get where y should be when accounting for hidden rows
-    // if y is in a hidden row region, shift up - but we still need absolute
-    // position,
-    // so convert back after getting visible region position
-    yAsSeq = hiddenSeqs.adjustForHiddenSeqs(hiddenSeqs
-            .findIndexWithoutHiddenSeqs(yAsSeq));
-
-    // check in case we went off the edge of the alignment
-    int visAlignHeight = hiddenSeqs.findIndexWithoutHiddenSeqs(alheight);
-    int visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq);
-    if (visYAsRes + vpheight - 1 > visAlignHeight)
-    {
-      // went past the end of the alignment, adjust backwards
-      if ((scrollRow + vpheight - 1) < visAlignHeight)
-      {
-        visYAsRes = hiddenSeqs.findIndexWithoutHiddenSeqs(hiddenSeqs
-                .subtractVisibleRows(vpheight - 1, alheight - 1));
-      }
-      else
-      {
-        visYAsRes = scrollRow;
-      }
-    }
-
-    // update scroll values
-    scrollCol = visXAsRes;
-    scrollRow = visYAsRes;
-
-  }
-
-  /**
-   * Update the overview panel box when the associated alignment panel is
-   * changed
-   * 
-   * @param hiddenSeqs
-   *          hidden sequences
-   * @param hiddenCols
-   *          hidden columns
-   * @param ranges
-   *          viewport position properties
-   */
-  public void setBoxPosition(HiddenSequences hiddenSeqs,
-          HiddenColumns hiddenCols, ViewportRanges ranges)
-  {
-    int alwidth = ranges.getAbsoluteAlignmentWidth();
-    int alheight = ranges.getAbsoluteAlignmentHeight();
-
-    // work with absolute values of startRes and endRes
-    int startRes = hiddenCols.adjustForHiddenColumns(ranges.getStartRes());
-    int endRes = hiddenCols.adjustForHiddenColumns(ranges.getEndRes());
-
-    // work with absolute values of startSeq and endSeq
-    int startSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getStartSeq());
-    int endSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.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);
-  }
-
-  /**
    * Draw the overview panel's viewport box on a graphics object
    * 
    * @param g
@@ -285,42 +107,26 @@ public class OverviewDimensions
     return scrollRow;
   }
 
-  // TODO should be removed, when unit test has mock Graphics object available
-  // to check boxX/boxY
   public int getBoxX()
   {
     return boxX;
   }
 
-  // TODO should be removed, when unit test has mock Graphics object available
-  // to check boxX/boxY
   public int getBoxY()
   {
     return boxY;
   }
 
-  // TODO should be removed, when unit test has mock Graphics object available
   public int getBoxWidth()
   {
     return boxWidth;
   }
 
-  // TODO should be removed, when unit test has mock Graphics object available
   public int getBoxHeight()
   {
     return boxHeight;
   }
 
-  public void setWidth(int w)
-  {
-    width = w;
-  }
-
-  public void setHeight(int h)
-  {
-    sequencesHeight = h - graphHeight;
-  }
-
   public int getWidth()
   {
     return width;
@@ -340,4 +146,94 @@ public class OverviewDimensions
   {
     return graphHeight;
   }
-}
+
+  public float getPixelsPerCol()
+  {
+    resetAlignmentDims();
+    return (float) width / alwidth;
+  }
+
+  public float getPixelsPerSeq()
+  {
+    resetAlignmentDims();
+    return (float) sequencesHeight / alheight;
+  }
+
+  public void setWidth(int w)
+  {
+    width = w;
+  }
+
+  public void setHeight(int h)
+  {
+    sequencesHeight = h - graphHeight;
+  }
+
+  /**
+   * Update the viewport location from a mouse click in the overview panel
+   * 
+   * @param mousex
+   *          x location of mouse
+   * @param mousey
+   *          y location of mouse
+   * @param hiddenSeqs
+   *          the alignment's hidden sequences
+   * @param hiddenCols
+   *          the alignment's hidden columns
+   */
+  public abstract void updateViewportFromMouse(int mousex, int mousey,
+          HiddenSequences hiddenSeqs, HiddenColumns hiddenCols);
+
+  /**
+   * Set the overview panel's box position to match the viewport
+   * 
+   * @param hiddenSeqs
+   *          the alignment's hidden sequences
+   * @param hiddenCols
+   *          the alignment's hidden columns
+   */
+  public abstract void setBoxPosition(HiddenSequences hiddenSeqs,
+          HiddenColumns hiddenCols);
+
+  /**
+   * Get the collection of columns used by this overview dimensions object
+   * 
+   * @param hiddenCols
+   *          the alignment's hidden columns
+   * @return a column collection
+   */
+  public abstract AlignmentColsCollectionI getColumns(AlignmentI al);
+
+  /**
+   * Get the collection of rows used by this overview dimensions object
+   * 
+   * @param al
+   *          the alignment
+   * @return a row collection
+   */
+  public abstract AlignmentRowsCollectionI getRows(AlignmentI al);
+
+  /**
+   * Updates overview dimensions to account for current alignment dimensions
+   */
+  protected abstract void resetAlignmentDims();
+
+  protected void setBoxPosition(int startRes, int endRes, int startSeq,
+          int endSeq)
+  {
+    resetAlignmentDims();
+
+    // 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);
+  }
+}
\ No newline at end of file
diff --git a/src/jalview/viewmodel/OverviewDimensionsHideHidden.java b/src/jalview/viewmodel/OverviewDimensionsHideHidden.java
new file mode 100644 (file)
index 0000000..b03f9ac
--- /dev/null
@@ -0,0 +1,137 @@
+package jalview.viewmodel;
+
+import jalview.api.AlignmentColsCollectionI;
+import jalview.api.AlignmentRowsCollectionI;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.HiddenSequences;
+import jalview.datamodel.VisibleColsCollection;
+import jalview.datamodel.VisibleRowsCollection;
+
+public class OverviewDimensionsHideHidden extends OverviewDimensions
+{
+  private ViewportRanges ranges;
+
+  public OverviewDimensionsHideHidden(ViewportRanges vpranges,
+          boolean showAnnotationPanel)
+  {
+    super(vpranges, showAnnotationPanel);
+    ranges = vpranges;
+    resetAlignmentDims();
+  }
+
+  @Override
+  public void updateViewportFromMouse(int mousex, int mousey,
+          HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
+  {
+    resetAlignmentDims();
+
+    int x = mousex;
+    int y = mousey;
+
+    if (x < 0)
+    {
+      x = 0;
+    }
+
+    if (y < 0)
+    {
+      y = 0;
+    }
+
+    //
+    // Convert x value to residue position
+    //
+
+    // need to determine where scrollCol should be, given x
+    // to do this also need to know width of viewport, and some hidden column
+    // correction
+
+    // convert x to residues - this is an absolute position
+    int xAsRes = Math.round((float) x * alwidth / width);
+
+    // get viewport width in residues
+    int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1;
+
+    if (xAsRes + vpwidth > alwidth)
+    {
+      // went past the end of the alignment, adjust backwards
+
+      // if last position was before the end of the alignment, need to update
+      if ((scrollCol + vpwidth - 1) < alwidth)
+      {
+        xAsRes = alwidth - vpwidth;
+      }
+      else
+      {
+        xAsRes = scrollCol;
+      }
+    }
+
+
+    //
+    // Convert y value to sequence position
+    //
+
+    // convert y to residues
+    int yAsSeq = Math.round((float) y * alheight / sequencesHeight);
+
+    // get viewport height in sequences
+    // add 1 because height includes both endSeq and startSeq
+    int vpheight = ranges.getEndSeq() - ranges.getStartSeq() + 1;
+
+    if (yAsSeq + vpheight > alheight)
+    {
+      // went past the end of the alignment, adjust backwards
+      if ((scrollRow + vpheight - 1) < alheight)
+      {
+        yAsSeq = alheight - vpheight;
+      }
+      else
+      {
+        yAsSeq = scrollRow;
+      }
+    }
+
+    // update scroll values
+    scrollCol = xAsRes;
+    scrollRow = yAsSeq;
+
+  }
+
+  @Override
+  public void setBoxPosition(HiddenSequences hiddenSeqs,
+          HiddenColumns hiddenCols)
+  {
+    // work with visible values of startRes and endRes
+    int startRes = ranges.getStartRes();
+    int endRes = ranges.getEndRes();
+
+    // work with visible values of startSeq and endSeq
+    int startSeq = ranges.getStartSeq();
+    int endSeq = ranges.getEndSeq();
+
+    setBoxPosition(startRes, endRes, startSeq, endSeq);
+  }
+
+  @Override
+  public AlignmentColsCollectionI getColumns(AlignmentI al)
+  {
+    return new VisibleColsCollection(0,
+            ranges.getAbsoluteAlignmentWidth() - 1, al);
+  }
+
+  @Override
+  public AlignmentRowsCollectionI getRows(AlignmentI al)
+  {
+    return new VisibleRowsCollection(0,
+            ranges.getAbsoluteAlignmentHeight() - 1, al);
+  }
+
+  @Override
+  protected void resetAlignmentDims()
+  {
+    alwidth = ranges.getVisibleAlignmentWidth();
+    alheight = ranges.getVisibleAlignmentHeight();
+  }
+}
diff --git a/src/jalview/viewmodel/OverviewDimensionsShowHidden.java b/src/jalview/viewmodel/OverviewDimensionsShowHidden.java
new file mode 100644 (file)
index 0000000..b897189
--- /dev/null
@@ -0,0 +1,211 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.viewmodel;
+
+import jalview.api.AlignmentColsCollectionI;
+import jalview.api.AlignmentRowsCollectionI;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.AllColsCollection;
+import jalview.datamodel.AllRowsCollection;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.HiddenSequences;
+
+public class OverviewDimensionsShowHidden extends OverviewDimensions
+{
+  private ViewportRanges ranges;
+
+  /**
+   * 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 OverviewDimensionsShowHidden(ViewportRanges vpranges,
+          boolean showAnnotationPanel)
+  {
+    super(vpranges, showAnnotationPanel);
+    ranges = vpranges;
+    resetAlignmentDims();
+  }
+
+  /**
+   * Check box dimensions and scroll positions and correct if necessary
+   * 
+   * @param mousex
+   *          x position in overview panel
+   * @param mousey
+   *          y position in overview panel
+   * @param hiddenSeqs
+   *          hidden sequences
+   * @param hiddenCols
+   *          hidden columns
+   * @param ranges
+   *          viewport position properties
+   */
+  @Override
+  public void updateViewportFromMouse(int mousex, int mousey,
+          HiddenSequences hiddenSeqs, HiddenColumns hiddenCols)
+  {
+    int x = mousex;
+    int y = mousey;
+
+    resetAlignmentDims();
+
+    if (x < 0)
+    {
+      x = 0;
+    }
+
+    if (y < 0)
+    {
+      y = 0;
+    }
+
+    //
+    // Convert x value to residue position
+    //
+
+    // need to determine where scrollCol should be, given x
+    // to do this also need to know width of viewport, and some hidden column
+    // correction
+
+    // convert x to residues - this is an absolute position
+    int xAsRes = Math.round((float) x * alwidth / width);
+
+    // get viewport width in residues
+    int vpwidth = ranges.getEndRes() - ranges.getStartRes() + 1;
+
+    // get where x should be when accounting for hidden cols
+    // if x is in a hidden col region, shift to left - but we still need
+    // absolute position
+    // so convert back after getting visible region position
+    int visXAsRes = hiddenCols.findColumnPosition(xAsRes);
+
+    // check in case we went off the edge of the alignment
+    int visAlignWidth = hiddenCols.findColumnPosition(alwidth - 1);
+    if (visXAsRes + vpwidth - 1 > visAlignWidth)
+    {
+      // went past the end of the alignment, adjust backwards
+
+      // if last position was before the end of the alignment, need to update
+      if ((scrollCol + vpwidth - 1) < visAlignWidth)
+      {
+        visXAsRes = hiddenCols.findColumnPosition(hiddenCols
+                .subtractVisibleColumns(vpwidth - 1, alwidth - 1));
+      }
+      else
+      {
+        visXAsRes = scrollCol;
+      }
+    }
+
+    //
+    // Convert y value to sequence position
+    //
+
+    // convert y to residues
+    int yAsSeq = Math.round((float) y * alheight / sequencesHeight);
+
+    // get viewport height in sequences
+    // add 1 because height includes both endSeq and startSeq
+    int vpheight = ranges.getEndSeq() - ranges.getStartSeq() + 1;
+
+    // get where y should be when accounting for hidden rows
+    // if y is in a hidden row region, shift up - but we still need absolute
+    // position,
+    // so convert back after getting visible region position
+    yAsSeq = hiddenSeqs.adjustForHiddenSeqs(hiddenSeqs
+            .findIndexWithoutHiddenSeqs(yAsSeq));
+
+    // check in case we went off the edge of the alignment
+    int visAlignHeight = hiddenSeqs.findIndexWithoutHiddenSeqs(alheight);
+    int visYAsSeq = hiddenSeqs.findIndexWithoutHiddenSeqs(yAsSeq);
+    if (visYAsSeq + vpheight - 1 > visAlignHeight)
+    {
+      // went past the end of the alignment, adjust backwards
+      if ((scrollRow + vpheight - 1) < visAlignHeight)
+      {
+        visYAsSeq = hiddenSeqs.findIndexWithoutHiddenSeqs(hiddenSeqs
+                .subtractVisibleRows(vpheight - 1, alheight - 1));
+      }
+      else
+      {
+        visYAsSeq = scrollRow;
+      }
+    }
+
+    // update scroll values
+    scrollCol = visXAsRes;
+    scrollRow = visYAsSeq;
+
+  }
+
+  /**
+   * Update the overview panel box when the associated alignment panel is
+   * changed
+   * 
+   * @param hiddenSeqs
+   *          hidden sequences
+   * @param hiddenCols
+   *          hidden columns
+   * @param ranges
+   *          viewport position properties
+   */
+  @Override
+  public void setBoxPosition(HiddenSequences hiddenSeqs,
+          HiddenColumns hiddenCols)
+  {
+    // work with absolute values of startRes and endRes
+    int startRes = hiddenCols
+            .adjustForHiddenColumns(ranges.getStartRes());
+    int endRes = hiddenCols.adjustForHiddenColumns(ranges.getEndRes());
+
+    // work with absolute values of startSeq and endSeq
+    int startSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getStartSeq());
+    int endSeq = hiddenSeqs.adjustForHiddenSeqs(ranges.getEndSeq());
+
+    setBoxPosition(startRes, endRes, startSeq, endSeq);
+  }
+
+  @Override
+  public AlignmentColsCollectionI getColumns(AlignmentI al)
+  {
+    return new AllColsCollection(0,
+            ranges.getAbsoluteAlignmentWidth() - 1, al);
+  }
+
+  @Override
+  public AlignmentRowsCollectionI getRows(AlignmentI al)
+  {
+    return new AllRowsCollection(0,
+            ranges.getAbsoluteAlignmentHeight() - 1,
+            al);
+  }
+
+  @Override
+  protected void resetAlignmentDims()
+  {
+    alwidth = ranges.getAbsoluteAlignmentWidth();
+    alheight = ranges.getAbsoluteAlignmentHeight();
+  }
+}
index c91d2d9..fc163e0 100644 (file)
@@ -79,6 +79,22 @@ public class ViewportRanges extends ViewportProperties
   }
 
   /**
+   * Get alignment width in cols, excluding hidden cols
+   */
+  public int getVisibleAlignmentWidth()
+  {
+    return al.getWidth() - al.getHiddenColumns().getSize();
+  }
+
+  /**
+   * Get alignment height in rows, excluding hidden rows
+   */
+  public int getVisibleAlignmentHeight()
+  {
+    return al.getHeight();
+  }
+
+  /**
    * Set first residue visible in the viewport
    * 
    * @param res
diff --git a/test/jalview/datamodel/AllColsIteratorTest.java b/test/jalview/datamodel/AllColsIteratorTest.java
new file mode 100644 (file)
index 0000000..fbb20be
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.datamodel;
+
+import static org.testng.Assert.assertTrue;
+
+import java.util.NoSuchElementException;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class AllColsIteratorTest
+{
+  HiddenColumns hiddenCols;
+  
+  @BeforeClass
+  public void setup()
+  {
+    hiddenCols = new HiddenColumns();
+   hiddenCols.hideColumns(2,4);
+  }
+  
+
+  /*
+   * Test iterator iterates through collection correctly
+   */
+  @Test(groups = { "Functional" })
+  public void testHasNextAndNext()
+  {
+    AllColsIterator it = new AllColsIterator(0, 3, hiddenCols);
+    int count = 0;
+    while (it.hasNext())
+    {
+      it.next();
+      count++;
+    }
+    assertTrue(count == 4, "hasNext() is false after 4 iterations");
+  }
+
+  /*
+   * Test iterator throws NoSuchElementException at end of iteration
+   */
+  @Test(
+    groups = { "Functional" },
+    expectedExceptions = { NoSuchElementException.class })
+  public void testLastNext() throws NoSuchElementException
+  {
+    AllColsIterator it = new AllColsIterator(0, 3, hiddenCols);
+    while (it.hasNext())
+    {
+      it.next();
+    }
+    it.next();
+  }
+
+  /*
+   * Test iterator throws UnsupportedOperationException on call to remove
+   */
+  @Test(
+    groups = { "Functional" },
+    expectedExceptions = { UnsupportedOperationException.class })
+  public void testRemove() throws UnsupportedOperationException
+  {
+    AllColsIterator it = new AllColsIterator(0, 3, hiddenCols);
+    it.remove();
+  }
+}
diff --git a/test/jalview/datamodel/AllRowsIteratorTest.java b/test/jalview/datamodel/AllRowsIteratorTest.java
new file mode 100644 (file)
index 0000000..fd1d29d
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.datamodel;
+
+import static org.testng.Assert.assertTrue;
+
+import jalview.analysis.AlignmentGenerator;
+
+import java.util.Hashtable;
+import java.util.NoSuchElementException;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class AllRowsIteratorTest
+{
+  AlignmentI al;
+
+  Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences = new Hashtable<SequenceI, SequenceCollectionI>();
+
+  @BeforeClass
+  public void setup()
+  {
+    // create random alignment
+    AlignmentGenerator gen = new AlignmentGenerator(false);
+    al = gen.generate(20, 15, 123, 5, 5);
+    if (!hiddenRepSequences.isEmpty())
+    {
+      al.getHiddenSequences().showAll(hiddenRepSequences);
+    }
+    hideSequences(2, 4);
+  }
+
+  /*
+   * Test iterator iterates through collection correctly
+   */
+  @Test(groups = { "Functional" })
+  public void testHasNextAndNext()
+  {
+    AllRowsIterator it = new AllRowsIterator(0, 3, al);
+    int count = 0;
+    while (it.hasNext())
+    {
+      it.next();
+      count++;
+    }
+    assertTrue(count == 4, "hasNext() is false after 4 iterations");
+  }
+
+  /*
+   * Test iterator throws NoSuchElementException at end of iteration
+   */
+  @Test(
+    groups = { "Functional" },
+    expectedExceptions = { NoSuchElementException.class })
+  public void testLastNext() throws NoSuchElementException
+  {
+    AllRowsIterator it = new AllRowsIterator(0, 3, al);
+    while (it.hasNext())
+    {
+      it.next();
+    }
+    it.next();
+  }
+
+  /*
+   * Test iterator throws UnsupportedOperationException on call to remove
+   */
+  @Test(
+    groups = { "Functional" },
+    expectedExceptions = { UnsupportedOperationException.class })
+  public void testRemove() throws UnsupportedOperationException
+  {
+    AllRowsIterator it = new AllRowsIterator(0, 3, al);
+    it.remove();
+  }
+
+
+  /*
+   * Hide sequences between start and end
+   */
+  private void hideSequences(int start, int end)
+  {
+    SequenceI[] allseqs = al.getSequencesArray();
+    SequenceGroup theseSeqs = new SequenceGroup();
+
+    for (int i = start; i <= end; i++)
+    {
+      theseSeqs.addSequence(allseqs[i], false);
+      al.getHiddenSequences().hideSequence(allseqs[i]);
+    }
+
+    hiddenRepSequences.put(allseqs[start], theseSeqs);
+  }
+}
index ce2949f..7237e63 100644 (file)
@@ -132,7 +132,7 @@ public class ColumnSelectionTest
     // hide column 5 (and adjacent):
     cs.hideSelectedColumns(5, al.getHiddenColumns());
     // 4,5,6 now hidden:
-    List<int[]> hidden = al.getHiddenColumns().getListOfCols();
+    List<int[]> hidden = al.getHiddenColumns().getHiddenRegions();
     assertEquals(1, hidden.size());
     assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
     // none now selected:
@@ -145,7 +145,7 @@ public class ColumnSelectionTest
     cs.addElement(5);
     cs.addElement(6);
     cs.hideSelectedColumns(4, al.getHiddenColumns());
-    hidden = al.getHiddenColumns().getListOfCols();
+    hidden = al.getHiddenColumns().getHiddenRegions();
     assertEquals(1, hidden.size());
     assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
     assertTrue(cs.getSelected().isEmpty());
@@ -157,7 +157,7 @@ public class ColumnSelectionTest
     cs.addElement(5);
     cs.addElement(6);
     cs.hideSelectedColumns(6, al.getHiddenColumns());
-    hidden = al.getHiddenColumns().getListOfCols();
+    hidden = al.getHiddenColumns().getHiddenRegions();
     assertEquals(1, hidden.size());
     assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
     assertTrue(cs.getSelected().isEmpty());
@@ -168,7 +168,7 @@ public class ColumnSelectionTest
     cs.addElement(4);
     cs.addElement(6);
     cs.hideSelectedColumns(5, al.getHiddenColumns());
-    hidden = al.getHiddenColumns().getListOfCols();
+    hidden = al.getHiddenColumns().getHiddenRegions();
     assertEquals(1, hidden.size());
     assertEquals("[4, 6]", Arrays.toString(hidden.get(0)));
     assertTrue(cs.getSelected().isEmpty());
@@ -196,7 +196,7 @@ public class ColumnSelectionTest
 
     cs.hideSelectedColumns(al);
     assertTrue(cs.getSelected().isEmpty());
-    List<int[]> hidden = cols.getListOfCols();
+    List<int[]> hidden = cols.getHiddenRegions();
     assertEquals(4, hidden.size());
     assertEquals("[2, 4]", Arrays.toString(hidden.get(0)));
     assertEquals("[7, 9]", Arrays.toString(hidden.get(1)));
index 5eaecd3..b767cf7 100644 (file)
@@ -45,6 +45,29 @@ public class HiddenColumnsTest
   }
 
   /**
+   * Test the method which counts the number of hidden columns
+   */
+  @Test(groups = { "Functional" })
+  public void testGetSize()
+  {
+    HiddenColumns hidden = new HiddenColumns();
+    assertEquals(0, hidden.getSize());
+
+    hidden.hideColumns(3, 5);
+    assertEquals(3, hidden.getSize());
+
+    hidden.hideColumns(8, 8);
+    assertEquals(4, hidden.getSize());
+
+    hidden.hideColumns(9, 14);
+    assertEquals(10, hidden.getSize());
+
+    ColumnSelection cs = new ColumnSelection();
+    hidden.revealAllHiddenColumns(cs);
+    assertEquals(0, hidden.getSize());
+  }
+
+  /**
    * Test the method that finds the visible column position of an alignment
    * column, allowing for hidden columns.
    */
@@ -207,14 +230,14 @@ public class HiddenColumnsTest
     HiddenColumns cs = new HiddenColumns();
     cs.hideColumns(10, 11);
     cs.hideColumns(5, 7);
-    assertEquals("[5, 7]", Arrays.toString(cs.getListOfCols().get(0)));
+    assertEquals("[5, 7]", Arrays.toString(cs.getHiddenRegions().get(0)));
 
     HiddenColumns cs2 = new HiddenColumns(cs);
     assertTrue(cs2.hasHiddenColumns());
-    assertEquals(2, cs2.getListOfCols().size());
+    assertEquals(2, cs2.getHiddenRegions().size());
     // hidden columns are held in column order
-    assertEquals("[5, 7]", Arrays.toString(cs2.getListOfCols().get(0)));
-    assertEquals("[10, 11]", Arrays.toString(cs2.getListOfCols().get(1)));
+    assertEquals("[5, 7]", Arrays.toString(cs2.getHiddenRegions().get(0)));
+    assertEquals("[10, 11]", Arrays.toString(cs2.getHiddenRegions().get(1)));
   }
 
   /**
@@ -311,51 +334,51 @@ public class HiddenColumnsTest
     ColumnSelection colsel = new ColumnSelection();
     HiddenColumns cs = al.getHiddenColumns();
     colsel.hideSelectedColumns(5, al.getHiddenColumns());
-    List<int[]> hidden = cs.getListOfCols();
+    List<int[]> hidden = cs.getHiddenRegions();
     assertEquals(1, hidden.size());
     assertEquals("[5, 5]", Arrays.toString(hidden.get(0)));
 
     colsel.hideSelectedColumns(3, al.getHiddenColumns());
     assertEquals(2, hidden.size());
     // two hidden ranges, in order:
-    assertSame(hidden, cs.getListOfCols());
+    assertSame(hidden, cs.getHiddenRegions());
     assertEquals("[3, 3]", Arrays.toString(hidden.get(0)));
     assertEquals("[5, 5]", Arrays.toString(hidden.get(1)));
 
     // hiding column 4 expands [3, 3] to [3, 4]
     // and merges to [5, 5] to make [3, 5]
     colsel.hideSelectedColumns(4, al.getHiddenColumns());
-    hidden = cs.getListOfCols();
+    hidden = cs.getHiddenRegions();
     assertEquals(1, hidden.size());
     assertEquals("[3, 5]", Arrays.toString(hidden.get(0)));
 
     // clear hidden columns (note they are added to selected)
     cs.revealAllHiddenColumns(colsel);
     // it is now actually null but getter returns an empty list
-    assertTrue(cs.getListOfCols().isEmpty());
+    assertTrue(cs.getHiddenRegions().isEmpty());
 
     cs.hideColumns(3, 6);
-    hidden = cs.getListOfCols();
+    hidden = cs.getHiddenRegions();
     int[] firstHiddenRange = hidden.get(0);
     assertEquals("[3, 6]", Arrays.toString(firstHiddenRange));
 
     // adding a subrange of already hidden should do nothing
     cs.hideColumns(4, 5);
     assertEquals(1, hidden.size());
-    assertSame(firstHiddenRange, cs.getListOfCols().get(0));
+    assertSame(firstHiddenRange, cs.getHiddenRegions().get(0));
     cs.hideColumns(3, 5);
     assertEquals(1, hidden.size());
-    assertSame(firstHiddenRange, cs.getListOfCols().get(0));
+    assertSame(firstHiddenRange, cs.getHiddenRegions().get(0));
     cs.hideColumns(4, 6);
     assertEquals(1, hidden.size());
-    assertSame(firstHiddenRange, cs.getListOfCols().get(0));
+    assertSame(firstHiddenRange, cs.getHiddenRegions().get(0));
     cs.hideColumns(3, 6);
     assertEquals(1, hidden.size());
-    assertSame(firstHiddenRange, cs.getListOfCols().get(0));
+    assertSame(firstHiddenRange, cs.getHiddenRegions().get(0));
 
     cs.revealAllHiddenColumns(colsel);
     cs.hideColumns(2, 4);
-    hidden = cs.getListOfCols();
+    hidden = cs.getHiddenRegions();
     assertEquals(1, hidden.size());
     assertEquals("[2, 4]", Arrays.toString(hidden.get(0)));
 
@@ -388,7 +411,7 @@ public class HiddenColumnsTest
     colsel.addElement(10);
     cs.revealHiddenColumns(5, colsel);
     // hidden columns list now null but getter returns empty list:
-    assertTrue(cs.getListOfCols().isEmpty());
+    assertTrue(cs.getHiddenRegions().isEmpty());
     // revealed columns are marked as selected (added to selection):
     assertEquals("[10, 5, 6, 7, 8]", colsel.getSelected().toString());
 
@@ -396,9 +419,9 @@ public class HiddenColumnsTest
     colsel = new ColumnSelection();
     cs = new HiddenColumns();
     cs.hideColumns(5, 8);
-    List<int[]> hidden = cs.getListOfCols();
+    List<int[]> hidden = cs.getHiddenRegions();
     cs.revealHiddenColumns(6, colsel);
-    assertSame(hidden, cs.getListOfCols());
+    assertSame(hidden, cs.getHiddenRegions());
     assertTrue(colsel.getSelected().isEmpty());
   }
 
@@ -417,7 +440,7 @@ public class HiddenColumnsTest
      * revealing hidden columns adds them (in order) to the (unordered)
      * selection list
      */
-    assertTrue(cs.getListOfCols().isEmpty());
+    assertTrue(cs.getHiddenRegions().isEmpty());
     assertEquals("[11, 1, 2, 3, 5, 6, 7, 8]", colsel.getSelected()
             .toString());
   }
@@ -453,13 +476,13 @@ public class HiddenColumnsTest
     HiddenColumns cs = new HiddenColumns();
     cs.hideColumns(49, 59);
     cs.hideColumns(69, 79);
-    List<int[]> hidden = cs.getListOfCols();
+    List<int[]> hidden = cs.getHiddenRegions();
     assertEquals(2, hidden.size());
     assertEquals("[49, 59]", Arrays.toString(hidden.get(0)));
     assertEquals("[69, 79]", Arrays.toString(hidden.get(1)));
 
     cs.hideColumns(48, 80);
-    hidden = cs.getListOfCols();
+    hidden = cs.getHiddenRegions();
     assertEquals(1, hidden.size());
     assertEquals("[48, 80]", Arrays.toString(hidden.get(0)));
 
@@ -472,7 +495,7 @@ public class HiddenColumnsTest
     cs.hideColumns(50, 60);
     // hiding 21-49 should merge to one range
     cs.hideColumns(21, 49);
-    hidden = cs.getListOfCols();
+    hidden = cs.getHiddenRegions();
     assertEquals(1, hidden.size());
     assertEquals("[10, 60]", Arrays.toString(hidden.get(0)));
 
@@ -488,7 +511,7 @@ public class HiddenColumnsTest
     cs.hideColumns(60, 70);
 
     cs.hideColumns(15, 45);
-    hidden = cs.getListOfCols();
+    hidden = cs.getHiddenRegions();
     assertEquals(2, hidden.size());
     assertEquals("[10, 50]", Arrays.toString(hidden.get(0)));
     assertEquals("[60, 70]", Arrays.toString(hidden.get(1)));
diff --git a/test/jalview/datamodel/VisibleColsIteratorTest.java b/test/jalview/datamodel/VisibleColsIteratorTest.java
new file mode 100644 (file)
index 0000000..b2d747b
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.datamodel;
+
+import static org.testng.Assert.assertTrue;
+
+import java.util.NoSuchElementException;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class VisibleColsIteratorTest
+{
+  HiddenColumns hiddenCols;
+
+  HiddenColumns hiddenColsAtStart;
+
+  @BeforeClass(groups = { "Functional" })
+  public void setup()
+  {
+    hiddenCols = new HiddenColumns();
+    hiddenCols.hideColumns(2, 4);
+
+    hiddenColsAtStart = new HiddenColumns();
+    hiddenColsAtStart.hideColumns(0, 2);
+  }
+
+  /*
+   * Test iterator iterates correctly through the columns
+   * when alignment has hidden cols
+   */
+  @Test(groups = { "Functional" })
+  public void testHasNextAndNextWithHidden()
+  {
+    VisibleColsIterator it = new VisibleColsIterator(0, 6, hiddenCols);
+    int count = 0;
+    while (it.hasNext())
+    {
+      it.next();
+      count++;
+    }
+    assertTrue(count == 4, "hasNext() is false after 4 iterations");
+  }
+
+  /*
+   * Test iterator iterates correctly through the columns
+   * when alignment has no hidden cols
+   */
+  @Test(groups = { "Functional" })
+  public void testHasNextAndNextNoHidden()
+  {
+    VisibleColsIterator it2 = new VisibleColsIterator(0, 3,
+            new HiddenColumns());
+    int count = 0;
+    while (it2.hasNext())
+    {
+      it2.next();
+      count++;
+    }
+    assertTrue(count == 4, "hasNext() is false after 4 iterations");
+  }
+
+  /*
+   * Test iterator iterates correctly through the columns
+   * when alignment has hidden cols at start
+   */
+  @Test(groups = { "Functional" })
+  public void testHasNextAndNextStartHidden()
+  {
+    VisibleColsIterator it3 = new VisibleColsIterator(0, 6,
+            hiddenColsAtStart);
+    int count = 0;
+    while (it3.hasNext())
+    {
+      it3.next();
+      count++;
+    }
+    assertTrue(count == 4, "hasNext() is false after 4 iterations");
+  }
+
+  /*
+   * Test iterator iterates correctly through the columns
+   * when alignment has hidden cols at end
+   */
+  @Test(groups = { "Functional" })
+  public void testHasNextAndNextEndHidden()
+  {
+    VisibleColsIterator it4 = new VisibleColsIterator(0, 4, hiddenCols);
+    int count = 0;
+    while (it4.hasNext())
+    {
+      it4.next();
+      count++;
+    }
+    assertTrue(count == 2, "hasNext() is false after 2 iterations");
+
+  }
+
+  /*
+   * Test iterator always throws NoSuchElementException at end of iteration
+   * when alignment has hidden cols
+   */
+  @Test(
+    groups = { "Functional" },
+    expectedExceptions = { NoSuchElementException.class })
+  public void testLastNextWithHidden() throws NoSuchElementException
+  {
+    VisibleColsIterator it = new VisibleColsIterator(0, 3, hiddenCols);
+    while (it.hasNext())
+    {
+      it.next();
+    }
+    it.next();
+  }
+
+  /*
+   * Test iterator always throws NoSuchElementException at end of iteration
+   * when alignment has no hidden cols
+   */
+  @Test(
+    groups = { "Functional" },
+    expectedExceptions = { NoSuchElementException.class })
+  public void testLastNextNoHidden() throws NoSuchElementException
+  {
+    VisibleColsIterator it2 = new VisibleColsIterator(0, 3,
+            new HiddenColumns());
+    while (it2.hasNext())
+    {
+      it2.next();
+    }
+    it2.next();
+  }
+
+  /*
+   * Test iterator always throws NoSuchElementException at end of iteration
+   * when alignment has hidden cols at start
+   */
+  @Test(
+    groups = { "Functional" },
+    expectedExceptions = { NoSuchElementException.class })
+  public void testLastNextStartHidden() throws NoSuchElementException
+  {
+    VisibleColsIterator it3 = new VisibleColsIterator(0, 6,
+            hiddenColsAtStart);
+    while (it3.hasNext())
+    {
+      it3.next();
+    }
+    it3.next();
+  }
+
+  /*
+   * Test iterator always throws NoSuchElementException at end of iteration
+   * when alignment has hidden cols at end
+   */
+  @Test(
+    groups = { "Functional" },
+    expectedExceptions = { NoSuchElementException.class })
+  public void testLastNextEndHidden() throws NoSuchElementException
+  {
+    VisibleColsIterator it4 = new VisibleColsIterator(0, 4, hiddenCols);
+    while (it4.hasNext())
+    {
+      it4.next();
+    }
+    it4.next();
+  }
+
+  /*
+   * Test calls to remove throw UnsupportedOperationException
+   */
+  @Test(
+    groups = { "Functional" },
+    expectedExceptions = { UnsupportedOperationException.class })
+  public void testRemove() throws UnsupportedOperationException
+  {
+    VisibleColsIterator it = new VisibleColsIterator(0, 3, hiddenCols);
+    it.remove();
+  }
+}
diff --git a/test/jalview/datamodel/VisibleRowsIteratorTest.java b/test/jalview/datamodel/VisibleRowsIteratorTest.java
new file mode 100644 (file)
index 0000000..4a021c5
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.datamodel;
+
+import static org.testng.Assert.assertTrue;
+
+import jalview.analysis.AlignmentGenerator;
+
+import java.util.Hashtable;
+import java.util.NoSuchElementException;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class VisibleRowsIteratorTest
+{
+  AlignmentI al;
+
+  AlignmentI al2;
+
+  AlignmentI al3;
+
+  Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences = new Hashtable<SequenceI, SequenceCollectionI>();
+
+  Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences2 = new Hashtable<SequenceI, SequenceCollectionI>();
+
+  @BeforeClass(groups = { "Functional" })
+  public void setup()
+  {
+    // create random alignment
+    AlignmentGenerator gen = new AlignmentGenerator(false);
+    al = gen.generate(20, 15, 123, 5, 5);
+    if (!hiddenRepSequences.isEmpty())
+    {
+      al.getHiddenSequences().showAll(hiddenRepSequences);
+    }
+    hideSequences(al, hiddenRepSequences, 2, 4);
+
+    al2 = gen.generate(20, 15, 123, 5, 5);
+    if (!hiddenRepSequences2.isEmpty())
+    {
+      al2.getHiddenSequences().showAll(hiddenRepSequences2);
+    }
+    hideSequences(al2, hiddenRepSequences2, 0, 2);
+
+    al3 = gen.generate(20, 15, 123, 5, 5);
+  }
+
+  /*
+   * Test iterator iterates correctly through the rows
+   * when alignment has hidden rows
+   */
+  @Test(groups = { "Functional" })
+  public void testHasNextAndNextWithHidden()
+  {
+    VisibleRowsIterator it = new VisibleRowsIterator(0, 6, al);
+    int count = 0;
+    while (it.hasNext())
+    {
+      it.next();
+      count++;
+    }
+    assertTrue(count == 4, "hasNext() is false after 4 iterations");
+  }
+
+  /*
+   * Test iterator iterates correctly through the rows
+   * when alignment has no hidden rows
+   */
+  @Test(groups = { "Functional" })
+  public void testHasNextAndNextNoHidden()
+  {
+    VisibleRowsIterator it = new VisibleRowsIterator(0, 3, al3);
+    int count = 0;
+    while (it.hasNext())
+    {
+      it.next();
+      count++;
+    }
+    assertTrue(count == 4, "hasNext() is false after 4 iterations");
+  }
+
+  /*
+   * Test iterator iterates correctly through the rows
+   * when alignment has hidden rows at start
+   */
+  @Test(groups = { "Functional" })
+  public void testHasNextAndNextStartHidden()
+  {
+    VisibleRowsIterator it = new VisibleRowsIterator(0, 6, al2);
+    int count = 0;
+    while (it.hasNext())
+    {
+      it.next();
+      count++;
+    }
+    assertTrue(count == 4, "hasNext() is false after 4 iterations");
+  }
+
+  /*
+   * Test iterator iterates correctly through the rows
+   * when alignment has hidden rows at end
+   */
+  @Test(groups = { "Functional" })
+  public void testHasNextAndNextEndHidden()
+  {
+    VisibleRowsIterator it = new VisibleRowsIterator(0, 4, al);
+    int count = 0;
+    while (it.hasNext())
+    {
+      it.next();
+      count++;
+    }
+    assertTrue(count == 2, "hasNext() is false after 2 iterations");
+  }
+
+  /*
+   * Test iterator always throws NoSuchElementException at end of iteration
+   * when alignment has hidden rows
+   */
+  @Test(
+    groups = { "Functional" },
+    expectedExceptions = { NoSuchElementException.class })
+  public void testLastNextWithHidden() throws NoSuchElementException
+  {
+    VisibleRowsIterator it = new VisibleRowsIterator(0, 3, al);
+    while (it.hasNext())
+    {
+      it.next();
+    }
+    it.next();
+  }
+
+  /*
+   * Test iterator always throws NoSuchElementException at end of iteration
+   * when alignment has no hidden rows
+   */
+  @Test(
+    groups = { "Functional" },
+    expectedExceptions = { NoSuchElementException.class })
+  public void testLastNextNoHidden() throws NoSuchElementException
+  {
+    VisibleRowsIterator it = new VisibleRowsIterator(0, 3, al3);
+    while (it.hasNext())
+    {
+      it.next();
+    }
+    it.next();
+  }
+
+  /*
+   * Test iterator always throws NoSuchElementException at end of iteration
+   * when alignment has hidden rows at start
+   */
+  @Test(
+    groups = { "Functional" },
+    expectedExceptions = { NoSuchElementException.class })
+  public void testLastNextStartHidden() throws NoSuchElementException
+  {
+    VisibleRowsIterator it = new VisibleRowsIterator(0, 3, al2);
+    while (it.hasNext())
+    {
+      it.next();
+    }
+    it.next();
+  }
+
+  /*
+   * Test iterator always throws NoSuchElementException at end of iteration
+   * when alignment has hidden rows at end
+   */
+  @Test(
+    groups = { "Functional" },
+    expectedExceptions = { NoSuchElementException.class })
+  public void testLastNextEndHidden() throws NoSuchElementException
+  {
+    VisibleRowsIterator it = new VisibleRowsIterator(0, 4, al);
+    while (it.hasNext())
+    {
+      it.next();
+    }
+    it.next();
+  }
+
+  /*
+   * Test calls to remove throw UnsupportedOperationException
+   */
+  @Test(
+    groups = { "Functional" },
+    expectedExceptions = { UnsupportedOperationException.class })
+  public void testRemove() throws UnsupportedOperationException
+  {
+    VisibleRowsIterator it = new VisibleRowsIterator(0, 3, al);
+    it.remove();
+  }
+
+  /*
+   * Hide sequences between start and end
+   */
+  private void hideSequences(AlignmentI alignment,
+          Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences,
+          int start, int end)
+  {
+    SequenceI[] allseqs = alignment.getSequencesArray();
+    SequenceGroup theseSeqs = new SequenceGroup();
+
+    for (int i = start; i <= end; i++)
+    {
+      theseSeqs.addSequence(allseqs[i], false);
+      alignment.getHiddenSequences().hideSequence(allseqs[i]);
+    }
+
+    hiddenRepSequences.put(allseqs[start], theseSeqs);
+  }
+}
index bd6b68f..fed5992 100644 (file)
@@ -86,12 +86,12 @@ public class AlignFrameTest
     assertFalse(alignFrame.hideFeatureColumns("exon", true));
     assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
     assertTrue(alignFrame.getViewport().getAlignment().getHiddenColumns()
-            .getListOfCols()
+            .getHiddenRegions()
             .isEmpty());
     assertFalse(alignFrame.hideFeatureColumns("exon", false));
     assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
     assertTrue(alignFrame.getViewport().getAlignment().getHiddenColumns()
-            .getListOfCols()
+            .getHiddenRegions()
             .isEmpty());
 
     /*
@@ -101,7 +101,7 @@ public class AlignFrameTest
     assertTrue(alignFrame.getViewport().getColumnSelection().isEmpty());
     List<int[]> hidden = alignFrame.getViewport().getAlignment()
             .getHiddenColumns()
-            .getListOfCols();
+            .getHiddenRegions();
     assertTrue(hidden.isEmpty());
 
     /*
@@ -111,7 +111,7 @@ public class AlignFrameTest
      */
     assertTrue(alignFrame.hideFeatureColumns("Turn", true));
     hidden = alignFrame.getViewport().getAlignment().getHiddenColumns()
-            .getListOfCols();
+            .getHiddenRegions();
     assertEquals(hidden.size(), 2);
     assertEquals(hidden.get(0)[0], 1);
     assertEquals(hidden.get(0)[1], 3);
index 3b418ec..2aff5cc 100644 (file)
@@ -195,7 +195,7 @@ public class JSONFileTest
     TEST_SEQ_HEIGHT = expectedSeqs.size();
     TEST_GRP_HEIGHT = expectedGrps.size();
     TEST_ANOT_HEIGHT = expectedAnnots.size();
-    TEST_CS_HEIGHT = expectedColSel.getListOfCols().size();
+    TEST_CS_HEIGHT = expectedColSel.getHiddenRegions().size();
 
     exportSettings = new AlignExportSettingI()
     {
@@ -315,11 +315,11 @@ public class JSONFileTest
   {
     HiddenColumns cs = testJsonFile.getHiddenColumns();
     Assert.assertNotNull(cs);
-    Assert.assertNotNull(cs.getListOfCols());
-    List<int[]> hiddenCols = cs.getListOfCols();
+    Assert.assertNotNull(cs.getHiddenRegions());
+    List<int[]> hiddenCols = cs.getHiddenRegions();
     Assert.assertEquals(hiddenCols.size(), TEST_CS_HEIGHT);
     Assert.assertEquals(hiddenCols.get(0), expectedColSel
-            .getListOfCols().get(0),
+            .getHiddenRegions().get(0),
             "Mismatched hidden columns!");
   }
 
index bd97ad8..19c8438 100644 (file)
@@ -913,7 +913,7 @@ public class MappingUtilsTest
     MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
             proteinView, dnaView, dnaSelection, dnaHidden);
     assertEquals("[]", dnaSelection.getSelected().toString());
-    List<int[]> hidden = dnaHidden.getListOfCols();
+    List<int[]> hidden = dnaHidden.getHiddenRegions();
     assertEquals(1, hidden.size());
     assertEquals("[0, 4]", Arrays.toString(hidden.get(0)));
 
@@ -930,7 +930,7 @@ public class MappingUtilsTest
     proteinSelection.hideSelectedColumns(1, hiddenCols);
     MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
             proteinView, dnaView, dnaSelection, dnaHidden);
-    hidden = dnaHidden.getListOfCols();
+    hidden = dnaHidden.getHiddenRegions();
     assertEquals(1, hidden.size());
     assertEquals("[0, 3]", Arrays.toString(hidden.get(0)));
 
@@ -944,7 +944,7 @@ public class MappingUtilsTest
     proteinSelection.hideSelectedColumns(2, hiddenCols);
     MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
             proteinView, dnaView, dnaSelection, dnaHidden);
-    assertTrue(dnaHidden.getListOfCols().isEmpty());
+    assertTrue(dnaHidden.getHiddenRegions().isEmpty());
 
     /*
      * Column 3 in protein picks up Seq1/P, Seq2/Q, Seq3/S which map to columns
@@ -959,7 +959,7 @@ public class MappingUtilsTest
     MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
             proteinView, dnaView, dnaSelection, dnaHidden);
     assertEquals("[0, 1, 2, 3]", dnaSelection.getSelected().toString());
-    hidden = dnaHidden.getListOfCols();
+    hidden = dnaHidden.getHiddenRegions();
     assertEquals(1, hidden.size());
     assertEquals("[5, 10]", Arrays.toString(hidden.get(0)));
 
@@ -974,7 +974,7 @@ public class MappingUtilsTest
     proteinSelection.hideSelectedColumns(3, hiddenCols);
     MappingUtils.mapColumnSelection(proteinSelection, hiddenCols,
             proteinView, dnaView, dnaSelection, dnaHidden);
-    hidden = dnaHidden.getListOfCols();
+    hidden = dnaHidden.getHiddenRegions();
     assertEquals(2, hidden.size());
     assertEquals("[0, 3]", Arrays.toString(hidden.get(0)));
     assertEquals("[5, 10]", Arrays.toString(hidden.get(1)));
diff --git a/test/jalview/viewmodel/OverviewDimensionsHideHiddenTest.java b/test/jalview/viewmodel/OverviewDimensionsHideHiddenTest.java
new file mode 100644 (file)
index 0000000..2bd9c47
--- /dev/null
@@ -0,0 +1,989 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.viewmodel;
+
+import static org.testng.Assert.assertEquals;
+
+import jalview.analysis.AlignmentGenerator;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceCollectionI;
+import jalview.datamodel.SequenceGroup;
+import jalview.datamodel.SequenceI;
+
+import java.util.Hashtable;
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+@Test(singleThreaded = true)
+public class OverviewDimensionsHideHiddenTest
+{
+  AlignmentI al;
+
+  OverviewDimensionsHideHidden od;
+
+  // cached widths and heights
+  int boxWidth;
+  int boxHeight;
+  int viewHeight;
+  int viewWidth;
+  int alheight;
+  int alwidth;
+
+  ViewportRanges vpranges;
+
+  Hashtable<SequenceI, SequenceCollectionI> hiddenRepSequences = new Hashtable<SequenceI, SequenceCollectionI>();
+
+  HiddenColumns hiddenCols = new HiddenColumns();
+
+  @BeforeClass(alwaysRun = true)
+  public void setUpAlignment()
+  {
+    // create random alignment
+    AlignmentGenerator gen = new AlignmentGenerator(false);
+    al = gen.generate(157, 525, 123, 5, 5);
+  }
+
+  @BeforeMethod(alwaysRun = true)
+  public void setUp()
+  {
+    if (!hiddenRepSequences.isEmpty())
+    {
+      al.getHiddenSequences().showAll(hiddenRepSequences);
+    }
+    ColumnSelection colsel = new ColumnSelection();
+    hiddenCols.revealAllHiddenColumns(colsel);
+    
+    vpranges = new ViewportRanges(al);
+    vpranges.setStartRes(0);
+    vpranges.setEndRes(62);
+    vpranges.setStartSeq(0);
+    vpranges.setEndSeq(17);
+
+    viewHeight = vpranges.getEndSeq() - vpranges.getStartSeq() + 1;
+    viewWidth = vpranges.getEndRes() - vpranges.getStartRes() + 1;
+
+    HiddenColumns hiddenCols = new HiddenColumns();
+
+    od = new OverviewDimensionsHideHidden(vpranges, true);
+    // Initial box sizing - default path through code
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
+
+    mouseClick(od, 0, 0);
+    moveViewport(0, 0);
+
+    // calculate with visible values
+    alheight = vpranges.getVisibleAlignmentHeight();
+    alwidth = vpranges.getVisibleAlignmentWidth();
+
+    boxWidth = Math.round((float) (vpranges.getEndRes()
+            - vpranges.getStartRes() + 1)
+            * od.getWidth() / alwidth);
+    boxHeight = Math.round((float) (vpranges.getEndSeq()
+            - vpranges.getStartSeq() + 1)
+            * od.getSequencesHeight() / alheight);
+  }
+
+  @AfterClass(alwaysRun = true)
+  public void cleanUp()
+  {
+    al = null;
+  }
+
+  /**
+   * Test that the OverviewDimensions constructor sets width and height
+   * correctly
+   */
+  @Test(groups = { "Functional" })
+  public void testConstructor()
+  {
+    SequenceI seqa = new Sequence("Seq1", "ABC");
+    SequenceI seqb = new Sequence("Seq2", "ABC");
+    SequenceI seqc = new Sequence("Seq3", "ABC");
+    SequenceI seqd = new Sequence("Seq4", "ABC");
+    SequenceI seqe = new Sequence("Seq5",
+            "ABCABCABCABCABCABCABCABCBACBACBACBAC");
+
+    int defaultGraphHeight = 20;
+    int maxWidth = 400;
+    int minWidth = 120;
+    int maxSeqHeight = 300;
+    int minSeqHeight = 40;
+
+    // test for alignment with width > height
+    SequenceI[] seqs1 = new SequenceI[] { seqa, seqb };
+    Alignment al1 = new Alignment(seqs1);
+    ViewportRanges props = new ViewportRanges(al1);
+
+    OverviewDimensions od = new OverviewDimensionsHideHidden(props, true);
+    int scaledHeight = 267;
+    assertEquals(od.getGraphHeight(), defaultGraphHeight);
+    assertEquals(od.getSequencesHeight(), scaledHeight);
+    assertEquals(od.getWidth(), maxWidth);
+    assertEquals(od.getHeight(), scaledHeight + defaultGraphHeight);
+
+    // test for alignment with width < height
+    SequenceI[] seqs2 = new SequenceI[] { seqa, seqb, seqc, seqd };
+    Alignment al2 = new Alignment(seqs2);
+    props = new ViewportRanges(al2);
+
+    od = new OverviewDimensionsHideHidden(props, true);
+    int scaledWidth = 300;
+    assertEquals(od.getGraphHeight(), defaultGraphHeight);
+    assertEquals(od.getSequencesHeight(), maxSeqHeight);
+    assertEquals(od.getWidth(), scaledWidth);
+    assertEquals(od.getHeight(), scaledWidth + defaultGraphHeight);
+
+    // test for alignment with width > height and sequence height scaled below
+    // min value
+    SequenceI[] seqs3 = new SequenceI[] { seqe };
+    Alignment al3 = new Alignment(seqs3);
+    props = new ViewportRanges(al3);
+
+    od = new OverviewDimensionsHideHidden(props, true);
+    assertEquals(od.getGraphHeight(), defaultGraphHeight);
+    assertEquals(od.getSequencesHeight(), minSeqHeight);
+    assertEquals(od.getWidth(), maxWidth);
+    assertEquals(od.getHeight(), minSeqHeight + defaultGraphHeight);
+
+    // test for alignment with width < height and width scaled below min value
+    SequenceI[] seqs4 = new SequenceI[] { seqa, seqb, seqc, seqd, seqa,
+        seqb, seqc, seqd, seqa, seqb, seqc, seqd, seqa, seqb, seqc, seqd };
+    Alignment al4 = new Alignment(seqs4);
+    props = new ViewportRanges(al4);
+
+    od = new OverviewDimensionsHideHidden(props, true);
+    assertEquals(od.getGraphHeight(), defaultGraphHeight);
+    assertEquals(od.getSequencesHeight(), maxSeqHeight);
+    assertEquals(od.getWidth(), minWidth);
+    assertEquals(od.getHeight(), maxSeqHeight + defaultGraphHeight);
+
+    Alignment al5 = new Alignment(seqs4);
+    props = new ViewportRanges(al5);
+
+    od = new OverviewDimensionsHideHidden(props, false);
+    assertEquals(od.getGraphHeight(), 0);
+    assertEquals(od.getSequencesHeight(), maxSeqHeight);
+    assertEquals(od.getWidth(), minWidth);
+    assertEquals(od.getHeight(), maxSeqHeight);
+  }
+
+  /**
+   * Test that validation after mouse adjustments to boxX and boxY sets box
+   * dimensions and scroll values correctly, when there are no hidden rows or
+   * columns.
+   */
+  @Test(groups = { "Functional" })
+  public void testSetBoxFromMouseClick()
+  {
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getScrollCol(), 0);
+    assertEquals(od.getScrollRow(), 0);
+
+    // negative boxX value reset to 0
+    mouseClick(od, -5, 10);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+    assertEquals(od.getScrollRow(),
+            Math.round((float) 10 * alheight / od.getSequencesHeight()));
+    assertEquals(od.getScrollCol(), 0);
+
+    // negative boxY value reset to 0
+    mouseClick(od, 6, -2);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+    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());
+    assertEquals(od.getBoxY(), 6);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+    assertEquals(od.getScrollCol(),
+            Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
+    assertEquals(od.getScrollRow(),
+            Math.round((float) od.getBoxY() * alheight
+                    / od.getSequencesHeight()));
+
+    // overly large boxY value reset to sequenceHeight - boxHeight
+    mouseClick(od, 10, 520);
+    assertEquals(od.getBoxX(), 10);
+    assertEquals(od.getBoxY(), od.getSequencesHeight() - od.getBoxHeight());
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+    assertEquals(od.getScrollCol(),
+            Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
+
+    // here (float) od.getBoxY() * alheight / od.getSequencesHeight() = 507.5
+    // and round rounds to 508; however we get 507 working with row values
+    // hence the subtraction of 1
+    assertEquals(od.getScrollRow(),
+            Math.round((float) od.getBoxY() * alheight
+                    / od.getSequencesHeight()) - 1);
+
+    // click past end of alignment, as above
+    mouseClick(od, 3000, 5);
+    assertEquals(od.getBoxX(), od.getWidth() - od.getBoxWidth());
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+    assertEquals(od.getScrollCol(),
+            Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
+    assertEquals(od.getScrollRow(),
+            Math.round((float) od.getBoxY() * alheight
+                    / od.getSequencesHeight()));
+
+    // move viewport so startRes non-zero and then mouseclick
+    moveViewportH(50);
+
+    // click at viewport position
+    int oldboxx = od.getBoxX();
+    int oldboxy = od.getBoxY();
+    mouseClick(od, od.getBoxX() + 5, od.getBoxY() + 2);
+    assertEquals(od.getBoxX(), oldboxx + 5);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+    assertEquals(od.getScrollCol(),
+            Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
+    assertEquals(od.getBoxY(), oldboxy + 2);
+    assertEquals(od.getScrollRow(),
+            Math.round((float) od.getBoxY() * alheight
+                    / od.getSequencesHeight()));
+
+    // click at top corner
+    mouseClick(od, 0, 0);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getScrollCol(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getScrollRow(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+  }
+
+  /**
+   * Test setting of the box position, when there are hidden cols at the start
+   * of the alignment
+   */
+  @Test(groups = { "Functional" })
+  public void testFromMouseWithHiddenColsAtStart()
+  {
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getScrollCol(), 0);
+    assertEquals(od.getScrollRow(), 0);
+
+    // hide cols at start and check updated box position is correct
+    int lastHiddenCol = 30;
+    hiddenCols.hideColumns(0, lastHiddenCol);
+
+    testBoxIsAtClickPoint(0, 0);
+
+    // click to right of hidden columns, box moves to click point
+    testBoxIsAtClickPoint(40, 0);
+    assertEquals(od.getScrollRow(), 0);
+    assertEquals(od.getScrollCol(),
+            Math.round((float) 40 * alwidth / od.getWidth()));
+
+    // click to right of hidden columns such that box runs over right hand side
+    // of alignment
+    // box position is adjusted away from the edge
+    // overly large boxX value reset to width-boxWidth
+    int xpos = 100;
+    mouseClick(od, xpos, 0);
+    assertEquals(od.getBoxX(), Math.round(od.getWidth()) - boxWidth);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+    assertEquals(od.getScrollCol(),
+            Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
+    assertEquals(od.getScrollRow(), 0);
+  }
+
+  /**
+   * Test setting of the box position, when there are hidden cols in the middle
+   * of the alignment
+   */
+  @Test(groups = { "Functional" })
+  public void testFromMouseWithHiddenColsInMiddle()
+  {
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
+    testBoxIsAtClickPoint(0, 0);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getScrollCol(), 0);
+    assertEquals(od.getScrollRow(), 0);
+    
+    // hide columns 63-73, no change to box position or dimensions
+    int firstHidden = 63;
+    int lastHidden = 73;
+    hiddenCols.hideColumns(firstHidden, lastHidden);
+
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
+    testBoxIsAtClickPoint(0, 0);
+    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, boxX and scrollCol as for unhidden case
+    int xpos = 55 - boxWidth; // 55 is position in overview approx halfway
+                              // between cols 60 and 70
+    mouseClick(od, xpos, 0);
+    testBoxIsAtClickPoint(xpos, 0);
+    assertEquals(od.getScrollCol(),
+            Math.round(xpos * alwidth / od.getWidth()));
+    assertEquals(od.getScrollRow(), 0);
+
+    // move box so that it completely covers hidden cols
+    // box width, boxX and scrollCol as for unhidden case
+    xpos = 33;
+    mouseClick(od, xpos, 0);
+    testBoxIsAtClickPoint(xpos, 0);
+    assertEquals(od.getScrollCol(),
+            Math.round((float) xpos * alwidth / od.getWidth()));
+    assertEquals(od.getScrollRow(), 0);
+
+    // move box so boxX is in hidden cols, box overhangs at right
+    // boxX and scrollCol at left of hidden area, box width unchanged
+    xpos = 50;
+    mouseClick(od, xpos, 0);
+    testBoxIsAtClickPoint(xpos, 0);
+    assertEquals(od.getScrollCol(),
+            Math.round((float) xpos * alwidth / od.getWidth()));
+    assertEquals(od.getScrollRow(), 0);
+
+    // move box so boxX is to right of hidden cols, but does not go beyond full
+    // width of alignment
+    // box width, boxX and scrollCol all as for non-hidden case
+    xpos = 75;
+    testBoxIsAtClickPoint(xpos, 0);
+    assertEquals(od.getScrollRow(), 0);
+    assertEquals(od.getScrollCol(),
+            Math.round(xpos * alwidth / od.getWidth()));
+    
+    // move box so it goes beyond full width of alignment
+    // boxX, scrollCol adjusted back, box width normal
+    xpos = 3000;
+    mouseClick(od, xpos, 0);
+    assertEquals(od.getBoxX(), Math.round(od.getWidth()) - boxWidth);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+    assertEquals(od.getScrollCol(),
+            Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
+    assertEquals(od.getScrollRow(), 0);
+
+  }
+
+  /**
+   * Test setting of the box position, when there are hidden cols at the end of
+   * the alignment
+   */
+  @Test(groups = { "Functional" })
+  public void testFromMouseWithHiddenColsAtEnd()
+  {
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getScrollCol(), 0);
+    assertEquals(od.getScrollRow(), 0);
+
+    // hide columns 140-164, no change to box position or dimensions
+    int firstHidden = 140;
+    int lastHidden = 164;
+    hiddenCols.hideColumns(firstHidden, lastHidden);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getScrollCol(), 0);
+    assertEquals(od.getScrollRow(), 0);
+
+    // click to left of hidden cols, without overlapping
+    // boxX, scrollCol and width as normal
+    int xpos = 5;
+    testBoxIsAtClickPoint(xpos, 0);
+    assertEquals(od.getScrollRow(), 0);
+    assertEquals(od.getScrollCol(),
+            Math.round((float) xpos * alwidth / od.getWidth()));
+
+    // click to left of hidden cols, with overlap
+    // boxX and scrollCol adjusted for hidden cols, width normal
+    xpos = Math.round((float) 145 * od.getWidth() / alwidth) - boxWidth;
+    mouseClick(od, xpos, 0);
+    testBoxIsAtClickPoint(xpos, 0);
+    assertEquals(od.getScrollCol(),
+            Math.round((float) xpos * alwidth / od.getWidth()));
+    assertEquals(od.getScrollRow(), 0);
+
+    // click off end of alignment
+    // boxX and scrollCol adjusted backwards, width normal
+    xpos = 3000;
+    mouseClick(od, xpos, 0);
+    assertEquals(od.getBoxX(), Math.round(od.getWidth()) - boxWidth);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+    assertEquals(od.getScrollCol(),
+            Math.round((float) od.getBoxX() * alwidth / od.getWidth()));
+    assertEquals(od.getScrollRow(), 0);
+  }
+
+  /**
+   * Test that the box position is set correctly when set from the viewport,
+   * with no hidden rows or columns
+   */
+  @Test(groups = { "Functional" })
+  public void testSetBoxFromViewport()
+  {
+    // move viewport to start of alignment
+    moveViewport(0, 0);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+    // move viewport to right
+    moveViewportH(70);
+    assertEquals(od.getBoxX(),
+            Math.round((float) 70 * od.getWidth() / alwidth));
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+    // move viewport down
+    moveViewportV(100);
+    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(),
+            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);
+  }
+
+  /**
+   * Test that the box position is set correctly when there are hidden columns
+   * at the start
+   */
+  @Test(groups = { "Functional" })
+  public void testSetBoxFromViewportHiddenColsAtStart()
+  {
+    int firstHidden = 0;
+    int lastHidden = 20;
+    hiddenCols.hideColumns(firstHidden, lastHidden);
+
+    // move viewport to start of alignment
+    moveViewport(0, 0);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    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(),
+            Math.round((float) (98 - lastHidden - 1) * od.getWidth()
+                    / alwidth));
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+  }
+
+  /**
+   * Test that the box position is set correctly when there are hidden columns
+   * in the middle
+   */
+  @Test(groups = { "Functional" })
+  public void testSetBoxFromViewportHiddenColsInMiddle()
+  {
+    int firstHidden = 68;
+    int lastHidden = 78;
+    hiddenCols.hideColumns(firstHidden, lastHidden);
+
+    // move viewport before hidden columns
+    moveViewport(3, 0);
+
+    assertEquals(od.getBoxX(),
+            Math.round((float) 3 * od.getWidth() / alwidth));
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+    // move viewport to left of hidden columns with overlap
+    moveViewport(10, 0);
+    assertEquals(od.getBoxX(),
+            Math.round((float) 10 * od.getWidth() / alwidth));
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+    // move viewport to straddle hidden columns
+    moveViewport(63, 0);
+    assertEquals(od.getBoxX(),
+            Math.round((float) 63 * od.getWidth() / alwidth));
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+    // move viewport to right of hidden columns, no overlap
+    moveViewport(80 - (lastHidden - firstHidden + 1), 0);
+    assertEquals(od.getBoxX(),
+            Math.round((float) (80 - (lastHidden - firstHidden + 1))
+                    * od.getWidth() / alwidth));
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+  }
+
+  /**
+   * Test that the box position is set correctly when there are hidden columns
+   * at the end
+   */
+  @Test(groups = { "Functional" })
+  public void testSetBoxFromViewportHiddenColsAtEnd()
+  {
+    int firstHidden = 152;
+    int lastHidden = 164;
+    hiddenCols.hideColumns(firstHidden, lastHidden);
+
+    // move viewport before hidden columns
+    moveViewport(3, 0);
+    assertEquals(od.getBoxX(),
+            Math.round((float) 3 * od.getWidth() / alwidth));
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+    // move viewport to hidden columns
+    // viewport can't actually extend into hidden cols,
+    // so move to the far right edge of the viewport
+    moveViewport(firstHidden - viewWidth, 0);
+    assertEquals(od.getBoxX(),
+            Math.round((float) (firstHidden - viewWidth)
+                    * od.getWidth() / alwidth));
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+  }
+
+  /**
+   * Test that the box position is set correctly when there are hidden rows at
+   * the start
+   */
+  @Test(groups = { "Functional" })
+  public void testSetBoxFromViewportHiddenRowsAtStart()
+  {
+    int firstHidden = 0;
+    int lastHidden = 20;
+    hideSequences(firstHidden, lastHidden);
+
+    // calculate with visible values
+    alheight = vpranges.getVisibleAlignmentHeight();
+    alwidth = vpranges.getVisibleAlignmentWidth();
+
+    boxWidth = Math.round((float) (vpranges.getEndRes()
+            - vpranges.getStartRes() + 1)
+            * od.getWidth() / alwidth);
+    boxHeight = Math.round((float) (vpranges.getEndSeq()
+            - vpranges.getStartSeq() + 1)
+            * od.getSequencesHeight() / alheight);
+
+    // move viewport to start of alignment:
+    // box moves to below hidden rows, height remains same
+    moveViewport(0, 0);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+    // move viewport to end of alignment
+    moveViewport(0, 525 - viewHeight - lastHidden - 1);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(
+            od.getBoxY(),
+            Math.round((float) (525 - viewHeight - lastHidden - 1)
+                    * od.getSequencesHeight()
+                    / alheight));
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+  }
+
+  /**
+   * Test that the box position is set correctly when there are hidden rows in
+   * the middle
+   */
+  @Test(groups = { "Functional" })
+  public void testSetBoxFromViewportHiddenRowsInMiddle()
+  {
+    int firstHidden = 200;
+    int lastHidden = 210;
+    hideSequences(firstHidden, lastHidden);
+
+    // calculate with visible values
+    alheight = vpranges.getVisibleAlignmentHeight();
+    alwidth = vpranges.getVisibleAlignmentWidth();
+
+    boxWidth = Math.round((float) (vpranges.getEndRes()
+            - vpranges.getStartRes() + 1)
+            * od.getWidth() / alwidth);
+    boxHeight = Math.round((float) (vpranges.getEndSeq()
+            - vpranges.getStartSeq() + 1)
+            * od.getSequencesHeight() / alheight);
+
+    // move viewport to start of alignment:
+    // box, height etc as in non-hidden case
+    moveViewport(0, 0);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+    // move viewport to straddle hidden rows
+    moveViewport(0, 198);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), Math.round ((float)198 * od.getSequencesHeight()
+            / alheight));
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+  }
+
+  /**
+   * Test that the box position is set correctly when there are hidden rows at
+   * the bottom
+   */
+  @Test(groups = { "Functional" })
+  public void testSetBoxFromViewportHiddenRowsAtEnd()
+  {
+    int firstHidden = 500;
+    int lastHidden = 524;
+    hideSequences(firstHidden, lastHidden);
+
+    // calculate with visible values
+    alheight = vpranges.getVisibleAlignmentHeight();
+    alwidth = vpranges.getVisibleAlignmentWidth();
+
+    boxWidth = Math.round((float) (vpranges.getEndRes()
+            - vpranges.getStartRes() + 1)
+            * od.getWidth() / alwidth);
+    boxHeight = Math.round((float) (vpranges.getEndSeq()
+            - vpranges.getStartSeq() + 1)
+            * od.getSequencesHeight() / alheight);
+
+    // move viewport to start of alignment:
+    // box, height etc as in non-hidden case
+    moveViewport(0, 0);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+    // move viewport to end of alignment
+    // viewport sits above hidden rows and does not include them
+    moveViewport(0, firstHidden - viewHeight - 1);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(
+            od.getBoxY(),
+            Math.round((float) (firstHidden - viewHeight - 1)
+                    * od.getSequencesHeight() / alheight));
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+  }
+
+  /**
+   * Test setting of the box position, when there are hidden rows at the start
+   * of the alignment
+   */
+  @Test(groups = { "Functional" })
+  public void testFromMouseWithHiddenRowsAtStart()
+  {
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxHeight(), boxHeight);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getScrollCol(), 0);
+    assertEquals(od.getScrollRow(), 0);
+
+    // hide rows at start and check updated box position is correct
+    int lastHiddenRow = 30;
+    hideSequences(0, lastHiddenRow);
+
+    // calculate with visible values
+    alheight = vpranges.getVisibleAlignmentHeight();
+    alwidth = vpranges.getVisibleAlignmentWidth();
+
+    boxWidth = Math.round((float) (vpranges.getEndRes()
+            - vpranges.getStartRes() + 1)
+            * od.getWidth() / alwidth);
+    boxHeight = Math.round((float) (vpranges.getEndSeq()
+            - vpranges.getStartSeq() + 1)
+            * od.getSequencesHeight() / alheight);
+
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+    // click below hidden rows
+    mouseClick(od, 0, 150);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 150);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+  }
+
+  /**
+   * Test setting of the box position, when there are hidden rows at the middle
+   * of the alignment
+   */
+  @Test(groups = { "Functional" })
+  public void testFromMouseWithHiddenRowsInMiddle()
+  {
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
+
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+    assertEquals(od.getScrollCol(), 0);
+    assertEquals(od.getScrollRow(), 0);
+
+    // hide rows in middle and check updated box position is correct
+    // no changes
+    int firstHiddenRow = 50;
+    int lastHiddenRow = 54;
+    hideSequences(firstHiddenRow, lastHiddenRow);
+
+    // calculate with visible values
+    alheight = vpranges.getVisibleAlignmentHeight();
+    alwidth = vpranges.getVisibleAlignmentWidth();
+
+    boxWidth = Math.round((float) (vpranges.getEndRes()
+            - vpranges.getStartRes() + 1)
+            * od.getWidth() / alwidth);
+    boxHeight = Math.round((float) (vpranges.getEndSeq()
+            - vpranges.getStartSeq() + 1)
+            * od.getSequencesHeight() / alheight);
+
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
+
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+    // click above hidden rows, so that box overlaps
+    int ypos = 35; // column value in residues
+    mouseClick(od, 0,
+            Math.round((float) ypos * od.getSequencesHeight() / alheight));
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(),
+            Math.round((float) ypos * od.getSequencesHeight() / alheight));
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+    // click so that box straddles hidden rows
+    ypos = 44; // column value in residues
+    mouseClick(od, 0,
+            Math.round((float) ypos * od.getSequencesHeight() / alheight));
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(),
+            Math.round((float) ypos * od.getSequencesHeight() / alheight));
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+  }
+
+  /**
+   * Test setting of the box position, when there are hidden rows at the end of
+   * the alignment
+   */
+  @Test(groups = { "Functional" })
+  public void testFromMouseWithHiddenRowsAtEnd()
+  {
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+    assertEquals(od.getScrollCol(), 0);
+    assertEquals(od.getScrollRow(), 0);
+
+    // hide rows at end and check updated box position is correct
+    // no changes
+    int firstHidden = 500;
+    int lastHidden = 524;
+    hideSequences(firstHidden, lastHidden);
+
+    // calculate with visible values
+    alheight = vpranges.getVisibleAlignmentHeight();
+    alwidth = vpranges.getVisibleAlignmentWidth();
+
+    boxWidth = Math.round((float) (vpranges.getEndRes()
+            - vpranges.getStartRes() + 1)
+            * od.getWidth() / alwidth);
+    boxHeight = Math.round((float) (vpranges.getEndSeq()
+            - vpranges.getStartSeq() + 1)
+            * od.getSequencesHeight() / alheight);
+
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(od.getBoxY(), 0);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+    // click above hidden rows
+    int ypos = 40; // row 40
+    mouseClick(od, 0,
+            Math.round((float) ypos * od.getSequencesHeight() / alheight));
+    assertEquals(od.getBoxX(), 0);
+    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, boxHeight remains same
+    ypos = 497; // row 497
+    mouseClick(od, 0,
+            Math.round((float) ypos * od.getSequencesHeight() / alheight));
+    assertEquals(od.getBoxX(), 0);
+    assertEquals(
+            od.getBoxY(),
+            Math.round((float) firstHidden * od.getSequencesHeight()
+                    / alheight)
+                    - boxHeight);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+  }
+
+  /*
+   * Move viewport horizontally: startRes + previous width gives new horizontal extent. Vertical extent stays the same.
+   */
+  private void moveViewportH(int startRes)
+  {
+    vpranges.setStartRes(startRes);
+    vpranges.setEndRes(startRes + viewWidth - 1);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
+  }
+
+  /*
+   * Move viewport vertically: startSeq and endSeq give new vertical extent. Horizontal extent stays the same.
+   */
+  private void moveViewportV(int startSeq)
+  {
+    vpranges.setStartSeq(startSeq);
+    vpranges.setEndSeq(startSeq + viewHeight - 1);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
+  }
+
+  /*
+   * Move viewport horizontally and vertically.
+   */
+  private void moveViewport(int startRes, int startSeq)
+  {
+    vpranges.setStartRes(startRes);
+    vpranges.setEndRes(startRes + viewWidth - 1);
+    vpranges.setStartSeq(startSeq);
+    vpranges.setEndSeq(startSeq + viewHeight - 1);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
+  }
+
+  /*
+   * Mouse click as position x,y in overview window
+   */
+  private void mouseClick(OverviewDimensionsHideHidden od, int x, int y)
+  {
+    od.updateViewportFromMouse(x, y, al.getHiddenSequences(), hiddenCols);
+
+    // updates require an OverviewPanel to exist which it doesn't here
+    // so call setBoxPosition() as it would be called by the AlignmentPanel
+    // normally
+
+    vpranges.setStartRes(od.getScrollCol());
+    vpranges.setEndRes(od.getScrollCol() + viewWidth - 1);
+    vpranges.setStartSeq(od.getScrollRow());
+    vpranges.setEndSeq(od.getScrollRow() + viewHeight - 1);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
+  }
+  
+  /*
+   * Test that the box is positioned with the top left corner at xpos, ypos
+   * and with the original width and height
+   */
+  private void testBoxIsAtClickPoint(int xpos, int ypos)
+  {
+    mouseClick(od, xpos, ypos);
+    assertEquals(od.getBoxX(), xpos);
+    assertEquals(od.getBoxY(), ypos);
+    assertEquals(od.getBoxWidth(), boxWidth);
+    assertEquals(od.getBoxHeight(), boxHeight);
+
+  }
+
+  /*
+   * Hide sequences between start and end
+   */
+  private void hideSequences(int start, int end)
+  {
+    SequenceI[] allseqs = al.getSequencesArray();
+    SequenceGroup theseSeqs = new SequenceGroup();
+    
+    for (int i = start; i <= end; i++)
+    {
+      theseSeqs.addSequence(allseqs[i], false);
+      al.getHiddenSequences().hideSequence(allseqs[i]);
+    }
+
+    hiddenRepSequences.put(allseqs[start], theseSeqs);
+  }
+}
@@ -40,10 +40,10 @@ import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 @Test(singleThreaded = true)
-public class OverviewDimensionsTest
+public class OverviewDimensionsShowHiddenTest
 {
   AlignmentI al;
-  OverviewDimensions od;
+  OverviewDimensionsShowHidden od;
 
   // cached widths and heights
   int boxWidth;
@@ -60,7 +60,7 @@ public class OverviewDimensionsTest
   HiddenColumns hiddenCols = new HiddenColumns();
 
   @BeforeClass(alwaysRun = true)
-  public void setUpJvOptionPane()
+  public void setUpAlignment()
   {
     // create random alignment
     AlignmentGenerator gen = new AlignmentGenerator(false);
@@ -88,9 +88,9 @@ public class OverviewDimensionsTest
 
     HiddenColumns hiddenCols = new HiddenColumns();
 
-    od = new OverviewDimensions(vpranges, true);
+    od = new OverviewDimensionsShowHidden(vpranges, true);
     // Initial box sizing - default path through code
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
 
     mouseClick(od, 0, 0);
     moveViewport(0, 0);
@@ -138,7 +138,7 @@ public class OverviewDimensionsTest
     Alignment al1 = new Alignment(seqs1);
     ViewportRanges props = new ViewportRanges(al1);
 
-    OverviewDimensions od = new OverviewDimensions(props, true);
+    OverviewDimensions od = new OverviewDimensionsShowHidden(props, true);
     int scaledHeight = 267;
     assertEquals(od.getGraphHeight(), defaultGraphHeight);
     assertEquals(od.getSequencesHeight(), scaledHeight);
@@ -150,7 +150,7 @@ public class OverviewDimensionsTest
     Alignment al2 = new Alignment(seqs2);
     props = new ViewportRanges(al2);
 
-    od = new OverviewDimensions(props, true);
+    od = new OverviewDimensionsShowHidden(props, true);
     int scaledWidth = 300;
     assertEquals(od.getGraphHeight(), defaultGraphHeight);
     assertEquals(od.getSequencesHeight(), maxSeqHeight);
@@ -163,7 +163,7 @@ public class OverviewDimensionsTest
     Alignment al3 = new Alignment(seqs3);
     props = new ViewportRanges(al3);
 
-    od = new OverviewDimensions(props, true);
+    od = new OverviewDimensionsShowHidden(props, true);
     assertEquals(od.getGraphHeight(), defaultGraphHeight);
     assertEquals(od.getSequencesHeight(), minSeqHeight);
     assertEquals(od.getWidth(), maxWidth);
@@ -175,7 +175,7 @@ public class OverviewDimensionsTest
     Alignment al4 = new Alignment(seqs4);
     props = new ViewportRanges(al4);
 
-    od = new OverviewDimensions(props, true);
+    od = new OverviewDimensionsShowHidden(props, true);
     assertEquals(od.getGraphHeight(), defaultGraphHeight);
     assertEquals(od.getSequencesHeight(), maxSeqHeight);
     assertEquals(od.getWidth(), minWidth);
@@ -184,7 +184,7 @@ public class OverviewDimensionsTest
     Alignment al5 = new Alignment(seqs4);
     props = new ViewportRanges(al5);
 
-    od = new OverviewDimensions(props, false);
+    od = new OverviewDimensionsShowHidden(props, false);
     assertEquals(od.getGraphHeight(), 0);
     assertEquals(od.getSequencesHeight(), maxSeqHeight);
     assertEquals(od.getWidth(), minWidth);
@@ -199,8 +199,7 @@ public class OverviewDimensionsTest
   @Test(groups = { "Functional" })
   public void testSetBoxFromMouseClick()
   {
-    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
-            vpranges);
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -298,8 +297,7 @@ public class OverviewDimensionsTest
   @Test(groups = { "Functional" })
   public void testFromMouseWithHiddenColsAtStart()
   {
-    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
-            vpranges);
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -311,7 +309,7 @@ public class OverviewDimensionsTest
     int lastHiddenCol = 30;
     hiddenCols.hideColumns(0, lastHiddenCol);
 
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
     assertEquals(od.getBoxX(),
             Math.round((float) (lastHiddenCol + 1) * od.getWidth()
                     / alwidth));
@@ -363,8 +361,7 @@ public class OverviewDimensionsTest
   @Test(groups = { "Functional" })
   public void testFromMouseWithHiddenColsInMiddle()
   {
-    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
-            vpranges);
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -376,7 +373,7 @@ public class OverviewDimensionsTest
     int lastHidden = 73;
     hiddenCols.hideColumns(firstHidden, lastHidden);
 
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -465,8 +462,7 @@ public class OverviewDimensionsTest
   @Test(groups = { "Functional" })
   public void testFromMouseWithHiddenColsAtEnd()
   {
-    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
-            vpranges);
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -477,7 +473,7 @@ public class OverviewDimensionsTest
     int firstHidden = 140;
     int lastHidden = 164;
     hiddenCols.hideColumns(firstHidden, lastHidden);
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -620,9 +616,7 @@ public class OverviewDimensionsTest
     assertEquals(od.getBoxX(),
             Math.round((float) 3 * od.getWidth() / alwidth));
     assertEquals(od.getBoxY(), 0);
-    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
@@ -792,8 +786,7 @@ public class OverviewDimensionsTest
   @Test(groups = { "Functional" })
   public void testFromMouseWithHiddenRowsAtStart()
   {
-    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
-            vpranges);
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxHeight(), boxHeight);
@@ -806,7 +799,7 @@ public class OverviewDimensionsTest
     int lastHiddenRow = 30;
     hideSequences(0, lastHiddenRow);
 
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(),
             Math.round((float) (lastHiddenRow + 1)
@@ -839,8 +832,7 @@ public class OverviewDimensionsTest
   @Test(groups = { "Functional" })
   public void testFromMouseWithHiddenRowsInMiddle()
   {
-    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
-            vpranges);
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
 
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
@@ -855,7 +847,7 @@ public class OverviewDimensionsTest
     int lastHiddenRow = 54;
     hideSequences(firstHiddenRow, lastHiddenRow);
 
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
 
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
@@ -898,8 +890,7 @@ public class OverviewDimensionsTest
   @Test(groups = { "Functional" })
   public void testFromMouseWithHiddenRowsAtEnd()
   {
-    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols,
-            vpranges);
+    od.updateViewportFromMouse(0, 0, al.getHiddenSequences(), hiddenCols);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -913,7 +904,7 @@ public class OverviewDimensionsTest
     int lastHidden = 524;
     hideSequences(firstHidden, lastHidden);
 
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
     assertEquals(od.getBoxX(), 0);
     assertEquals(od.getBoxY(), 0);
     assertEquals(od.getBoxWidth(), boxWidth);
@@ -962,7 +953,7 @@ public class OverviewDimensionsTest
   {
     vpranges.setStartRes(startRes);
     vpranges.setEndRes(startRes + viewWidth - 1);
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
   }
 
   /*
@@ -972,7 +963,7 @@ public class OverviewDimensionsTest
   {
     vpranges.setStartSeq(startSeq);
     vpranges.setEndSeq(startSeq + viewHeight - 1);
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
   }
 
   /*
@@ -984,16 +975,15 @@ public class OverviewDimensionsTest
     vpranges.setEndRes(startRes + viewWidth - 1);
     vpranges.setStartSeq(startSeq);
     vpranges.setEndSeq(startSeq + viewHeight - 1);
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
   }
 
   /*
    * Mouse click as position x,y in overview window
    */
-  private void mouseClick(OverviewDimensions od, int x, int y)
+  private void mouseClick(OverviewDimensionsShowHidden od, int x, int y)
   {
-    od.updateViewportFromMouse(x, y, al.getHiddenSequences(), hiddenCols,
-            vpranges);
+    od.updateViewportFromMouse(x, y, al.getHiddenSequences(), hiddenCols);
 
     // updates require an OverviewPanel to exist which it doesn't here
     // so call setBoxPosition() as it would be called by the AlignmentPanel
@@ -1003,7 +993,7 @@ public class OverviewDimensionsTest
     vpranges.setEndRes(od.getScrollCol() + viewWidth - 1);
     vpranges.setStartSeq(od.getScrollRow());
     vpranges.setEndSeq(od.getScrollRow() + viewHeight - 1);
-    od.setBoxPosition(al.getHiddenSequences(), hiddenCols, vpranges);
+    od.setBoxPosition(al.getHiddenSequences(), hiddenCols);
   }
   
   /*