null pointer when double click event occurs without an existing selection (happens...
[jalview.git] / src / jalview / gui / SeqPanel.java
index e32c5cf..4036204 100755 (executable)
@@ -1425,12 +1425,14 @@ public class SeqPanel extends JPanel implements MouseListener,
 
   public void mouseClicked(MouseEvent evt)
   {
+    SequenceGroup sg=null;
     SequenceI sequence = av.alignment.getSequenceAt(findSeq(evt));
     if (evt.getClickCount() > 1)
     {
-      if (av.getSelectionGroup().getSize() == 1
-              && av.getSelectionGroup().getEndRes()
-                      - av.getSelectionGroup().getStartRes() < 2)
+      sg = av.getSelectionGroup();
+      if (sg!=null && sg.getSize() == 1
+              && sg.getEndRes()
+                      - sg.getStartRes() < 2)
       {
         av.setSelectionGroup(null);
       }
@@ -1627,6 +1629,7 @@ public class SeqPanel extends JPanel implements MouseListener,
       return;
     }
 
+    stretchGroup.recalcConservation(); // always do this - annotation has own state
     if (stretchGroup.cs != null)
     {
       if (stretchGroup.cs instanceof ClustalxColourScheme)
@@ -1636,14 +1639,6 @@ public class SeqPanel extends JPanel implements MouseListener,
                 .getWidth());
       }
 
-      if (stretchGroup.cs instanceof Blosum62ColourScheme
-              || stretchGroup.cs instanceof PIDColourScheme
-              || stretchGroup.cs.conservationApplied()
-              || stretchGroup.cs.getThreshold() > 0)
-      {
-        stretchGroup.recalcConservation();
-      }
-
       if (stretchGroup.cs.conservationApplied())
       {
         SliderPanel.setConservationSlider(ap, stretchGroup.cs, stretchGroup
@@ -1654,9 +1649,9 @@ public class SeqPanel extends JPanel implements MouseListener,
         SliderPanel.setPIDSliderSource(ap, stretchGroup.cs, stretchGroup
                 .getName());
       }
-      PaintRefresher.Refresh(this, av.getSequenceSetId());
-      ap.paintAlignment(true);
     }
+    PaintRefresher.Refresh(this, av.getSequenceSetId());
+    ap.paintAlignment(true);
 
     changeEndRes = false;
     changeStartRes = false;
@@ -1870,16 +1865,15 @@ public class SeqPanel extends JPanel implements MouseListener,
   {
     // TODO: fix this hack - source of messages is align viewport, but SeqPanel
     // handles selection messages...
-    if (av == source)
+    // TODO: extend config options to allow user to control if selections may be shared between viewports.
+    if (av == source || !av.followSelection || (source instanceof AlignViewport && ((AlignViewport)source).getSequenceSetId().equals(av.getSequenceSetId())))
     {
       return;
     }
     // do we want to thread this ? (contention with seqsel and colsel locks, I
     // suspect)
     boolean repaint = false;
-    if (av.followSelection)
-    {
-      if (av.selectionGroup == null || !av.isSelectionGroupChanged())
+    if (av.selectionGroup == null || !av.isSelectionGroupChanged())
       {
         SequenceGroup sgroup = null;
         if (seqsel != null)
@@ -1924,7 +1918,6 @@ public class SeqPanel extends JPanel implements MouseListener,
         }
         repaint |= av.isColSelChanged();
       }
-    }
     if (av.hasHiddenColumns && (av.colSel==null || av.colSel.getHiddenColumns()==null))
     {
       System.err.println("Bad things");