JAL-2899 colouring moved from SwingWorker to a background thread
authorJim Procter <jprocter@issues.jalview.org>
Tue, 1 May 2018 08:21:39 +0000 (09:21 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 1 May 2018 08:21:39 +0000 (09:21 +0100)
src/jalview/ext/jmol/JalviewJmolBinding.java

index bbb75cf..2a85a9f 100644 (file)
@@ -52,8 +52,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Vector;
 
-import javax.swing.SwingUtilities;
-
 import org.jmol.adapter.smarter.SmarterJmolAdapter;
 import org.jmol.api.JmolAppConsoleInterface;
 import org.jmol.api.JmolSelectionListener;
@@ -480,6 +478,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
     lastCommand = command;
   }
 
+  Thread colourby = null;
   /**
    * Sends a set of colour commands to the structure viewer
    * 
@@ -489,7 +488,12 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
   protected void colourBySequence(
           final StructureMappingcommandSet[] colourBySequenceCommands)
   {
-    SwingUtilities.invokeLater(new Runnable()
+    if (colourby != null)
+    {
+      colourby.interrupt();
+      colourby = null;
+    }
+    colourby = new Thread(new Runnable()
     {
       @Override
       public void run()
@@ -503,6 +507,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
         }
       }
     });
+    colourby.start();
   }
 
   /**