JAL-4134 efficiency improvement
[jalview.git] / src / jalview / gui / TreeCanvas.java
index f6b842d..bb028bf 100755 (executable)
@@ -1160,6 +1160,16 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
       return;
     }
 
+    // TODO - sort indices for faster lookup
+    ColumnSelection cs = av.getColumnSelection();
+    HiddenColumns hc = av.getAlignment().getHiddenColumns();
+    ContactMatrixI cm = av.getContactMatrix(tp.assocAnnotation);
+    MappableContactMatrixI mcm = null;
+    int offp;
+    if (cm instanceof MappableContactMatrixI)
+    {
+      mcm = (MappableContactMatrixI) cm;
+    }
     for (BinaryNode bn : l)
     {
       int colm = -1;
@@ -1171,15 +1181,8 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
       {
         continue;
       }
-      // TODO - sort indices for faster lookup
-      ColumnSelection cs = av.getColumnSelection();
-      HiddenColumns hc = av.getAlignment().getHiddenColumns();
-      ContactMatrixI cm = av.getContactMatrix(tp.assocAnnotation);
-      MappableContactMatrixI mcm = null;
-      int offp;
-      if (cm instanceof MappableContactMatrixI)
+      if (mcm!=null)
       {
-        mcm = (MappableContactMatrixI) cm;
         int[] seqpos = mcm.getMappedPositionsFor(
                 tp.assocAnnotation.sequenceRef, colm);
         if (seqpos == null)