Merge branch 'features/JAL-2295setChimeraAttributes' into
[jalview.git] / src / jalview / ext / rbvi / chimera / JalviewChimeraBinding.java
index 75ddc9c..2042ac4 100644 (file)
@@ -103,8 +103,6 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
    */
   private boolean loadingFinished = true;
 
-  public String fileLoadingError;
-
   /*
    * Map of ChimeraModel objects keyed by PDB full local file name
    */
@@ -256,18 +254,6 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
   }
 
   /**
-   * Construct a title string for the viewer window based on the data Jalview
-   * knows about
-   * 
-   * @param verbose
-   * @return
-   */
-  public String getViewerTitle(boolean verbose)
-  {
-    return getViewerTitle("Chimera", verbose);
-  }
-
-  /**
    * Tells Chimera to display only the specified chains
    * 
    * @param toshow
@@ -329,6 +315,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
     releaseUIResources();
   }
 
+  @Override
   public void colourByChain()
   {
     colourBySequence = false;
@@ -344,6 +331,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
    * <li>all others - white</li>
    * </ul>
    */
+  @Override
   public void colourByCharge()
   {
     colourBySequence = false;
@@ -365,6 +353,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
    * @param _hiddenCols
    *          an array of corresponding hidden columns for each alignment
    */
+  @Override
   public void superposeStructures(AlignmentI[] _alignment,
           int[] _refStructure, ColumnSelection[] _hiddenCols)
   {
@@ -692,39 +681,37 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
           String progressMsg);
 
   /**
-   * colour any structures associated with sequences in the given alignment
-   * using the getFeatureRenderer() and getSequenceRenderer() renderers but only
-   * if colourBySequence is enabled.
+   * Sends a set of colour commands to the structure viewer
+   * 
+   * @param colourBySequenceCommands
    */
-  public void colourBySequence(boolean showFeatures,
-          jalview.api.AlignmentViewPanel alignmentv)
+  @Override
+  protected void colourBySequence(
+          StructureMappingcommandSet[] colourBySequenceCommands)
   {
-    if (!colourBySequence || !loadingFinished)
+    for (StructureMappingcommandSet cpdbbyseq : colourBySequenceCommands)
     {
-      return;
-    }
-    if (getSsm() == null)
-    {
-      return;
-    }
-    String[] files = getPdbFile();
-
-    SequenceRenderer sr = getSequenceRenderer(alignmentv);
-
-    FeatureRenderer fr = null;
-    if (showFeatures)
-    {
-      fr = getFeatureRenderer(alignmentv);
+      for (String command : cpdbbyseq.commands)
+      {
+        sendAsynchronousCommand(command, COLOURING_CHIMERA);
+      }
     }
-    AlignmentI alignment = alignmentv.getAlignment();
+  }
 
-    StructureMappingcommandSet colourBySequenceCommands = ChimeraCommands
-            .getColourBySequenceCommand(getSsm(), files, getSequence(), sr,
-                    fr, alignment);
-    for (String command : colourBySequenceCommands.commands)
-    {
-      sendAsynchronousCommand(command, COLOURING_CHIMERA);
-    }
+  /**
+   * @param files
+   * @param sr
+   * @param fr
+   * @param alignment
+   * @return
+   */
+  @Override
+  protected StructureMappingcommandSet[] getColourBySequenceCommands(
+          String[] files, SequenceRenderer sr, FeatureRenderer fr,
+          AlignmentI alignment)
+  {
+    return ChimeraCommands.getColourBySequenceCommand(getSsm(), files,
+            getSequence(), sr, fr, alignment);
   }
 
   /**
@@ -754,23 +741,20 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
   // //////////////////////////
 
   /**
-   * returns the current featureRenderer that should be used to colour the
-   * structures
-   * 
-   * @param alignment
-   * 
-   * @return
-   */
-  public abstract FeatureRenderer getFeatureRenderer(
-          AlignmentViewPanel alignment);
-
-  /**
    * instruct the Jalview binding to update the pdbentries vector if necessary
    * prior to matching the viewer's contents to the list of structure files
    * Jalview knows about.
    */
   public abstract void refreshPdbEntries();
 
+  /**
+   * map between index of model filename returned from getPdbFile and the first
+   * index of models from this file in the viewer. Note - this is not trimmed -
+   * use getPdbFile to get number of unique models.
+   */
+  private int _modelFileNameMap[];
+
+
   // ////////////////////////////////
   // /StructureListener
   @Override
@@ -786,17 +770,6 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
   }
 
   /**
-   * returns the current sequenceRenderer that should be used to colour the
-   * structures
-   * 
-   * @param alignment
-   * 
-   * @return
-   */
-  public abstract SequenceRenderer getSequenceRenderer(
-          AlignmentViewPanel alignment);
-
-  /**
    * Construct and send a command to highlight zero, one or more atoms. We do
    * this by sending an "rlabel" command to show the residue label at that
    * position.
@@ -953,6 +926,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
     return loadNotifiesHandled;
   }
 
+  @Override
   public void setJalviewColourScheme(ColourSchemeI cs)
   {
     colourBySequence = false;
@@ -969,12 +943,14 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
 
     List<String> residueSet = ResidueProperties.getResidues(isNucleotide(),
             false);
-    for (String res : residueSet)
+    for (String resName : residueSet)
     {
-      Color col = cs.findColour(res.charAt(0));
+      char res = resName.length() == 3 ? ResidueProperties
+              .getSingleCharacterCode(resName) : resName.charAt(0);
+      Color col = cs.findColour(res, 0, null, null, 0f);
       command.append("color " + col.getRed() / normalise + ","
               + col.getGreen() / normalise + "," + col.getBlue()
-              / normalise + " ::" + res + ";");
+              / normalise + " ::" + resName + ";");
     }
 
     sendAsynchronousCommand(command.toString(), COLOURING_CHIMERA);
@@ -1025,6 +1001,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel
    *      .html
    * @param col
    */
+  @Override
   public void setBackgroundColour(Color col)
   {
     viewerCommandHistory(false);