JAL-1193 patch prevents JalviewJmolBinding from handling colourBySequence events...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 24 Oct 2012 16:00:59 +0000 (17:00 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Wed, 24 Oct 2012 16:00:59 +0000 (17:00 +0100)
src/jalview/ext/jmol/JalviewJmolBinding.java

index 025b970..257ca8c 100644 (file)
@@ -65,6 +65,12 @@ public abstract class JalviewJmolBinding implements StructureListener,
    * time.
    */
   private boolean loadingFromArchive = false;
+  
+  /**
+   * second flag to indicate if the jmol viewer should ignore sequence colouring
+   * events from the structure manager because the GUI is still setting up
+   */
+  private boolean loadingFinished = true;
 
   /**
    * state flag used to check if the Jmol viewer's paint method can be called
@@ -566,7 +572,7 @@ public abstract class JalviewJmolBinding implements StructureListener,
   public void colourBySequence(boolean showFeatures,
           jalview.api.AlignmentViewPanel alignmentv)
   {
-    if (!colourBySequence)
+    if (!colourBySequence || !loadingFinished)
       return;
     if (ssm == null)
     {
@@ -1438,10 +1444,24 @@ public abstract class JalviewJmolBinding implements StructureListener,
   {
     this.loadingFromArchive = loadingFromArchive;
   }
-
+  
+  /**
+   * 
+   * @return true if Jmol is still restoring state or loading is still going on (see setFinsihedLoadingFromArchive)
+   */
   public boolean isLoadingFromArchive()
   {
-    return loadingFromArchive;
+    return loadingFromArchive && !loadingFinished;
+  }
+
+  /**
+   * modify flag which controls if sequence colouring events are honoured by the binding. 
+   * Should be true for normal operation
+   * @param finishedLoading
+   */
+  public void setFinishedLoadingFromArchive(boolean finishedLoading)
+  {
+    loadingFinished = finishedLoading;
   }
 
   public void setBackgroundColour(java.awt.Color col)