JAL-2068 avoid ArrayIndexOutOfBounds when consensus accessed before calculation has...
authorJim Procter <jprocter@issues.jalview.org>
Mon, 20 Jun 2016 12:47:30 +0000 (13:47 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Mon, 20 Jun 2016 12:47:30 +0000 (13:47 +0100)
src/jalview/datamodel/SequenceGroup.java
src/jalview/gui/SequenceRenderer.java

index 0e8fa17..4cbc2a9 100755 (executable)
@@ -1036,7 +1036,8 @@ public class SequenceGroup implements AnnotatedCollectionI
 
   /**
    * 
-   * @return automatically calculated consensus row
+   * @return automatically calculated consensus row note: the row is a stub if a
+   *         consensus calculation has not yet been performed on the group
    */
   public AlignmentAnnotation getConsensus()
   {
index aec61b5..7928a89 100755 (executable)
@@ -455,8 +455,10 @@ public class SequenceRenderer implements jalview.api.SequenceRenderer
                     .getCharAt(position) : av.getAlignment().getSeqrep()
                     .getCharAt(position)))
             : (currentGroup != null && currentGroup.getConsensus() != null
-                    && position >= currentGroup.getStartRes() && position <= currentGroup
-                    .getEndRes()) ? currentGroup.getConsensus().annotations[position].displayCharacter
+                    && position >= currentGroup.getStartRes()
+                    && position <= currentGroup.getEndRes() && currentGroup
+                    .getConsensus().annotations.length > position) ? currentGroup
+                    .getConsensus().annotations[position].displayCharacter
                     .charAt(0)
                     : av.getAlignmentConsensusAnnotation().annotations[position].displayCharacter
                             .charAt(0);