JAL-2388 Working hidden regions hide/show in desktop
[jalview.git] / src / jalview / datamodel / HiddenColumns.java
index 0b7e246..f6102d4 100644 (file)
@@ -20,12 +20,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());
@@ -543,7 +566,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;
@@ -597,7 +620,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;
@@ -670,7 +693,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;
@@ -764,7 +787,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;