From af8696684758d73680cb775f35b05c5eda879353 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 26 Jul 2006 10:11:41 +0000 Subject: [PATCH] Calculate overlap hidden regions --- src/jalview/datamodel/ColumnSelection.java | 68 ++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 18 deletions(-) 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) -- 1.7.10.2