JAL-2571 Corrected alignment width/height checks to visible only
[jalview.git] / src / jalview / datamodel / HiddenSequences.java
index d3aa01a..a98b10e 100755 (executable)
@@ -170,7 +170,13 @@ public class HiddenSequences
   public List<SequenceI> showAll(
           Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
   {
-    List<SequenceI> revealedSeqs = new ArrayList<SequenceI>();
+    List<SequenceI> revealedSeqs = new ArrayList<>();
+
+    if (hiddenSequences == null)
+    {
+      return revealedSeqs;
+    }
+
     for (int i = 0; i < hiddenSequences.length; i++)
     {
       if (hiddenSequences[i] != null)
@@ -199,7 +205,7 @@ public class HiddenSequences
   public List<SequenceI> showSequence(int alignmentIndex,
           Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
   {
-    List<SequenceI> revealedSeqs = new ArrayList<SequenceI>();
+    List<SequenceI> revealedSeqs = new ArrayList<>();
     SequenceI repSequence = alignment.getSequenceAt(alignmentIndex);
     if (repSequence != null && hiddenRepSequences != null
             && hiddenRepSequences.containsKey(repSequence))
@@ -294,7 +300,7 @@ public class HiddenSequences
    *          the row to start from
    * @return the position of the row in the visible alignment
    */
-  public int findIndexNAboveRow(int visibleDistance, int startRow)
+  public int subtractVisibleRows(int visibleDistance, int startRow)
   {
     // walk upwards through the alignment
     // count all the non-null sequences until we have visibleDistance counted
@@ -403,4 +409,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;
+  }
 }