X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FHiddenSequences.java;h=e841648b851d0e3bc58ee595177d1572b80cfdaf;hb=1dabf099b7c77fb0a80039f72cef34669df9b2e1;hp=ca5208391d0602181988f75d70c643691aa6b28d;hpb=8b875ed4be8113683a34f4d4df36b3a6bb1c556e;p=jalview.git diff --git a/src/jalview/datamodel/HiddenSequences.java b/src/jalview/datamodel/HiddenSequences.java index ca52083..e841648 100755 --- a/src/jalview/datamodel/HiddenSequences.java +++ b/src/jalview/datamodel/HiddenSequences.java @@ -1,161 +1,281 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -package jalview.datamodel; - -import java.util.*; - -public class HiddenSequences -{ - Hashtable hiddenSequences; - AlignmentI alignment; - - public HiddenSequences(AlignmentI al) - { - alignment = al; - } - - public int getSize() - { - return hiddenSequences == null ? 0 : hiddenSequences.size(); - } - - public void hideSequence(SequenceI sequence) - { - if(hiddenSequences==null) - hiddenSequences = new Hashtable(); - - int alignmentIndex = alignment.findIndex(sequence); - alignmentIndex = adjustForHiddenSeqs(alignmentIndex); - - hiddenSequences.put(new Integer(alignmentIndex), sequence); - - alignment.deleteSequence(sequence); - } - - public void showAll() - { - for(int i=0; i0) - repSequence = alignment.getSequenceAt(alignmentIndex-1); - - if(repSequence!=null - && repSequence.getHiddenSequences()==null) - repSequence = null; - - int start = adjustForHiddenSeqs(alignmentIndex-1); - int end = adjustForHiddenSeqs(alignmentIndex); - - for(int index = end; index > start; index--) - { - SequenceI seq = (SequenceI)hiddenSequences.remove(new Integer( - index)); - - if(seq!=null) - { - alignment.getSequences().insertElementAt(seq, alignmentIndex); - if(repSequence!=null) - { - repSequence.showHiddenSequence(seq); - } - } - } - } - - public Hashtable getHiddenSequences() - { - return hiddenSequences; - } - - public SequenceI getHiddenSequence(int alignmentIndex) - { - return (SequenceI)hiddenSequences.get(new Integer(alignmentIndex)); - } - - public int findIndexWithoutHiddenSeqs(int alignmentIndex) - { - int index = 0; - int hiddenSeqs = 0; - while(index <= alignmentIndex) - { - if(hiddenSequences.containsKey(new Integer(index))) - { - hiddenSeqs ++; - } - index ++; - }; - - return (alignmentIndex - hiddenSeqs) ; - } - - public int adjustForHiddenSeqs(int alignmentIndex) - { - int index = 0; - while(index <= alignmentIndex) - { - if(hiddenSequences.containsKey(new Integer(index))) - { - alignmentIndex ++; - } - index ++; - }; - - return alignmentIndex ; - } - - public AlignmentI getFullAlignment() - { - int isize = alignment.getHeight()+hiddenSequences.size(); - SequenceI [] seq = new Sequence[isize]; - - Enumeration en = hiddenSequences.keys(); - while(en.hasMoreElements()) - { - Integer key = (Integer)en.nextElement(); - seq[key.intValue()] = (SequenceI)hiddenSequences.get(key); - } - - int index = 0; - for(int i=0; i