X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FColumnSelection.java;h=a7fd83a211c26d4f97f96534d512ea006f421bad;hb=e1124a62486322d2d28482529d2d6b850ce1719b;hp=fc11698962d69332627a7c5e601b382d4ba93016;hpb=588042b69abf8e60bcc950b24c283933c7dd422f;p=jalview.git diff --git a/src/jalview/gui/ColumnSelection.java b/src/jalview/gui/ColumnSelection.java index fc11698..a7fd83a 100755 --- a/src/jalview/gui/ColumnSelection.java +++ b/src/jalview/gui/ColumnSelection.java @@ -20,98 +20,163 @@ package jalview.gui; import java.util.*; + /** * NOTE: Columns are zero based. */ public class ColumnSelection { - Vector selected = new Vector(); - - public void addElement(int col) - { - selected.addElement(new Integer(col)); - } - - public void clear() - { - selected.removeAllElements(); - } - - public void removeElement(int col) - { - Integer colInt = new Integer(col); - - if (selected.contains(colInt)) + Vector selected = new Vector(); + + /** + * DOCUMENT ME! + * + * @param col DOCUMENT ME! + */ + public void addElement(int col) { - selected.removeElement(colInt); + if (!selected.contains(new Integer(col))) + { + selected.addElement(new Integer(col)); + } } - else + + /** + * DOCUMENT ME! + */ + public void clear() { - System.err.println( - "WARNING: Tried to remove Integer NOT in ColumnSelection"); + selected.removeAllElements(); } - } - - public boolean contains(int col) - { - return selected.contains(new Integer(col)); - } - public int columnAt(int i) - { - return ( (Integer) selected.elementAt(i)).intValue(); - } - - public int size() - { - return selected.size(); - } + /** + * DOCUMENT ME! + * + * @param col DOCUMENT ME! + */ + public void removeElement(int col) + { + Integer colInt = new Integer(col); - public int getMax() - { - int max = -1; + if (selected.contains(colInt)) + { + selected.removeElement(colInt); + } + } - for (int i = 0; i < selected.size(); i++) + public void removeElements(int start, int end) { - if (columnAt(i) > max) + Integer colInt; + for(int i=start; i max) + { + max = columnAt(i); + } + } + + return max; } - return min; - } + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public int getMin() + { + int min = 1000000000; + + for (int i = 0; i < selected.size(); i++) + { + if (columnAt(i) < min) + { + min = columnAt(i); + } + } - public Vector asVector() - { - return selected; - } + return min; + } - public void compensateForEdit(int start, int change) - { - for (int i = 0; i < size(); i++) + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public Vector asVector() { - int temp = columnAt(i); + return selected; + } - if (temp >= start) - { - selected.setElementAt(new Integer(temp - change), i); - } + /** + * DOCUMENT ME! + * + * @param start DOCUMENT ME! + * @param change DOCUMENT ME! + */ + public void compensateForEdit(int start, int change) + { + for (int i = 0; i < size(); i++) + { + int temp = columnAt(i); + + if (temp >= start) + { + selected.setElementAt(new Integer(temp - change), i); + } + } } - } }