Merge branch 'develop' into features/JAL-2349_matrixvis
authorJim Procter <jprocter@issues.jalview.org>
Wed, 5 Jul 2017 15:06:42 +0000 (16:06 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 5 Jul 2017 15:06:42 +0000 (16:06 +0100)
1  2 
src/jalview/appletgui/AnnotationPanel.java
src/jalview/gui/AnnotationPanel.java
src/jalview/viewmodel/AlignmentViewport.java

@@@ -30,6 -30,7 +30,7 @@@ import jalview.util.Comparison
  import jalview.util.MessageManager;
  import jalview.util.Platform;
  import jalview.viewmodel.ViewportListenerI;
+ import jalview.viewmodel.ViewportRanges;
  
  import java.awt.Color;
  import java.awt.Dimension;
@@@ -118,13 -119,15 +119,15 @@@ public class AnnotationPanel extends Pa
  
      // ap.annotationScroller.getVAdjustable().addAdjustmentListener( this );
      renderer = new AnnotationRenderer();
+     av.getRanges().addPropertyChangeListener(this);
    }
  
    public AnnotationPanel(AlignViewport av)
    {
      this.av = av;
      renderer = new AnnotationRenderer();
-     av.getRanges().addPropertyChangeListener(this);
    }
  
    @Override
          {
            activeRow = i;
          }
 -        else if (aa[i].graph > 0)
 +        else if (aa[i].graph != AlignmentAnnotation.NO_GRAPH)
          {
            // Stretch Graph
            graphStretch = i;
    public void propertyChange(PropertyChangeEvent evt)
    {
      // Respond to viewport range changes (e.g. alignment panel was scrolled)
-     if (evt.getPropertyName().equals("startres")
-             || evt.getPropertyName().equals("endres"))
+     // Both scrolling and resizing change viewport ranges: scrolling changes
+     // both start and end points, but resize only changes end values.
+     // Here we only want to fastpaint on a scroll, with resize using a normal
+     // paint, so scroll events are identified as changes to the horizontal or
+     // vertical start value.
+     if (evt.getPropertyName().equals(ViewportRanges.STARTRES))
      {
        fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
      }
@@@ -31,6 -31,7 +31,7 @@@ import jalview.schemes.ResiduePropertie
  import jalview.util.Comparison;
  import jalview.util.MessageManager;
  import jalview.viewmodel.ViewportListenerI;
+ import jalview.viewmodel.ViewportRanges;
  
  import java.awt.AlphaComposite;
  import java.awt.Color;
@@@ -451,7 -452,7 +452,7 @@@ public class AnnotationPanel extends JP
       * the selection list (read-only view) is in selection order, not
       * column order; make a copy so we can sort it
       */
-     List<Integer> selected = new ArrayList<Integer>(viscols.getSelected());
+     List<Integer> selected = new ArrayList<>(viscols.getSelected());
      Collections.sort(selected);
      for (int index : selected)
      {
          {
            activeRow = i;
          }
 -        else if (aa[i].graph > 0)
 +        else if (aa[i].graph != 0)
          {
            // Stretch Graph
            graphStretch = i;
        repaint();
        return;
      }
+     int sr = av.getRanges().getStartRes();
+     int er = av.getRanges().getEndRes() + 1;
+     int transX = 0;
      long stime = System.currentTimeMillis();
      gg.copyArea(0, 0, imgWidth, getHeight(),
              -horizontal * av.getCharWidth(), 0);
      long mtime = System.currentTimeMillis();
-     int sr = av.getRanges().getStartRes();
-     int er = av.getRanges().getEndRes() + 1;
-     int transX = 0;
  
      if (horizontal > 0) // scrollbar pulled right, image to the left
      {
    public void propertyChange(PropertyChangeEvent evt)
    {
      // Respond to viewport range changes (e.g. alignment panel was scrolled)
-     if (evt.getPropertyName().equals("startres")
-             || evt.getPropertyName().equals("endres"))
+     // Both scrolling and resizing change viewport ranges: scrolling changes
+     // both start and end points, but resize only changes end values.
+     // Here we only want to fastpaint on a scroll, with resize using a normal
+     // paint, so scroll events are identified as changes to the horizontal or
+     // vertical start value.
+     if (evt.getPropertyName().equals(ViewportRanges.STARTRES))
      {
        fastPaint((int) evt.getNewValue() - (int) evt.getOldValue());
      }
@@@ -35,7 -35,6 +35,7 @@@ import jalview.datamodel.AlignmentView
  import jalview.datamodel.Annotation;
  import jalview.datamodel.CigarArray;
  import jalview.datamodel.ColumnSelection;
 +import jalview.datamodel.ContactListI;
  import jalview.datamodel.HiddenColumns;
  import jalview.datamodel.HiddenSequences;
  import jalview.datamodel.ProfilesI;
@@@ -1160,7 -1159,7 +1160,7 @@@ public abstract class AlignmentViewpor
    @Override
    public boolean hasHiddenColumns()
    {
-     return colSel != null
+     return alignment.getHiddenColumns() != null
              && alignment.getHiddenColumns().hasHiddenColumns();
    }
  
      return searchResults;
    }
  
 +  @Override
 +  public ContactListI getContactList(AlignmentAnnotation _aa, int column)
 +  {
 +    return alignment.getContactListFor(_aa, column);
 +  }
++
+   /**
+    * get the consensus sequence as displayed under the PID consensus annotation
+    * row.
+    * 
+    * @return consensus sequence as a new sequence object
+    */
+   public SequenceI getConsensusSeq()
+   {
+     if (consensus == null)
+     {
+       updateConsensus(null);
+     }
+     if (consensus == null)
+     {
+       return null;
+     }
+     StringBuffer seqs = new StringBuffer();
+     for (int i = 0; i < consensus.annotations.length; i++)
+     {
+       Annotation annotation = consensus.annotations[i];
+       if (annotation != null)
+       {
+         String description = annotation.description;
+         if (description != null && description.startsWith("["))
+         {
+           // consensus is a tie - just pick the first one
+           seqs.append(description.charAt(1));
+         }
+         else
+         {
+           seqs.append(annotation.displayCharacter);
+         }
+       }
+     }
+   
+     SequenceI sq = new Sequence("Consensus", seqs.toString());
+     sq.setDescription("Percentage Identity Consensus "
+             + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
+     return sq;
+   }
  }