JAL-2759 remove redundant hiddenColumns.clear()
[jalview.git] / src / jalview / datamodel / HiddenColumns.java
index b903826..402ea25 100644 (file)
@@ -140,7 +140,7 @@ public class HiddenColumns
             numColumns += region[1] - region[0] + 1;
           }
         }
-        cursor.resetCursor(hiddenColumns);
+        cursor = new HiddenColumnsCursor(hiddenColumns);
       }
     } finally
     {
@@ -208,7 +208,8 @@ public class HiddenColumns
 
       // reset the cursor to just before our insertion point: this saves
       // a lot of reprocessing in large alignments
-      cursor.resetCursor(hiddenColumns, previndex, prevHiddenCount);
+      cursor = new HiddenColumnsCursor(hiddenColumns, previndex,
+              prevHiddenCount);
 
       // reset the number of columns so they will be recounted
       numColumns = 0;
@@ -301,7 +302,7 @@ public class HiddenColumns
       {
         hideColumns(r[0], r[1]);
       }
-      cursor.resetCursor(hiddenColumns);
+      cursor = new HiddenColumnsCursor(hiddenColumns);
       numColumns = 0;
     } finally
     {
@@ -326,7 +327,7 @@ public class HiddenColumns
         }
       }
       hiddenColumns.clear();
-      cursor.resetCursor(hiddenColumns);
+      cursor = new HiddenColumnsCursor(hiddenColumns);
       numColumns = 0;
 
     } finally
@@ -371,7 +372,6 @@ public class HiddenColumns
 
             if (hiddenColumns.isEmpty())
             {
-              hiddenColumns.clear();
               numColumns = 0;
             }
             else
@@ -706,75 +706,6 @@ public class HiddenColumns
   }
 
   /**
-   * Locate the first position visible for this sequence. If seq isn't visible
-   * then return the position of the left side of the hidden boundary region.
-   * 
-   * @param seq
-   *          sequence to find position for
-   * @return visible start position
-   */
-  public int locateVisibleStartOfSequence(SequenceI seq)
-  {
-    try
-    {
-      LOCK.readLock().lock();
-      int start = 0;
-
-      if (hiddenColumns.isEmpty())
-      {
-        return seq.findIndex(seq.getStart()) - 1;
-      }
-
-      // Simply walk along the sequence whilst watching for hidden column
-      // boundaries
-      Iterator<int[]> regions = hiddenColumns.iterator();
-      int hideStart = seq.getLength();
-      int hideEnd = -1;
-      int visPrev = 0;
-      int visNext = 0;
-      boolean foundStart = false;
-
-      // step through the non-gapped positions of the sequence
-      for (int i = seq.getStart(); i <= seq.getEnd() && (!foundStart); i++)
-      {
-        // get alignment position of this residue in the sequence
-        int p = seq.findIndex(i) - 1;
-
-        // update hidden region start/end
-        while (hideEnd < p && regions.hasNext())
-        {
-          int[] region = regions.next();
-          visPrev = visNext;
-          visNext += region[0] - visPrev;
-          hideStart = region[0];
-          hideEnd = region[1];
-        }
-        if (hideEnd < p)
-        {
-          hideStart = seq.getLength();
-        }
-        // update visible boundary for sequence
-        if (p < hideStart)
-        {
-          start = p;
-          foundStart = true;
-        }
-      }
-
-      if (foundStart)
-      {
-        return absoluteToVisibleColumn(start);
-      }
-      // otherwise, sequence was completely hidden
-      return visPrev;
-    } finally
-    {
-      LOCK.readLock().unlock();
-    }
-  }
-
-
-  /**
    * 
    * @return true if there are columns hidden
    */
@@ -851,7 +782,7 @@ public class HiddenColumns
         lastSet = inserts.nextClearBit(firstSet);
         hideColumns(firstSet, lastSet - 1);
       }
-      cursor.resetCursor(hiddenColumns);
+      cursor = new HiddenColumnsCursor(hiddenColumns);
       numColumns = 0;
     } finally
     {
@@ -935,7 +866,7 @@ public class HiddenColumns
         }
 
         hiddenColumns.subList(startindex, endindex + 1).clear();
-        cursor.resetCursor(hiddenColumns);
+        cursor = new HiddenColumnsCursor(hiddenColumns);
         numColumns = 0;
       }
     } finally