X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FAlignment.java;h=98510e39524e0b415780f424ca6f323ba53ca583;hb=a83adb45bdf9554e270921b4baad94defd314b36;hp=0f51b7e538b9c3c25e7d397f7df51fb21d072e61;hpb=985fd5ff517f3eb5221a7aefec88138341514779;p=jalview.git diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 0f51b7e..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,12 +721,8 @@ 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; } @@ -1192,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--) @@ -1209,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(); @@ -2028,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(); + // } + } + }