updates to console
authoramwaterhouse <Andrew Waterhouse>
Fri, 23 Mar 2007 17:26:20 +0000 (17:26 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 23 Mar 2007 17:26:20 +0000 (17:26 +0000)
src/jalview/appletgui/AppletJmol.java

index b03775b..9ff3078 100644 (file)
@@ -55,6 +55,7 @@ public class AppletJmol extends Frame
   String fileLoadingError;\r
   boolean loadedInline;\r
   PDBEntry pdbentry;\r
+  boolean colourBySequence = true;\r
 \r
   public AppletJmol(PDBEntry pdbentry,\r
                     SequenceI[] seq,\r
@@ -224,9 +225,7 @@ public class AppletJmol extends Frame
         && scriptWindow.isVisible())\r
     {\r
       viewer.evalString(inputLine.getText());\r
-\r
-      history.append("\n"+inputLine.getText());\r
-\r
+      history.append("\n$ "+inputLine.getText());\r
       inputLine.setText("");\r
     }\r
 \r
@@ -317,6 +316,10 @@ public class AppletJmol extends Frame
   FeatureRenderer fr;\r
   public void colourBySequence(AlignmentPanel ap)\r
   {\r
+    if(!colourBySequence)\r
+      return;\r
+\r
+\r
     StructureMapping[] mapping = ssm.getMapping(pdbentry.getFile());\r
 \r
     if (mapping.length < 1)\r
@@ -338,6 +341,7 @@ public class AppletJmol extends Frame
 \r
     StringBuffer command = new StringBuffer();\r
 \r
+    int lastPos = -1;\r
     for (int s = 0; s < sequence.length; s++)\r
     {\r
       for (int m = 0; m < mapping.length; m++)\r
@@ -349,8 +353,25 @@ public class AppletJmol extends Frame
             int pos = mapping[m].getPDBResNum(\r
                 sequence[s].findPosition(r));\r
 \r
-            if (pos < 1)\r
+            if (pos < 1 || pos==lastPos)\r
+              continue;\r
+\r
+            lastPos = pos;\r
+\r
+            Color col = sr.getResidueBoxColour(sequence[s], r);\r
+\r
+            if (showFeatures)\r
+              col = fr.findFeatureColour(col, sequence[s], r);\r
+\r
+            if (command.toString().endsWith(":" + mapping[m].getChain()+\r
+                                            ";color["\r
+                                            + col.getRed() + ","\r
+                                            + col.getGreen() + ","\r
+                                            + col.getBlue() + "]"))\r
+            {\r
+              command = condenseCommand(command.toString(), pos);\r
               continue;\r
+            }\r
 \r
             command.append(";select " + pos);\r
 \r
@@ -359,17 +380,13 @@ public class AppletJmol extends Frame
               command.append(":" + mapping[m].getChain());\r
             }\r
 \r
-            Color col = sr.getResidueBoxColour(sequence[s], r);\r
-\r
-            if (showFeatures)\r
-              col = fr.findFeatureColour(col, sequence[s], r);\r
-\r
-            command.append("; color ["\r
-                           + col.getRed() + ","\r
-                           + col.getGreen() + ","\r
-                           + col.getBlue() + "]");\r
+            command.append(";color["\r
+                             + col.getRed() + ","\r
+                             + col.getGreen() + ","\r
+                             + col.getBlue() + "]");\r
 \r
           }\r
+          break;\r
         }\r
       }\r
     }\r
@@ -377,6 +394,29 @@ public class AppletJmol extends Frame
     viewer.evalStringQuiet(command.toString());\r
   }\r
 \r
+  StringBuffer condenseCommand(String command, int pos)\r
+  {\r
+\r
+    StringBuffer sb = new StringBuffer(command.substring(0, command.lastIndexOf("select")+7));\r
+\r
+    command = command.substring(sb.length());\r
+\r
+    String start;\r
+\r
+    if (command.indexOf("-") > -1)\r
+    {\r
+      start = command.substring(0,command.indexOf("-"));\r
+    }\r
+    else\r
+    {\r
+      start = command.substring(0, command.indexOf(":"));\r
+    }\r
+\r
+    sb.append(start+"-"+pos+command.substring(command.indexOf(":")));\r
+\r
+    return sb;\r
+  }\r
+\r
   /////////////////////////////////\r
   //JmolStatusListener\r
 \r
@@ -388,9 +428,7 @@ public class AppletJmol extends Frame
   }\r
 \r
   public void createImage(String file, String type, int quality)\r
-  {\r
-    System.out.println("JMOL CREATE IMAGE");\r
-  }\r
+  {}\r
 \r
   public void setCallbackFunction(String callbackType,\r
                                   String callbackFunction)\r
@@ -425,7 +463,6 @@ public class AppletJmol extends Frame
                                 pdbentry.getFile(),\r
                                 AppletFormatAdapter.PASTE);\r
         pdbentry.setFile("INLINE"+pdb.id);\r
-\r
       }\r
       else\r
       {\r
@@ -487,14 +524,17 @@ public class AppletJmol extends Frame
 \r
   public void sendConsoleMessage(String strStatus)\r
   {\r
-   // if (scriptWindow != null)\r
-   //   scriptWindow.sendConsoleMessage(strStatus);\r
+    if(history!=null && strStatus!=null\r
+       && !strStatus.equals("Script completed"))\r
+    {\r
+      history.append("\n"+strStatus);\r
+    }\r
   }\r
 \r
   public void notifyScriptTermination(String strStatus, int msWalltime)\r
   {\r
-  //  if (scriptWindow != null)\r
-  //    scriptWindow.notifyScriptTermination(strStatus, msWalltime);\r
+   // if (scriptWindow != null)\r
+   //   scriptWindow.notifyScriptTermination(strStatus, msWalltime);\r
   }\r
 \r
   public void handlePopupMenu(int x, int y)\r