X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FColumnSelection.java;h=ad6689488792191e953f429f752a7c1ca742912c;hb=af8696684758d73680cb775f35b05c5eda879353;hp=1dafcf0ccc8d881a7025baeb8e82ecad5c58a254;hpb=6a52231af31721231478e6ff3a553bbe23ee863f;p=jalview.git diff --git a/src/jalview/datamodel/ColumnSelection.java b/src/jalview/datamodel/ColumnSelection.java index 1dafcf0..ad66894 100644 --- a/src/jalview/datamodel/ColumnSelection.java +++ b/src/jalview/datamodel/ColumnSelection.java @@ -331,41 +331,71 @@ public class ColumnSelection } return alPos; - } + public void hideSelectedColumns() + { + while (size() > 0) + { + int column = ( (Integer) getSelected().firstElement()).intValue(); + hideColumns(column); + } + } - public void hideColumns(int res) + public void hideColumns(int start, int end) { if(hiddenColumns==null) hiddenColumns = new Vector(); - // First find out range of columns to hide - int min = res, max = res+1; - while( contains(min) ) - { removeElement(min); min --; } - - while( contains(max) ) - { removeElement(max); max ++; } - - min++; max--; - boolean added = false; - for(int i=0; i=region[0]) + { + hiddenColumns.removeElementAt(i); + overlap = true; + break; + } + else if (end < region[0] && start < region[0]) { - hiddenColumns.insertElementAt(new int[]{min, max}, i); + hiddenColumns.insertElementAt(new int[] + {start, end}, i); added = true; break; } } - if(!added) - hiddenColumns.addElement(new int[]{min, max}); + if(overlap) + { + hideColumns(start, end); + } + else if (!added) + hiddenColumns.addElement(new int[] {start, end}); + + } + + /** + * This method will find a range of selected columns + * around the column specified + * @param res int + */ + public void hideColumns(int col) + { + // First find out range of columns to hide + int min = col, max = col+1; + while( contains(min) ) + { removeElement(min); min --; } + + while( contains(max) ) + { removeElement(max); max ++; } + + min++; max--; + hideColumns(min, max); } public void revealAllHiddenColumns() @@ -401,6 +431,8 @@ public class ColumnSelection break; } } + if(hiddenColumns.size()==0) + hiddenColumns = null; } public boolean isVisible(int column)