X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FHiddenColumns.java;fp=src%2Fjalview%2Fdatamodel%2FHiddenColumns.java;h=c0a43eea64ba09df70ed8e5686e58334ecb772f0;hb=be762d8d9c71a7aa3121e845c45911c7192b7827;hp=169b0a4e4dca973dd5da9abd0d5ef1204243758a;hpb=d1bb7a31fc091606aedbc255a5766ac79e36fa91;p=jalview.git diff --git a/src/jalview/datamodel/HiddenColumns.java b/src/jalview/datamodel/HiddenColumns.java index 169b0a4..c0a43ee 100644 --- a/src/jalview/datamodel/HiddenColumns.java +++ b/src/jalview/datamodel/HiddenColumns.java @@ -33,7 +33,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; public class HiddenColumns { private static final ReentrantReadWriteLock LOCK = new ReentrantReadWriteLock(); - + /* * list of hidden column [start, end] ranges; the list is maintained in * ascending start column order @@ -135,8 +135,7 @@ public class HiddenColumns } } return size; - } - finally + } finally { LOCK.readLock().unlock(); } @@ -290,47 +289,47 @@ public class HiddenColumns { LOCK.readLock().lock(); - int distance = visibleDistance; + int distance = visibleDistance; - // in case startColumn is in a hidden region, move it to the left - int start = adjustForHiddenColumns(findColumnPosition(startColumn)); + // in case startColumn is in a hidden region, move it to the left + int start = adjustForHiddenColumns(findColumnPosition(startColumn)); - // get index of hidden region to left of start - int index = getHiddenIndexLeft(start); - if (index == -1) - { - // no hidden regions to left of startColumn - return start - distance; - } + // get index of hidden region to left of start + int index = getHiddenIndexLeft(start); + if (index == -1) + { + // no hidden regions to left of startColumn + return start - distance; + } - // walk backwards through the alignment subtracting the counts of visible - // columns from distance - int[] region; - int gap = 0; - int nextstart = start; + // walk backwards through the alignment subtracting the counts of visible + // columns from distance + int[] region; + int gap = 0; + int nextstart = start; - while ((index > -1) && (distance - gap > 0)) - { - // subtract the gap to right of region from distance - distance -= gap; - start = nextstart; + while ((index > -1) && (distance - gap > 0)) + { + // subtract the gap to right of region from distance + distance -= gap; + start = nextstart; - // calculate the next gap - region = hiddenColumns.get(index); - gap = start - region[1]; + // calculate the next gap + region = hiddenColumns.get(index); + gap = start - region[1]; - // set start to just to left of current region - nextstart = region[0] - 1; - index--; - } + // set start to just to left of current region + nextstart = region[0] - 1; + index--; + } - if (distance - gap > 0) - { - // fell out of loop because there are no more hidden regions - distance -= gap; - return nextstart - distance; - } - return start - distance; + if (distance - gap > 0) + { + // fell out of loop because there are no more hidden regions + distance -= gap; + return nextstart - distance; + } + return start - distance; } finally { LOCK.readLock().unlock(); @@ -382,8 +381,7 @@ public class HiddenColumns } return positions; - } - finally + } finally { LOCK.readLock().unlock(); } @@ -437,22 +435,22 @@ public class HiddenColumns { LOCK.readLock().lock(); - if (hiddenColumns != null) - { - int index = hiddenColumns.size() - 1; - do + if (hiddenColumns != null) { - int[] region = hiddenColumns.get(index); - if (alPos > region[1]) + int index = hiddenColumns.size() - 1; + do { - return region[1]; - } + int[] region = hiddenColumns.get(index); + if (alPos > region[1]) + { + return region[1]; + } - index--; - } while (index > -1); - } + index--; + } while (index > -1); + } - return alPos; + return alPos; } finally { LOCK.readLock().unlock(); @@ -473,22 +471,22 @@ public class HiddenColumns { LOCK.readLock().lock(); - if (hiddenColumns != null) - { - int index = hiddenColumns.size() - 1; - do + if (hiddenColumns != null) { - int[] region = hiddenColumns.get(index); - if (pos > region[1]) + int index = hiddenColumns.size() - 1; + do { - return index; - } + int[] region = hiddenColumns.get(index); + if (pos > region[1]) + { + return index; + } - index--; - } while (index > -1); - } + index--; + } while (index > -1); + } - return -1; + return -1; } finally { LOCK.readLock().unlock(); @@ -578,11 +576,11 @@ public class HiddenColumns } return; } - } + } - /* - * remaining case is that the new range follows everything else - */ + /* + * remaining case is that the new range follows everything else + */ hiddenColumns.add(new int[] { start, end }); } finally { @@ -599,18 +597,18 @@ public class HiddenColumns { LOCK.readLock().lock(); - if (hiddenColumns != null) - { - for (int[] region : hiddenColumns) + if (hiddenColumns != null) { - if (column >= region[0] && column <= region[1]) + for (int[] region : hiddenColumns) { - return false; + if (column >= region[0] && column <= region[1]) + { + return false; + } } } - } - return true; + return true; } finally { LOCK.readLock().unlock(); @@ -641,7 +639,7 @@ public class HiddenColumns return copy; } - + /** * Returns a copy of the vector of hidden regions, as an ArrayList. Before * using this method please consider if you really need access to the hidden @@ -760,8 +758,7 @@ public class HiddenColumns } } } - } - finally + } finally { LOCK.writeLock().unlock(); } @@ -828,8 +825,7 @@ public class HiddenColumns { return new int[] { start, end - 1 }; } - } - finally + } finally { LOCK.readLock().unlock(); } @@ -898,8 +894,7 @@ public class HiddenColumns } return selections; - } - finally + } finally { LOCK.readLock().unlock(); } @@ -992,8 +987,7 @@ public class HiddenColumns } // otherwise, sequence was completely hidden return new int[] { visPrev, visNext, 0, 0, firstP, lastP }; - } - finally + } finally { LOCK.readLock().unlock(); } @@ -1114,8 +1108,7 @@ public class HiddenColumns { alignmentAnnotation.restrict(start, end); } - } - finally + } finally { LOCK.readLock().unlock(); } @@ -1196,8 +1189,7 @@ public class HiddenColumns } hiddenColumns = null; - } - finally + } finally { LOCK.writeLock().unlock(); } @@ -1232,8 +1224,7 @@ public class HiddenColumns { hiddenColumns = null; } - } - finally + } finally { LOCK.writeLock().unlock(); } @@ -1357,8 +1348,7 @@ public class HiddenColumns hiddenColumns = null; } } - } - finally + } finally { LOCK.writeLock().unlock(); } @@ -1456,9 +1446,8 @@ public class HiddenColumns } else { - al.getSequenceAt(s).setSequence( - sq.substring(0, spos + offset) + sb.toString() - + sq.substring(spos + offset)); + al.getSequenceAt(s).setSequence(sq.substring(0, spos + offset) + + sb.toString() + sq.substring(spos + offset)); } } } @@ -1470,7 +1459,8 @@ public class HiddenColumns { // pad the final region with gaps. StringBuffer sb = new StringBuffer(); - for (int s = 0, ns = profileseq.getLength() - spos - offset; s < ns; s++) + for (int s = 0, ns = profileseq.getLength() - spos + - offset; s < ns; s++) { sb.append(gc); } @@ -1572,8 +1562,7 @@ public class HiddenColumns } } return hashCode; - } - finally + } finally { LOCK.readLock().unlock(); } @@ -1621,8 +1610,7 @@ public class HiddenColumns { inserts.set(range[0], range[1] + 1); } - } - finally + } finally { LOCK.readLock().unlock(); }