JAL-2759 Changes to getVisibleSequenceStrings after review
[jalview.git] / src / jalview / datamodel / HiddenColumns.java
index 6e594bd..ab71cbe 100644 (file)
@@ -639,7 +639,7 @@ public class HiddenColumns
    * @return the index of the next hidden column, or alPos if there is no next
    *         hidden column
    */
-  public int getHiddenBoundaryRight(int alPos)
+  public int getNextHiddenBoundary(boolean left, int alPos)
   {
     try
     {
@@ -647,7 +647,13 @@ public class HiddenColumns
       if (!hiddenColumns.isEmpty())
       {
         int index = cursor.findRegionForColumn(alPos).getRegionIndex();
-        if (index < hiddenColumns.size())
+
+        if (left && index > 0)
+        {
+          int[] region = hiddenColumns.get(index - 1);
+          return region[1];
+        }
+        else if (!left && index < hiddenColumns.size())
         {
           int[] region = hiddenColumns.get(index);
           if (alPos < region[0])
@@ -672,38 +678,6 @@ public class HiddenColumns
   }
 
   /**
-   * This method returns the leftmost limit of a region of an alignment with
-   * hidden columns. In otherwords, the previous hidden column.
-   * 
-   * @param alPos
-   *          the absolute (visible) alignmentPosition to find the previous
-   *          hidden column for
-   */
-  public int getHiddenBoundaryLeft(int alPos)
-  {
-    try
-    {
-      LOCK.readLock().lock();
-
-      if (!hiddenColumns.isEmpty())
-      {
-        int index = cursor.findRegionForColumn(alPos).getRegionIndex();
-
-        if (index > 0)
-        {
-          int[] region = hiddenColumns.get(index - 1);
-          return region[1];
-        }
-      }
-      return alPos;
-    } finally
-    {
-      LOCK.readLock().unlock();
-    }
-  }
-
-
-  /**
    * Answers if a column in the alignment is visible
    * 
    * @param column
@@ -736,67 +710,6 @@ public class HiddenColumns
   }
 
   /**
-   * Get the visible sections of a set of sequences
-   * 
-   * @param start
-   *          sequence position to start from
-   * @param end
-   *          sequence position to end at
-   * @param seqs
-   *          an array of sequences
-   * @return an array of strings encoding the visible parts of each sequence
-   */
-  public String[] getVisibleSequenceStrings(int start, int end,
-          SequenceI[] seqs)
-  {
-    try
-    {
-      LOCK.readLock().lock();
-      int iSize = seqs.length;
-      String[] selections = new String[iSize];
-      if (!hiddenColumns.isEmpty())
-      {
-        for (int i = 0; i < iSize; i++)
-        {
-          StringBuilder visibleSeq = new StringBuilder();
-
-          Iterator<int[]> blocks = new VisibleContigsIterator(start,
-                  end + 1, hiddenColumns);
-
-          while (blocks.hasNext())
-          {
-            int[] block = blocks.next();
-            if (blocks.hasNext())
-            {
-              visibleSeq
-                      .append(seqs[i].getSequence(block[0], block[1] + 1));
-            }
-            else
-            {
-              visibleSeq
-                      .append(seqs[i].getSequence(block[0], block[1]));
-            }
-          }
-
-          selections[i] = visibleSeq.toString();
-        }
-      }
-      else
-      {
-        for (int i = 0; i < iSize; i++)
-        {
-          selections[i] = seqs[i].getSequenceAsString(start, end);
-        }
-      }
-
-      return selections;
-    } finally
-    {
-      LOCK.readLock().unlock();
-    }
-  }
-
-  /**
    * 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.
    *