JAL-2759 HiddenColumns test polishing
[jalview.git] / src / jalview / datamodel / HiddenColumns.java
index 7862975..4e57aa1 100644 (file)
@@ -618,15 +618,14 @@ public class HiddenColumns
       {
         // numColumns is out of date, so recalculate
         int size = 0;
-        if (hiddenColumns != null)
+
+        Iterator<int[]> it = hiddenColumns.iterator();
+        while (it.hasNext())
         {
-          Iterator<int[]> it = hiddenColumns.iterator();
-          while (it.hasNext())
-          {
-            int[] range = it.next();
-            size += range[1] - range[0] + 1;
-          }
+          int[] range = it.next();
+          size += range[1] - range[0] + 1;
         }
+
         numColumns = size;
       }
 
@@ -1075,8 +1074,12 @@ public class HiddenColumns
    */
   public void makeVisibleAnnotation(AlignmentAnnotation alignmentAnnotation)
   {
-    makeVisibleAnnotation(0, alignmentAnnotation.annotations.length,
+    if (alignmentAnnotation != null
+            && alignmentAnnotation.annotations != null)
+    {
+      makeVisibleAnnotation(0, alignmentAnnotation.annotations.length,
             alignmentAnnotation);
+    }
   }
 
   /**
@@ -1100,7 +1103,8 @@ public class HiddenColumns
       int startFrom = start;
       int endAt = end;
 
-      if (alignmentAnnotation.annotations != null)
+      if (alignmentAnnotation != null
+              && alignmentAnnotation.annotations != null)
       {
         if (hiddenColumns != null && hiddenColumns.size() > 0)
         {
@@ -1317,7 +1321,7 @@ public class HiddenColumns
         higestRange = (range[1] >= endPos) ? range : higestRange;
       }
 
-      if (lowestRange[0] == -1 && lowestRange[1] == -1)
+      if (lowestRange[0] == -1) // includes (lowestRange[1] == -1)
       {
         startPos = alignmentStartEnd[0];
       }
@@ -1326,7 +1330,7 @@ public class HiddenColumns
         startPos = lowestRange[1] + 1;
       }
 
-      if (higestRange[0] == -1 && higestRange[1] == -1)
+      if (higestRange[0] == -1) // includes (higestRange[1] == -1)
       {
         endPos = alignmentStartEnd[1];
       }
@@ -1373,16 +1377,6 @@ public class HiddenColumns
         {
           reveal = hiddenColumns.get(regionindex);
         }
-        // or try the next region
-        else
-        {
-          regionindex++;
-          if (regionindex < hiddenColumns.size()
-                  && hiddenColumns.get(regionindex)[0] == adjres + 1)
-          {
-            reveal = hiddenColumns.get(regionindex);
-          }
-        }
       }
       return reveal;