instant update when seq colour is pressed
authoramwaterhouse <Andrew Waterhouse>
Tue, 8 May 2007 10:58:23 +0000 (10:58 +0000)
committeramwaterhouse <Andrew Waterhouse>
Tue, 8 May 2007 10:58:23 +0000 (10:58 +0000)
src/jalview/appletgui/AppletJmol.java
src/jalview/gui/AppJmol.java

index 6e2047b..f64014b 100644 (file)
@@ -354,6 +354,7 @@ public class AppletJmol extends Frame
   {
     if (evt.getSource() == seqColour)
     {
+      lastCommand = null;
       colourBySequence = seqColour.getState();
       colourBySequence(ap);
     }
@@ -467,13 +468,14 @@ public class AppletJmol extends Frame
     return new Color(viewer.getAtomArgb(atomIndex));
   }
 
-  FeatureRenderer fr;
   String lastCommand;
-  public void colourBySequence(AlignmentPanel ap)
+  FeatureRenderer fr=null;
+  public void colourBySequence(AlignmentPanel sourceap)
   {
-    if(!colourBySequence)
-      return;
+    this.ap = sourceap;
 
+    if (!colourBySequence)
+      return;
 
     StructureMapping[] mapping = ssm.getMapping(pdbentry.getFile());
 
@@ -483,6 +485,7 @@ public class AppletJmol extends Frame
     SequenceRenderer sr = new SequenceRenderer(ap.av);
 
     boolean showFeatures = false;
+
     if (ap.av.showSequenceFeatures)
     {
       showFeatures = true;
@@ -502,14 +505,14 @@ public class AppletJmol extends Frame
       for (int m = 0; m < mapping.length; m++)
       {
         if (mapping[m].getSequence() == sequence[s]
-            && ap.av.alignment.findIndex(sequence[s])>-1)
+            && ap.av.alignment.findIndex(sequence[s]) > -1)
         {
           for (int r = 0; r < sequence[s].getLength(); r++)
           {
             int pos = mapping[m].getPDBResNum(
                 sequence[s].findPosition(r));
 
-            if (pos < 1 || pos==lastPos)
+            if (pos < 1 || pos == lastPos)
               continue;
 
             lastPos = pos;
@@ -519,7 +522,7 @@ public class AppletJmol extends Frame
             if (showFeatures)
               col = fr.findFeatureColour(col, sequence[s], r);
 
-            if (command.toString().endsWith(":" + mapping[m].getChain()+
+            if (command.toString().endsWith(":" + mapping[m].getChain() +
                                             ";color["
                                             + col.getRed() + ","
                                             + col.getGreen() + ","
@@ -537,10 +540,9 @@ public class AppletJmol extends Frame
             }
 
             command.append(";color["
-                             + col.getRed() + ","
-                             + col.getGreen() + ","
-                             + col.getBlue() + "]");
-
+                           + col.getRed() + ","
+                           + col.getGreen() + ","
+                           + col.getBlue() + "]");
           }
           break;
         }
@@ -548,11 +550,13 @@ public class AppletJmol extends Frame
     }
 
     if (lastCommand == null || !lastCommand.equals(command.toString()))
+    {
       viewer.evalStringQuiet(command.toString());
-
+    }
     lastCommand = command.toString();
   }
 
+
   StringBuffer condenseCommand(String command, int pos)
   {
 
index ab03d10..c082463 100644 (file)
@@ -413,6 +413,7 @@ public synchronized void addSequence(SequenceI [] seq)
 
   public void seqColour_actionPerformed(ActionEvent actionEvent)
   {
+    lastCommand = null;
     colourBySequence = seqColour.isSelected();
     colourBySequence(ap.alignFrame.alignPanel);
   }