X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=98510e39524e0b415780f424ca6f323ba53ca583;hb=da8e34c5aeee5e83aa844d374eb21e4c2e3cebef;hp=3e0856a5d775040bb34c2508d5440d726f23c5b3;hpb=06476b6d02ef690bf684905cba39eb7b5db7525b;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 3e0856a..98510e3 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -125,8 +125,7 @@ public class Alignment implements AlignmentI /** * Make a new alignment from an array of SeqCigars * - * @param seqs - * SeqCigar[] + * @param alseqs */ public Alignment(SeqCigar[] alseqs) { @@ -195,6 +194,7 @@ public class Alignment implements AlignmentI { synchronized (sequences) { + if (i > -1 && i < sequences.size()) { return sequences.get(i); @@ -398,6 +398,10 @@ public class Alignment implements AlignmentI return null; } + private static final SequenceGroup[] noGroups = new SequenceGroup[0]; + + private ArrayList temp = new ArrayList<>(); + /* * (non-Javadoc) * @@ -407,11 +411,15 @@ public class Alignment implements AlignmentI @Override public SequenceGroup[] findAllGroups(SequenceI s) { - ArrayList temp = new ArrayList<>(); synchronized (groups) { int gSize = groups.size(); + if (gSize == 0) + { + return noGroups; + } + temp.clear(); for (int i = 0; i < gSize; i++) { SequenceGroup sg = groups.get(i); @@ -589,11 +597,12 @@ public class Alignment implements AlignmentI int i = 0; SequenceI sq = null; String sqname = null; + int nseq = sequences.size(); if (startAfter != null) { // try to find the sequence in the alignment boolean matched = false; - while (i < sequences.size()) + while (i < nseq) { if (getSequenceAt(i++) == startAfter) { @@ -606,7 +615,7 @@ public class Alignment implements AlignmentI i = 0; } } - while (i < sequences.size()) + while (i < nseq) { sq = getSequenceAt(i); sqname = sq.getName(); @@ -712,39 +721,21 @@ public class Alignment implements AlignmentI for (int i = 0; i < sequences.size(); i++) { - if (getSequenceAt(i).getLength() > maxLength) - { - maxLength = getSequenceAt(i).getLength(); - } + maxLength = Math.max(maxLength, getSequenceAt(i).getLength()); } - return maxLength; } - /* + @Override - public int getWidth() + public int getVisibleWidth() { - final Wrapper temp = new Wrapper(); - - forEachSequence(new Consumer() + int w = getWidth(); + if (hiddenCols != null) { - @Override - public void accept(SequenceI s) - { - if (s.getLength() > temp.inner) - { - temp.inner = s.getLength(); - } - } - }, 0, sequences.size() - 1); - - return temp.inner; + w -= hiddenCols.getSize(); + } + return w; } - - public static class Wrapper - { - public int inner; - }*/ /** * DOCUMENT ME! @@ -1206,7 +1197,8 @@ public class Alignment implements AlignmentI int maxLength = -1; SequenceI current; - for (int i = 0; i < sequences.size(); i++) + int nseq = sequences.size(); + for (int i = 0; i < nseq; i++) { current = getSequenceAt(i); for (int j = current.getLength(); j > maxLength; j--) @@ -1223,7 +1215,7 @@ public class Alignment implements AlignmentI maxLength++; int cLength; - for (int i = 0; i < sequences.size(); i++) + for (int i = 0; i < nseq; i++) { current = getSequenceAt(i); cLength = current.getLength(); @@ -2042,4 +2034,17 @@ public class Alignment implements AlignmentI } } + @Override + public void resetColors() + { + for (int i = getHeight(); --i >= 0;) + { + sequences.get(i).resetColors(); + } + // if (dataset != null) + // { + // dataset.resetColors(); + // } + } + }